[LTO] Make detection of WPD remark enablement more robust
Summary:
Currently only the first function in the module is checked to
see if it has remarks enabled. If that first function is a declaration,
remarks will be incorrectly skipped. Change to look for the first
non-empty function.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51556
llvm-svn: 342477
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 2f75c6b..0549f0a 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1325,15 +1325,14 @@
bool DevirtModule::areRemarksEnabled() {
const auto &FL = M.getFunctionList();
- if (FL.empty())
- return false;
- const Function &Fn = FL.front();
-
- const auto &BBL = Fn.getBasicBlockList();
- if (BBL.empty())
- return false;
- auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBL.front());
- return DI.isEnabled();
+ for (const Function &Fn : FL) {
+ const auto &BBL = Fn.getBasicBlockList();
+ if (BBL.empty())
+ continue;
+ auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBL.front());
+ return DI.isEnabled();
+ }
+ return false;
}
void DevirtModule::scanTypeTestUsers(Function *TypeTestFunc,