diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-10-03 19:35:30 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-10-03 19:35:30 +0000 |
commit | 0359a193a74d410e4664344cd1ab480568bc321c (patch) | |
tree | 89d62149a8213c5a69bb31e118098852c07b52d2 | |
parent | 31dd377ffc1ddda62e99239c8907ffea37fe8da2 (diff) | |
download | bcm5719-llvm-0359a193a74d410e4664344cd1ab480568bc321c.tar.gz bcm5719-llvm-0359a193a74d410e4664344cd1ab480568bc321c.zip |
[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!
llvm-svn: 283137
-rw-r--r-- | llvm/lib/Transforms/IPO/PruneEH.cpp | 5 | ||||
-rw-r--r-- | llvm/test/Transforms/PruneEH/ipo-nounwind.ll | 43 |
2 files changed, 44 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index 2aa3fa55cef..d9acb9b1a74 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -90,10 +90,7 @@ static bool runImpl(CallGraphSCC &SCC, CallGraph &CG) { 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 { diff --git a/llvm/test/Transforms/PruneEH/ipo-nounwind.ll b/llvm/test/Transforms/PruneEH/ipo-nounwind.ll new file mode 100644 index 00000000000..ba3fab1c0dd --- /dev/null +++ b/llvm/test/Transforms/PruneEH/ipo-nounwind.ll @@ -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 +} |