[llvm] e5c1a90 - [llvm-dwarfdump] Avoid possible div-by-zero in debug output
Dmitry Vassiliev via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 9 06:04:04 PST 2022
Author: Dmitry Vassiliev
Date: 2022-03-09T18:03:26+04:00
New Revision: e5c1a908b36eadb59c2ec7dd1cc784e1e1fa74f8
URL: https://github.com/llvm/llvm-project/commit/e5c1a908b36eadb59c2ec7dd1cc784e1e1fa74f8
DIFF: https://github.com/llvm/llvm-project/commit/e5c1a908b36eadb59c2ec7dd1cc784e1e1fa74f8.diff
LOG: [llvm-dwarfdump] Avoid possible div-by-zero in debug output
Added:
Modified:
llvm/tools/llvm-dwarfdump/Statistics.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index 90df6a82ee374..ed92665e04839 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -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;
}
More information about the llvm-commits
mailing list