[PATCH] D51556: [LTO] Make detection of WPD remark enablement more robust

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 18 06:43:58 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342477: [LTO] Make detection of WPD remark enablement more robust (authored by tejohnson, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D51556

Files:
  llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/trunk/test/ThinLTO/X86/cfi-devirt.ll


Index: llvm/trunk/test/ThinLTO/X86/cfi-devirt.ll
===================================================================
--- llvm/trunk/test/ThinLTO/X86/cfi-devirt.ll
+++ llvm/trunk/test/ThinLTO/X86/cfi-devirt.ll
@@ -11,6 +11,7 @@
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
+; RUN:   -r=%t.o,empty,p \
 ; RUN:   -r=%t.o,_ZTV1B, \
 ; RUN:   -r=%t.o,_ZTV1C, \
 ; RUN:   -r=%t.o,_ZN1A1nEi, \
@@ -27,6 +28,7 @@
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
+; RUN:   -r=%t.o,empty,p \
 ; RUN:   -r=%t.o,_ZTV1B, \
 ; RUN:   -r=%t.o,_ZTV1C, \
 ; RUN:   -r=%t.o,_ZN1A1nEi, \
@@ -48,6 +50,10 @@
 @_ZTV1B = constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.B*, i32)* @_ZN1B1fEi to i8*), i8* bitcast (i32 (%struct.A*, i32)* @_ZN1A1nEi to i8*)] }, !type !0, !type !1
 @_ZTV1C = constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.C*, i32)* @_ZN1C1fEi to i8*), i8* bitcast (i32 (%struct.A*, i32)* @_ZN1A1nEi to i8*)] }, !type !0, !type !2
 
+; Put declaration first to test handling of remarks when the first
+; function has no basic blocks.
+declare void @empty()
+
 ; CHECK-IR-LABEL: define i32 @test
 define i32 @test(%struct.A* %obj, i32 %a) {
 entry:
Index: llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/trunk/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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51556.165956.patch
Type: text/x-patch
Size: 2234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/9cdb1b55/attachment.bin>


More information about the llvm-commits mailing list