[llvm-dwarfdump] Avoid possible div-by-zero in debug output

This commit is contained in:
Dmitry Vassiliev 2022-03-09 18:03:26 +04:00
parent e81f566de6
commit e5c1a908b3
1 changed files with 11 additions and 6 deletions

View File

@ -1044,14 +1044,19 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
LocStats.LocalVarNonEntryValLocStats);
J.objectEnd();
OS << '\n';
LLVM_DEBUG(llvm::dbgs() << "Total Availability: "
<< (int)std::round((VarParamWithLoc.Value * 100.0) /
LLVM_DEBUG(
llvm::dbgs() << "Total Availability: "
<< (VarParamTotal.Value
? (int)std::round((VarParamWithLoc.Value * 100.0) /
VarParamTotal.Value)
<< "%\n";
llvm::dbgs() << "PC Ranges covered: "
<< (int)std::round(
: 0)
<< "%\n";
llvm::dbgs() << "PC Ranges covered: "
<< (GlobalStats.ScopeBytes.Value
? (int)std::round(
(GlobalStats.ScopeBytesCovered.Value * 100.0) /
GlobalStats.ScopeBytes.Value)
<< "%\n");
: 0)
<< "%\n");
return true;
}