Skip to content

Commit e5c1a90

Browse files
committed
[llvm-dwarfdump] Avoid possible div-by-zero in debug output
1 parent e81f566 commit e5c1a90

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

llvm/tools/llvm-dwarfdump/Statistics.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,14 +1044,19 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
10441044
LocStats.LocalVarNonEntryValLocStats);
10451045
J.objectEnd();
10461046
OS << '\n';
1047-
LLVM_DEBUG(llvm::dbgs() << "Total Availability: "
1048-
<< (int)std::round((VarParamWithLoc.Value * 100.0) /
1047+
LLVM_DEBUG(
1048+
llvm::dbgs() << "Total Availability: "
1049+
<< (VarParamTotal.Value
1050+
? (int)std::round((VarParamWithLoc.Value * 100.0) /
10491051
VarParamTotal.Value)
1050-
<< "%\n";
1051-
llvm::dbgs() << "PC Ranges covered: "
1052-
<< (int)std::round(
1052+
: 0)
1053+
<< "%\n";
1054+
llvm::dbgs() << "PC Ranges covered: "
1055+
<< (GlobalStats.ScopeBytes.Value
1056+
? (int)std::round(
10531057
(GlobalStats.ScopeBytesCovered.Value * 100.0) /
10541058
GlobalStats.ScopeBytes.Value)
1055-
<< "%\n");
1059+
: 0)
1060+
<< "%\n");
10561061
return true;
10571062
}

0 commit comments

Comments
 (0)