diff options
Diffstat (limited to 'test/Transforms/SimplifyCFG')
| -rw-r--r-- | test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/EmptyBlockMerge.ll (renamed from test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll) | 5 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/PHINode.ll (renamed from test/Transforms/SimplifyCFG/2002-06-24-PHINode.ll) | 3 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/PR9946.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/SpeculativeExec.ll | 41 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll | 26 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/branch-fold-dbg.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/select-gep.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/switch-on-const-select.ll | 9 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/trivial-throw.ll | 77 | ||||
| -rw-r--r-- | test/Transforms/SimplifyCFG/volatile-phioper.ll | 48 |
11 files changed, 206 insertions, 11 deletions
diff --git a/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll index 7bffa1a8e0e2..333336de7673 100644 --- a/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll +++ b/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -simplifycfg -disable-output +; RUN: opt -simplifycfg -disable-output < %s ; END. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll b/test/Transforms/SimplifyCFG/EmptyBlockMerge.ll index feffb4e4c812..aba08dc073a8 100644 --- a/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll +++ b/test/Transforms/SimplifyCFG/EmptyBlockMerge.ll @@ -1,8 +1,6 @@ ; Basic block #2 should not be merged into BB #3! ; -; RUN: opt < %s -simplifycfg -S | \ -; RUN: grep "br label" -; +; RUN: opt < %s -simplifycfg -S | FileCheck %s declare void @foo() @@ -13,6 +11,7 @@ bb0: br i1 %cond218, label %bb3, label %bb2 bb2: ; preds = %bb0 call void @foo( ) +; CHECK: br label %bb3 br label %bb3 bb3: ; preds = %bb2, %bb0 %reg117 = phi i32 [ 110, %bb2 ], [ %reg108, %bb0 ] ; <i32> [#uses=1] diff --git a/test/Transforms/SimplifyCFG/2002-06-24-PHINode.ll b/test/Transforms/SimplifyCFG/PHINode.ll index 88f32bc08279..25a242a55997 100644 --- a/test/Transforms/SimplifyCFG/2002-06-24-PHINode.ll +++ b/test/Transforms/SimplifyCFG/PHINode.ll @@ -1,10 +1,11 @@ ; -simplifycfg is not folding blocks if there is a PHI node involved. This ; should be fixed eventually -; RUN: opt < %s -simplifycfg -S | not grep br +; RUN: opt < %s -simplifycfg -S | FileCheck %s define i32 @main(i32 %argc) { ; <label>:0 +; CHECK-NOT: br label %InlinedFunctionReturnNode br label %InlinedFunctionReturnNode InlinedFunctionReturnNode: ; preds = %0 %X = phi i32 [ 7, %0 ] ; <i32> [#uses=1] diff --git a/test/Transforms/SimplifyCFG/PR9946.ll b/test/Transforms/SimplifyCFG/PR9946.ll index 4a61b846052e..c355a8f5cc98 100644 --- a/test/Transforms/SimplifyCFG/PR9946.ll +++ b/test/Transforms/SimplifyCFG/PR9946.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -simplifycfg -disable-output +; RUN: opt -simplifycfg -disable-output < %s @foo = external constant i32 diff --git a/test/Transforms/SimplifyCFG/SpeculativeExec.ll b/test/Transforms/SimplifyCFG/SpeculativeExec.ll index a61867fe89c7..dd2e5d1c3a77 100644 --- a/test/Transforms/SimplifyCFG/SpeculativeExec.ll +++ b/test/Transforms/SimplifyCFG/SpeculativeExec.ll @@ -44,3 +44,44 @@ join: ret i8 %c } +define i8* @test4(i1* %dummy, i8* %a, i8* %b) { +; Test that we don't speculate an arbitrarily large number of unfolded constant +; expressions. +; CHECK: @test4 + +entry: + %cond1 = load volatile i1* %dummy + br i1 %cond1, label %if, label %end + +if: + %cond2 = load volatile i1* %dummy + br i1 %cond2, label %then, label %end + +then: + br label %end + +end: + %x1 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 1 to i8*), %then ] + %x2 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 2 to i8*), %then ] + %x3 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 3 to i8*), %then ] + %x4 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 4 to i8*), %then ] + %x5 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 5 to i8*), %then ] + %x6 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 6 to i8*), %then ] + %x7 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 7 to i8*), %then ] + %x8 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 8 to i8*), %then ] + %x9 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 9 to i8*), %then ] + %x10 = phi i8* [ %a, %entry ], [ %b, %if ], [ inttoptr (i64 10 to i8*), %then ] +; CHECK-NOT: select +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* +; CHECK: phi i8* + + ret i8* %x10 +} diff --git a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll index 8a59992f5e64..5f70465c64d4 100644 --- a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll +++ b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll @@ -777,3 +777,29 @@ return: ; CHECK: switch.lookup: ; CHECK: getelementptr inbounds [5 x i32]* @switch.table6, i32 0, i32 %switch.tableidx } + +; Don't create a table with illegal type +; rdar://12779436 +define i96 @illegaltype(i32 %c) { +entry: + switch i32 %c, label %sw.default [ + i32 42, label %return + i32 43, label %sw.bb1 + i32 44, label %sw.bb2 + i32 45, label %sw.bb3 + i32 46, label %sw.bb4 + ] + +sw.bb1: br label %return +sw.bb2: br label %return +sw.bb3: br label %return +sw.bb4: br label %return +sw.default: br label %return +return: + %retval.0 = phi i96 [ 15, %sw.default ], [ 27, %sw.bb4 ], [ -1, %sw.bb3 ], [ 0, %sw.bb2 ], [ 123, %sw.bb1 ], [ 55, %entry ] + ret i96 %retval.0 + +; CHECK: @illegaltype +; CHECK-NOT: @switch.table +; CHECK: switch i32 %c +} diff --git a/test/Transforms/SimplifyCFG/branch-fold-dbg.ll b/test/Transforms/SimplifyCFG/branch-fold-dbg.ll index 0897c95a6778..0526883fe8f4 100644 --- a/test/Transforms/SimplifyCFG/branch-fold-dbg.ll +++ b/test/Transforms/SimplifyCFG/branch-fold-dbg.ll @@ -1,4 +1,4 @@ -; RUN: opt -simplifycfg -S %s | FileCheck %s +; RUN: opt -simplifycfg -S < %s | FileCheck %s %0 = type { i32*, i32* } diff --git a/test/Transforms/SimplifyCFG/select-gep.ll b/test/Transforms/SimplifyCFG/select-gep.ll index 7654d0271a9a..3e2a6237b275 100644 --- a/test/Transforms/SimplifyCFG/select-gep.ll +++ b/test/Transforms/SimplifyCFG/select-gep.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -simplifycfg %s | FileCheck %s +; RUN: opt -S -simplifycfg < %s | FileCheck %s define i8* @test1(i8* %x, i64 %y) nounwind { entry: diff --git a/test/Transforms/SimplifyCFG/switch-on-const-select.ll b/test/Transforms/SimplifyCFG/switch-on-const-select.ll index 673a62bf035c..9cd709ff8ecf 100644 --- a/test/Transforms/SimplifyCFG/switch-on-const-select.ll +++ b/test/Transforms/SimplifyCFG/switch-on-const-select.ll @@ -35,7 +35,7 @@ define i32 @bar(i64 %x, i64 %y) nounwind { ; CHECK: @bar entry: ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call void @bees.a() nounwind +; CHECK-NEXT: tail call void @bees.a() [[NUW:#[0-9]+]] ; CHECK-NEXT: ret i32 0 %lt = icmp slt i64 %x, %y %qux = select i1 %lt, i32 0, i32 2 @@ -61,7 +61,7 @@ define void @bazz(i64 %x, i64 %y) nounwind { ; CHECK: @bazz entry: ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call void @bees.b() nounwind +; CHECK-NEXT: tail call void @bees.b() [[NUW]] ; CHECK-NEXT: ret void %lt = icmp slt i64 %x, %y %qux = select i1 %lt, i32 10, i32 12 @@ -86,7 +86,7 @@ define void @quux(i64 %x, i64 %y) nounwind { ; CHECK: @quux entry: ; CHECK-NEXT: entry: -; CHECK-NEXT: tail call void @bees.a() nounwind +; CHECK-NEXT: tail call void @bees.a() [[NUW]] ; CHECK-NEXT: ret void %lt = icmp slt i64 %x, %y %qux = select i1 %lt, i32 0, i32 0 @@ -136,3 +136,6 @@ bees: declare void @llvm.trap() nounwind noreturn declare void @bees.a() nounwind declare void @bees.b() nounwind + +; CHECK: attributes [[NUW]] = { nounwind } +; CHECK: attributes #1 = { noreturn nounwind } diff --git a/test/Transforms/SimplifyCFG/trivial-throw.ll b/test/Transforms/SimplifyCFG/trivial-throw.ll new file mode 100644 index 000000000000..ca2b5693e600 --- /dev/null +++ b/test/Transforms/SimplifyCFG/trivial-throw.ll @@ -0,0 +1,77 @@ +; RUN: opt -simplifycfg -S < %s | FileCheck %s +; <rdar://problem/13360379> + +@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* +@_ZTS13TestException = linkonce_odr constant [16 x i8] c"13TestException\00" +@_ZTI13TestException = linkonce_odr unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([16 x i8]* @_ZTS13TestException, i32 0, i32 0) } + +define void @throw(i32 %n) #0 { +entry: + %exception = call i8* @__cxa_allocate_exception(i64 1) #4 + call void @__cxa_throw(i8* %exception, i8* bitcast ({ i8*, i8* }* @_ZTI13TestException to i8*), i8* null) #2 + unreachable +} + +define void @func() #0 { +entry: +; CHECK: func() +; CHECK: invoke void @throw +; CHECK-NOT: call void @throw + invoke void @throw(i32 42) #0 + to label %exit unwind label %lpad + +lpad: + %tmp0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup + resume { i8*, i32 } %tmp0 + +exit: + invoke void @abort() #2 + to label %invoke.cont unwind label %lpad1 + +invoke.cont: + unreachable + +lpad1: + %tmp1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* bitcast ({ i8*, i8* }* @_ZTI13TestException to i8*) + %tmp2 = extractvalue { i8*, i32 } %tmp1, 1 + %tmp3 = call i32 @llvm.eh.typeid.for(i8* bitcast ({ i8*, i8* }* @_ZTI13TestException to i8*)) #4 + %matches = icmp eq i32 %tmp2, %tmp3 + br i1 %matches, label %catch, label %eh.resume + +catch: + ret void + +eh.resume: + resume { i8*, i32 } %tmp1 +} + +define linkonce_odr hidden void @__clang_call_terminate(i8*) #1 { + %2 = call i8* @__cxa_begin_catch(i8* %0) #4 + call void @_ZSt9terminatev() #5 + unreachable +} + +declare void @abort() #2 + +declare i32 @llvm.eh.typeid.for(i8*) #3 + +declare void @__cxa_end_catch() + +declare i8* @__cxa_allocate_exception(i64) + +declare i32 @__gxx_personality_v0(...) + +declare void @__cxa_throw(i8*, i8*, i8*) + +declare i8* @__cxa_begin_catch(i8*) + +declare void @_ZSt9terminatev() + +attributes #0 = { ssp uwtable } +attributes #1 = { noinline noreturn nounwind } +attributes #2 = { noreturn } +attributes #3 = { nounwind readnone } +attributes #4 = { nounwind } +attributes #5 = { noreturn nounwind } diff --git a/test/Transforms/SimplifyCFG/volatile-phioper.ll b/test/Transforms/SimplifyCFG/volatile-phioper.ll new file mode 100644 index 000000000000..164898897eff --- /dev/null +++ b/test/Transforms/SimplifyCFG/volatile-phioper.ll @@ -0,0 +1,48 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s +; +; rdar:13349374 +; +; SimplifyCFG should not eliminate blocks with volatile stores. +; Essentially, volatile needs to be backdoor that tells the optimizer +; it can no longer use language standard as an excuse. The compiler +; needs to expose the volatile access to the platform. +; +; CHECK: @test +; CHECK: entry: +; CHECK: @Trace +; CHECK: while.body: +; CHECK: store volatile +; CHECK: end: +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +define void @test(i8** nocapture %PeiServices) #0 { +entry: + %call = tail call i32 (...)* @Trace() #2 + %tobool = icmp eq i32 %call, 0 + br i1 %tobool, label %while.body, label %if.then + +if.then: ; preds = %entry + %call1 = tail call i32 (...)* @Trace() #2 + br label %while.body + +while.body: ; preds = %entry, %if.then, %while.body + %Addr.017 = phi i8* [ %incdec.ptr, %while.body ], [ null, %if.then ], [ null, %entry ] + %x.016 = phi i8 [ %inc, %while.body ], [ 0, %if.then ], [ 0, %entry ] + %inc = add i8 %x.016, 1 + %incdec.ptr = getelementptr inbounds i8* %Addr.017, i64 1 + store volatile i8 %x.016, i8* %Addr.017, align 1 + %0 = ptrtoint i8* %incdec.ptr to i64 + %1 = trunc i64 %0 to i32 + %cmp = icmp ult i32 %1, 4096 + br i1 %cmp, label %while.body, label %end + +end: + ret void +} +declare i32 @Trace(...) #1 + +attributes #0 = { nounwind ssp uwtable "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" } +attributes #1 = { "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" } +attributes #2 = { nounwind } + +!0 = metadata !{i32 1039} |
