[llvm] r283137 - [PruneEH] Be correct in the face IPO
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 3 12:35:31 PDT 2016
Author: sanjoy
Date: Mon Oct 3 14:35:30 2016
New Revision: 283137
URL: http://llvm.org/viewvc/llvm-project?rev=283137&view=rev
Log:
[PruneEH] Be correct in the face IPO
This fixes one spot I had missed in r265762. Credit goes to Philip
Reames for spotting this one!
Added:
llvm/trunk/test/Transforms/PruneEH/ipo-nounwind.ll
Modified:
llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=283137&r1=283136&r2=283137&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Mon Oct 3 14:35:30 2016
@@ -90,10 +90,7 @@ static bool runImpl(CallGraphSCC &SCC, C
if (!F) {
SCCMightUnwind = true;
SCCMightReturn = true;
- } else if (F->isDeclaration() || F->isInterposable()) {
- // Note: isInterposable (as opposed to hasExactDefinition) is fine above,
- // since we're not inferring new attributes here, but only using existing,
- // assumed to be correct, function attributes.
+ } else if (!F->hasExactDefinition()) {
SCCMightUnwind |= !F->doesNotThrow();
SCCMightReturn |= !F->doesNotReturn();
} else {
Added: llvm/trunk/test/Transforms/PruneEH/ipo-nounwind.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PruneEH/ipo-nounwind.ll?rev=283137&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PruneEH/ipo-nounwind.ll (added)
+++ llvm/trunk/test/Transforms/PruneEH/ipo-nounwind.ll Mon Oct 3 14:35:30 2016
@@ -0,0 +1,43 @@
+; RUN: opt -S -prune-eh < %s | FileCheck %s
+
+declare void @may_throw()
+
+; @callee below may be an optimized form of this function, which can
+; throw at runtime (see r265762 for more details):
+;
+; define linkonce_odr void @callee(i32* %ptr) noinline {
+; entry:
+; %val0 = load atomic i32, i32* %ptr unordered, align 4
+; %val1 = load atomic i32, i32* %ptr unordered, align 4
+; %cmp = icmp eq i32 %val0, %val1
+; br i1 %cmp, label %left, label %right
+
+; left:
+; ret void
+
+; right:
+; call void @may_throw()
+; ret void
+; }
+
+define linkonce_odr void @callee(i32* %ptr) noinline {
+ ret void
+}
+
+define i32 @caller(i32* %ptr) personality i32 3 {
+; CHECK-LABEL: @caller(
+; CHECK: invoke void @callee(i32* %ptr)
+; CHECK-NEXT: to label %normal unwind label %unwind
+
+entry:
+ invoke void @callee(i32* %ptr)
+ to label %normal unwind label %unwind
+
+normal:
+ ret i32 1
+
+unwind:
+ %res = landingpad { i8*, i32 }
+ cleanup
+ ret i32 2
+}
More information about the llvm-commits
mailing list