diff options
author | Shih-wei Liao <sliao@google.com> | 2010-02-10 11:10:31 -0800 |
---|---|---|
committer | Shih-wei Liao <sliao@google.com> | 2010-02-10 11:10:31 -0800 |
commit | e264f62ca09a8f65c87a46d562a4d0f9ec5d457e (patch) | |
tree | 59e3d57ef656cef79afa708ae0a3daf25cd91fcf /test/Transforms/SimplifyCFG | |
download | external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.zip external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.gz external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.bz2 |
Check in LLVM r95781.
Diffstat (limited to 'test/Transforms/SimplifyCFG')
80 files changed, 4826 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll b/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll new file mode 100644 index 0000000..414235b --- /dev/null +++ b/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll @@ -0,0 +1,22 @@ +; Basic block #2 should not be merged into BB #3! +; +; RUN: opt < %s -simplifycfg -S | \ +; RUN: grep {br label} +; + +declare void @foo() + +define void @cprop_test12(i32* %data) { +bb0: + %reg108 = load i32* %data ; <i32> [#uses=2] + %cond218 = icmp ne i32 %reg108, 5 ; <i1> [#uses=1] + br i1 %cond218, label %bb3, label %bb2 +bb2: ; preds = %bb0 + call void @foo( ) + br label %bb3 +bb3: ; preds = %bb2, %bb0 + %reg117 = phi i32 [ 110, %bb2 ], [ %reg108, %bb0 ] ; <i32> [#uses=1] + store i32 %reg117, i32* %data + ret void +} + diff --git a/test/Transforms/SimplifyCFG/2002-05-21-PHIElimination.ll b/test/Transforms/SimplifyCFG/2002-05-21-PHIElimination.ll new file mode 100644 index 0000000..055386b --- /dev/null +++ b/test/Transforms/SimplifyCFG/2002-05-21-PHIElimination.ll @@ -0,0 +1,19 @@ +; CFG Simplification is making a loop dead, then changing the add into: +; +; %V1 = add int %V1, 1 +; +; Which is not valid SSA +; +; RUN: opt < %s -simplifycfg | llvm-dis + +define void @test() { +; <label>:0 + br i1 true, label %end, label %Loop +Loop: ; preds = %Loop, %0 + %V = phi i32 [ 0, %0 ], [ %V1, %Loop ] ; <i32> [#uses=1] + %V1 = add i32 %V, 1 ; <i32> [#uses=1] + br label %Loop +end: ; preds = %0 + ret void +} + diff --git a/test/Transforms/SimplifyCFG/2002-06-24-PHINode.ll b/test/Transforms/SimplifyCFG/2002-06-24-PHINode.ll new file mode 100644 index 0000000..88f32bc --- /dev/null +++ b/test/Transforms/SimplifyCFG/2002-06-24-PHINode.ll @@ -0,0 +1,14 @@ +; -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 + +define i32 @main(i32 %argc) { +; <label>:0 + br label %InlinedFunctionReturnNode +InlinedFunctionReturnNode: ; preds = %0 + %X = phi i32 [ 7, %0 ] ; <i32> [#uses=1] + %Y = add i32 %X, %argc ; <i32> [#uses=1] + ret i32 %Y +} + diff --git a/test/Transforms/SimplifyCFG/2002-09-24-PHIAssertion.ll b/test/Transforms/SimplifyCFG/2002-09-24-PHIAssertion.ll new file mode 100644 index 0000000..9a12062 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2002-09-24-PHIAssertion.ll @@ -0,0 +1,13 @@ +; RUN: opt < %s -simplifycfg + +define i32 @test(i32 %A, i32 %B, i1 %cond) { +J: + %C = add i32 %A, 12 ; <i32> [#uses=3] + br i1 %cond, label %L, label %L +L: ; preds = %J, %J + %Q = phi i32 [ %C, %J ], [ %C, %J ] ; <i32> [#uses=1] + %D = add i32 %C, %B ; <i32> [#uses=1] + %E = add i32 %Q, %D ; <i32> [#uses=1] + ret i32 %E +} + diff --git a/test/Transforms/SimplifyCFG/2003-03-07-DominateProblem.ll b/test/Transforms/SimplifyCFG/2003-03-07-DominateProblem.ll new file mode 100644 index 0000000..8762046 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-03-07-DominateProblem.ll @@ -0,0 +1,17 @@ +; RUN: opt < %s -simplifycfg -disable-output + +define void @test(i32* %ldo, i1 %c, i1 %d) { +bb9: + br i1 %c, label %bb11, label %bb10 +bb10: ; preds = %bb9 + br label %bb11 +bb11: ; preds = %bb10, %bb9 + %reg330 = phi i32* [ null, %bb10 ], [ %ldo, %bb9 ] ; <i32*> [#uses=1] + br label %bb20 +bb20: ; preds = %bb20, %bb11 + store i32* %reg330, i32** null + br i1 %d, label %bb20, label %done +done: ; preds = %bb20 + ret void +} + diff --git a/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll new file mode 100644 index 0000000..c019931 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll @@ -0,0 +1,13 @@ +; Do not remove the invoke! +; +; RUN: opt < %s -simplifycfg -disable-output + +define i32 @test() { + %A = invoke i32 @test( ) + to label %Ret unwind label %Ret2 ; <i32> [#uses=1] +Ret: ; preds = %0 + ret i32 %A +Ret2: ; preds = %0 + ret i32 undef +} + diff --git a/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll b/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll new file mode 100644 index 0000000..15cd773 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll @@ -0,0 +1,12 @@ +; Do not remove the invoke! +; +; RUN: opt < %s -simplifycfg -S | grep invoke + +define i32 @test() { + invoke i32 @test( ) + to label %Ret unwind label %Ret ; <i32>:1 [#uses=0] +Ret: ; preds = %0, %0 + %A = add i32 0, 1 ; <i32> [#uses=1] + ret i32 %A +} + diff --git a/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll b/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll new file mode 100644 index 0000000..8ac9ae4 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll @@ -0,0 +1,22 @@ +; This test checks to make sure that 'br X, Dest, Dest' is folded into +; 'br Dest' + +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep {br i1 %c2} + +declare void @noop() + +define i32 @test(i1 %c1, i1 %c2) { + call void @noop( ) + br i1 %c1, label %A, label %Y +A: ; preds = %0 + call void @noop( ) + br i1 %c2, label %X, label %X +X: ; preds = %Y, %A, %A + call void @noop( ) + ret i32 0 +Y: ; preds = %0 + call void @noop( ) + br label %X +} + diff --git a/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll b/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll new file mode 100644 index 0000000..888e187 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll @@ -0,0 +1,26 @@ +; This test checks to make sure that 'br X, Dest, Dest' is folded into +; 'br Dest'. This can only happen after the 'Z' block is eliminated. This is +; due to the fact that the SimplifyCFG function does not use +; the ConstantFoldTerminator function. + +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep {br i1 %c2} + +declare void @noop() + +define i32 @test(i1 %c1, i1 %c2) { + call void @noop( ) + br i1 %c1, label %A, label %Y +A: ; preds = %0 + call void @noop( ) + br i1 %c2, label %Z, label %X +Z: ; preds = %A + br label %X +X: ; preds = %Y, %Z, %A + call void @noop( ) + ret i32 0 +Y: ; preds = %0 + call void @noop( ) + br label %X +} + diff --git a/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll new file mode 100644 index 0000000..af59ba0 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll @@ -0,0 +1,58 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep switch + + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" + +@.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +; Test folding all to same dest +define i32 @test3(i1 %C) { + br i1 %C, label %Start, label %TheDest +Start: ; preds = %0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + switch i32 3, label %TheDest [ + i32 0, label %TheDest + i32 1, label %TheDest + i32 2, label %TheDest + i32 5, label %TheDest + ] +TheDest: ; preds = %Start, %Start, %Start, %Start, %Start, %0 + ret i32 1234 +} + +; Test folding switch -> branch +define i32 @test4(i32 %C) { + switch i32 %C, label %L1 [ + i32 0, label %L2 + ] +L1: ; preds = %0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret i32 0 +L2: ; preds = %0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret i32 1 +} + +; Can fold into a cond branch! +define i32 @test5(i32 %C) { + switch i32 %C, label %L1 [ + i32 0, label %L2 + i32 123, label %L1 + ] +L1: ; preds = %0, %0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret i32 0 +L2: ; preds = %0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret i32 1 +} + diff --git a/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch.ll b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch.ll new file mode 100644 index 0000000..93f851c --- /dev/null +++ b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch.ll @@ -0,0 +1,80 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep switch + +; Test normal folding +define i32 @test1() { + switch i32 5, label %Default [ + i32 0, label %Foo + i32 1, label %Bar + i32 2, label %Baz + i32 5, label %TheDest + ] +Default: ; preds = %0 + ret i32 -1 +Foo: ; preds = %0 + ret i32 -2 +Bar: ; preds = %0 + ret i32 -3 +Baz: ; preds = %0 + ret i32 -4 +TheDest: ; preds = %0 + ret i32 1234 +} + +; Test folding to default dest +define i32 @test2() { + switch i32 3, label %Default [ + i32 0, label %Foo + i32 1, label %Bar + i32 2, label %Baz + i32 5, label %TheDest + ] +Default: ; preds = %0 + ret i32 1234 +Foo: ; preds = %0 + ret i32 -2 +Bar: ; preds = %0 + ret i32 -5 +Baz: ; preds = %0 + ret i32 -6 +TheDest: ; preds = %0 + ret i32 -8 +} + +; Test folding all to same dest +define i32 @test3(i1 %C) { + br i1 %C, label %Start, label %TheDest +Start: ; preds = %0 + switch i32 3, label %TheDest [ + i32 0, label %TheDest + i32 1, label %TheDest + i32 2, label %TheDest + i32 5, label %TheDest + ] +TheDest: ; preds = %Start, %Start, %Start, %Start, %Start, %0 + ret i32 1234 +} + +; Test folding switch -> branch +define i32 @test4(i32 %C) { + switch i32 %C, label %L1 [ + i32 0, label %L2 + ] +L1: ; preds = %0 + ret i32 0 +L2: ; preds = %0 + ret i32 1 +} + +; Can fold into a cond branch! +define i32 @test5(i32 %C) { + switch i32 %C, label %L1 [ + i32 0, label %L2 + i32 123, label %L1 + ] +L1: ; preds = %0, %0 + ret i32 0 +L2: ; preds = %0 + ret i32 1 +} + diff --git a/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll b/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll new file mode 100644 index 0000000..fafe73b --- /dev/null +++ b/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll @@ -0,0 +1,40 @@ +; RUN: opt < %s -simplifycfg -disable-output + +define void @symhash_add() { +entry: + br i1 undef, label %then.0, label %UnifiedReturnBlock +then.0: ; preds = %entry + br i1 undef, label %loopentry.2, label %loopentry.1.preheader +loopentry.1.preheader: ; preds = %then.0 + br label %loopentry.1.outer +loopentry.1.outer: ; preds = %loopexit.1, %loopentry.1.preheader + br label %loopentry.1 +loopentry.1: ; preds = %endif.1, %then.4, %then.3, %then.1, %loopentry.1.outer + br i1 undef, label %loopexit.1, label %no_exit.1 +no_exit.1: ; preds = %loopentry.1 + br i1 undef, label %then.1, label %else.0 +then.1: ; preds = %no_exit.1 + br label %loopentry.1 +else.0: ; preds = %no_exit.1 + br i1 undef, label %then.2, label %else.1 +then.2: ; preds = %else.0 + br i1 undef, label %then.3, label %endif.1 +then.3: ; preds = %then.2 + br label %loopentry.1 +else.1: ; preds = %else.0 + br i1 undef, label %endif.1, label %then.4 +then.4: ; preds = %else.1 + br label %loopentry.1 +endif.1: ; preds = %else.1, %then.2 + br label %loopentry.1 +loopexit.1: ; preds = %loopentry.1 + br i1 undef, label %loopentry.1.outer, label %loopentry.2 +loopentry.2: ; preds = %no_exit.2, %loopexit.1, %then.0 + br i1 undef, label %loopexit.2, label %no_exit.2 +no_exit.2: ; preds = %loopentry.2 + br label %loopentry.2 +loopexit.2: ; preds = %loopentry.2 + ret void +UnifiedReturnBlock: ; preds = %entry + ret void +} diff --git a/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll b/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll new file mode 100644 index 0000000..90be680 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll @@ -0,0 +1,95 @@ +; RUN: opt < %s -simplifycfg -disable-output +; PR584 +@g_38098584 = external global i32 ; <i32*> [#uses=1] +@g_60187400 = external global i32 ; <i32*> [#uses=1] +@g_59182229 = external global i32 ; <i32*> [#uses=2] + +define i32 @_Z13func_26556482h(i8 %l_88173906) { +entry: + %tmp.1 = bitcast i8 %l_88173906 to i8 ; <i8> [#uses=2] + %tmp.3 = icmp eq i8 %l_88173906, 0 ; <i1> [#uses=1] + br i1 %tmp.3, label %else.0, label %then.0 +then.0: ; preds = %entry + %tmp.5 = icmp eq i8 %l_88173906, 0 ; <i1> [#uses=1] + br i1 %tmp.5, label %else.1, label %then.1 +then.1: ; preds = %then.0 + br label %return +else.1: ; preds = %then.0 + br label %loopentry.0 +loopentry.0: ; preds = %no_exit.0, %else.1 + %i.0.1 = phi i32 [ 0, %else.1 ], [ %inc.0, %no_exit.0 ] ; <i32> [#uses=2] + %tmp.9 = icmp sgt i32 %i.0.1, 99 ; <i1> [#uses=1] + br i1 %tmp.9, label %endif.0, label %no_exit.0 +no_exit.0: ; preds = %loopentry.0 + %inc.0 = add i32 %i.0.1, 1 ; <i32> [#uses=1] + br label %loopentry.0 +else.0: ; preds = %entry + %tmp.12 = sext i8 %tmp.1 to i32 ; <i32> [#uses=1] + br label %return +endif.0: ; preds = %loopentry.0 + %tmp.14 = sext i8 %tmp.1 to i32 ; <i32> [#uses=1] + %tmp.16 = zext i8 %l_88173906 to i32 ; <i32> [#uses=1] + %tmp.17 = icmp sgt i32 %tmp.14, %tmp.16 ; <i1> [#uses=1] + %tmp.19 = load i32* @g_59182229 ; <i32> [#uses=2] + br i1 %tmp.17, label %cond_true, label %cond_false +cond_true: ; preds = %endif.0 + %tmp.20 = icmp ne i32 %tmp.19, 1 ; <i1> [#uses=1] + br label %cond_continue +cond_false: ; preds = %endif.0 + %tmp.22 = icmp ne i32 %tmp.19, 0 ; <i1> [#uses=1] + br label %cond_continue +cond_continue: ; preds = %cond_false, %cond_true + %mem_tmp.0 = phi i1 [ %tmp.20, %cond_true ], [ %tmp.22, %cond_false ] ; <i1> [#uses=1] + br i1 %mem_tmp.0, label %then.2, label %else.2 +then.2: ; preds = %cond_continue + %tmp.25 = zext i8 %l_88173906 to i32 ; <i32> [#uses=1] + br label %return +else.2: ; preds = %cond_continue + br label %loopentry.1 +loopentry.1: ; preds = %endif.3, %else.2 + %i.1.1 = phi i32 [ 0, %else.2 ], [ %inc.3, %endif.3 ] ; <i32> [#uses=2] + %i.3.2 = phi i32 [ undef, %else.2 ], [ %i.3.0, %endif.3 ] ; <i32> [#uses=2] + %l_88173906_addr.1 = phi i8 [ %l_88173906, %else.2 ], [ %l_88173906_addr.0, %endif.3 ] ; <i8> [#uses=3] + %tmp.29 = icmp sgt i32 %i.1.1, 99 ; <i1> [#uses=1] + br i1 %tmp.29, label %endif.2, label %no_exit.1 +no_exit.1: ; preds = %loopentry.1 + %tmp.30 = load i32* @g_38098584 ; <i32> [#uses=1] + %tmp.31 = icmp eq i32 %tmp.30, 0 ; <i1> [#uses=1] + br i1 %tmp.31, label %else.3, label %then.3 +then.3: ; preds = %no_exit.1 + br label %endif.3 +else.3: ; preds = %no_exit.1 + br i1 false, label %else.4, label %then.4 +then.4: ; preds = %else.3 + br label %endif.3 +else.4: ; preds = %else.3 + br i1 false, label %else.5, label %then.5 +then.5: ; preds = %else.4 + store i32 -1004318825, i32* @g_59182229 + br label %return +else.5: ; preds = %else.4 + br label %loopentry.3 +loopentry.3: ; preds = %then.7, %else.5 + %i.3.3 = phi i32 [ 0, %else.5 ], [ %inc.2, %then.7 ] ; <i32> [#uses=3] + %tmp.55 = icmp sgt i32 %i.3.3, 99 ; <i1> [#uses=1] + br i1 %tmp.55, label %endif.3, label %no_exit.3 +no_exit.3: ; preds = %loopentry.3 + %tmp.57 = icmp eq i8 %l_88173906_addr.1, 0 ; <i1> [#uses=1] + br i1 %tmp.57, label %else.7, label %then.7 +then.7: ; preds = %no_exit.3 + store i32 16239, i32* @g_60187400 + %inc.2 = add i32 %i.3.3, 1 ; <i32> [#uses=1] + br label %loopentry.3 +else.7: ; preds = %no_exit.3 + br label %return +endif.3: ; preds = %loopentry.3, %then.4, %then.3 + %i.3.0 = phi i32 [ %i.3.2, %then.3 ], [ %i.3.2, %then.4 ], [ %i.3.3, %loopentry.3 ] ; <i32> [#uses=1] + %l_88173906_addr.0 = phi i8 [ 100, %then.3 ], [ %l_88173906_addr.1, %then.4 ], [ %l_88173906_addr.1, %loopentry.3 ] ; <i8> [#uses=1] + %inc.3 = add i32 %i.1.1, 1 ; <i32> [#uses=1] + br label %loopentry.1 +endif.2: ; preds = %loopentry.1 + br label %return +return: ; preds = %endif.2, %else.7, %then.5, %then.2, %else.0, %then.1 + %result.0 = phi i32 [ 1624650671, %then.1 ], [ %tmp.25, %then.2 ], [ 3379, %then.5 ], [ 52410, %else.7 ], [ -1526438411, %endif.2 ], [ %tmp.12, %else.0 ] ; <i32> [#uses=1] + ret i32 %result.0 +} diff --git a/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll b/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll new file mode 100644 index 0000000..c30bfa1 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll @@ -0,0 +1,71 @@ +; RUN: opt < %s -simplifycfg -disable-output +; END. + +define void @main() { +entry: + %tmp.14.i19 = icmp eq i32 0, 2 ; <i1> [#uses=1] + br i1 %tmp.14.i19, label %endif.1.i20, label %read_min.exit +endif.1.i20: ; preds = %entry + %tmp.9.i.i = icmp eq i8* null, null ; <i1> [#uses=1] + br i1 %tmp.9.i.i, label %then.i12.i, label %then.i.i +then.i.i: ; preds = %endif.1.i20 + ret void +then.i12.i: ; preds = %endif.1.i20 + %tmp.9.i4.i = icmp eq i8* null, null ; <i1> [#uses=1] + br i1 %tmp.9.i4.i, label %endif.2.i33, label %then.i5.i +then.i5.i: ; preds = %then.i12.i + ret void +endif.2.i33: ; preds = %then.i12.i + br i1 false, label %loopexit.0.i40, label %no_exit.0.i35 +no_exit.0.i35: ; preds = %no_exit.0.i35, %endif.2.i33 + %tmp.130.i = icmp slt i32 0, 0 ; <i1> [#uses=1] + br i1 %tmp.130.i, label %loopexit.0.i40.loopexit, label %no_exit.0.i35 +loopexit.0.i40.loopexit: ; preds = %no_exit.0.i35 + br label %loopexit.0.i40 +loopexit.0.i40: ; preds = %loopexit.0.i40.loopexit, %endif.2.i33 + %tmp.341.i = icmp eq i32 0, 0 ; <i1> [#uses=1] + br i1 %tmp.341.i, label %loopentry.1.i, label %read_min.exit +loopentry.1.i: ; preds = %loopexit.0.i40 + %tmp.347.i = icmp sgt i32 0, 0 ; <i1> [#uses=1] + br i1 %tmp.347.i, label %no_exit.1.i41, label %loopexit.2.i44 +no_exit.1.i41: ; preds = %endif.5.i, %loopentry.1.i + %indvar.i42 = phi i32 [ %indvar.next.i, %endif.5.i ], [ 0, %loopentry.1.i ] ; <i32> [#uses=1] + %tmp.355.i = icmp eq i32 0, 3 ; <i1> [#uses=1] + br i1 %tmp.355.i, label %endif.5.i, label %read_min.exit +endif.5.i: ; preds = %no_exit.1.i41 + %tmp.34773.i = icmp sgt i32 0, 0 ; <i1> [#uses=1] + %indvar.next.i = add i32 %indvar.i42, 1 ; <i32> [#uses=1] + br i1 %tmp.34773.i, label %no_exit.1.i41, label %loopexit.1.i.loopexit +loopexit.1.i.loopexit: ; preds = %endif.5.i + ret void +loopexit.2.i44: ; preds = %loopentry.1.i + ret void +read_min.exit: ; preds = %no_exit.1.i41, %loopexit.0.i40, %entry + %tmp.23 = icmp eq i32 0, 0 ; <i1> [#uses=1] + br i1 %tmp.23, label %endif.1, label %then.1 +then.1: ; preds = %read_min.exit + br i1 false, label %endif.0.i, label %then.0.i +then.0.i: ; preds = %then.1 + br i1 false, label %endif.1.i, label %then.1.i +endif.0.i: ; preds = %then.1 + br i1 false, label %endif.1.i, label %then.1.i +then.1.i: ; preds = %endif.0.i, %then.0.i + br i1 false, label %getfree.exit, label %then.2.i +endif.1.i: ; preds = %endif.0.i, %then.0.i + br i1 false, label %getfree.exit, label %then.2.i +then.2.i: ; preds = %endif.1.i, %then.1.i + ret void +getfree.exit: ; preds = %endif.1.i, %then.1.i + ret void +endif.1: ; preds = %read_min.exit + %tmp.27.i = getelementptr i32* null, i32 0 ; <i32*> [#uses=0] + br i1 false, label %loopexit.0.i15, label %no_exit.0.i14 +no_exit.0.i14: ; preds = %endif.1 + ret void +loopexit.0.i15: ; preds = %endif.1 + br i1 false, label %primal_start_artificial.exit, label %no_exit.1.i16 +no_exit.1.i16: ; preds = %no_exit.1.i16, %loopexit.0.i15 + br i1 false, label %primal_start_artificial.exit, label %no_exit.1.i16 +primal_start_artificial.exit: ; preds = %no_exit.1.i16, %loopexit.0.i15 + ret void +} diff --git a/test/Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll b/test/Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll new file mode 100644 index 0000000..477c9c9 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll @@ -0,0 +1,75 @@ +; RUN: opt < %s -simplifycfg -disable-output +; END. + + %arraytype.1.Char = type { i32, [0 x i8] } + %arraytype.4.Signed = type { i32, [0 x i32] } + %functiontype.23 = type %structtype.Task* (%structtype.Task*, %structtype.Packet*, %structtype.FailedRun*) + %functiontype.27 = type %structtype.object* () + %functiontype.28 = type i1 (%structtype.object*, %structtype.object_vtable*) + %functiontype.39 = type i32 (%structtype.listiter*) + %opaquetype.RuntimeTypeInfo = type i8* (i8*) + %structtype.AssertionError_vtable = type { %structtype.FailedRun_vtable } + %structtype.DeviceTask = type { %structtype.Task } + %structtype.FailedRun = type { %structtype.object } + %structtype.FailedRun_vtable = type { %structtype.object_vtable } + %structtype.Packet = type { %structtype.object, %structtype.list.1*, i32, i32, i32, %structtype.Packet* } + %structtype.Task = type { %structtype.TaskState, %structtype.FailedRun*, i32, %structtype.Packet*, %structtype.Task*, i32 } + %structtype.TaskState = type { %structtype.object, i1, i1, i1 } + %structtype.list.1 = type { %arraytype.4.Signed* } + %structtype.listiter = type { %structtype.list.1*, i32 } + %structtype.object = type { %structtype.object_vtable* } + %structtype.object_vtable = type { %structtype.object_vtable*, %opaquetype.RuntimeTypeInfo*, %arraytype.1.Char*, %functiontype.27* } +@structinstance.59 = external global %structtype.AssertionError_vtable ; <%structtype.AssertionError_vtable*> [#uses=0] + +declare fastcc i1 @ll_isinstance__objectPtr_object_vtablePtr() + +declare fastcc void @ll_listnext__listiterPtr() + +define fastcc void @WorkTask.fn() { +block0: + br label %block1 +block1: ; preds = %block0 + %v2542 = call fastcc i1 @ll_isinstance__objectPtr_object_vtablePtr( ) ; <i1> [#uses=1] + br i1 %v2542, label %block4, label %block2 +block2: ; preds = %block1 + br label %block3 +block3: ; preds = %block2 + unwind +block4: ; preds = %block1 + br label %block5 +block5: ; preds = %block4 + %v2565 = icmp eq %structtype.Packet* null, null ; <i1> [#uses=1] + br i1 %v2565, label %block15, label %block6 +block6: ; preds = %block5 + %self_2575 = phi %structtype.DeviceTask* [ null, %block5 ] ; <%structtype.DeviceTask*> [#uses=1] + br i1 false, label %block14, label %block7 +block7: ; preds = %block14, %block6 + %self_2635 = phi %structtype.DeviceTask* [ %self_2575, %block6 ], [ null, %block14 ] ; <%structtype.DeviceTask*> [#uses=1] + %tmp.124 = getelementptr %structtype.Packet* null, i32 0, i32 2 ; <i32*> [#uses=0] + br label %block8 +block8: ; preds = %block10, %block7 + %self_2672 = phi %structtype.DeviceTask* [ %self_2635, %block7 ], [ null, %block10 ] ; <%structtype.DeviceTask*> [#uses=0] + invoke fastcc void @ll_listnext__listiterPtr( ) + to label %block9 unwind label %block8_exception_handling +block8_exception_handling: ; preds = %block8 + br i1 false, label %block8_exception_found_branchto_block12, label %block8_not_exception_structinstance.10 +block8_not_exception_structinstance.10: ; preds = %block8_exception_handling + unwind +block8_exception_found_branchto_block12: ; preds = %block8_exception_handling + br label %block12 +block9: ; preds = %block8 + br i1 false, label %block11, label %block10 +block10: ; preds = %block11, %block9 + br label %block8 +block11: ; preds = %block9 + br label %block10 +block12: ; preds = %block8_exception_found_branchto_block12 + br label %block13 +block13: ; preds = %block15, %block12 + ret void +block14: ; preds = %block6 + br label %block7 +block15: ; preds = %block5 + %v2586 = phi %structtype.DeviceTask* [ null, %block5 ] ; <%structtype.DeviceTask*> [#uses=0] + br label %block13 +} diff --git a/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll b/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll new file mode 100644 index 0000000..778aa3b --- /dev/null +++ b/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -simplifycfg -disable-output + +define i1 @foo() { + %X = invoke i1 @foo( ) + to label %N unwind label %F ; <i1> [#uses=1] +F: ; preds = %0 + ret i1 false +N: ; preds = %0 + br i1 %X, label %A, label %B +A: ; preds = %N + ret i1 true +B: ; preds = %N + ret i1 true +} + diff --git a/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll b/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll new file mode 100644 index 0000000..760aa13 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll @@ -0,0 +1,124 @@ +; Make sure this doesn't turn into an infinite loop + +; RUN: opt < %s -simplifycfg -constprop -simplifycfg |\ +; RUN: llvm-dis | grep bb86 +; END. + +%struct.anon = type { i32, i32, i32, i32, [1024 x i8] } +@_zero_ = external global %struct.anon* ; <%struct.anon**> [#uses=2] +@_one_ = external global %struct.anon* ; <%struct.anon**> [#uses=4] +@str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=0] + +declare i32 @bc_compare(%struct.anon*, %struct.anon*) + +declare void @free_num(%struct.anon**) + +declare %struct.anon* @copy_num(%struct.anon*) + +declare void @init_num(%struct.anon**) + +declare %struct.anon* @new_num(i32, i32) + +declare void @int2num(%struct.anon**, i32) + +declare void @bc_multiply(%struct.anon*, %struct.anon*, %struct.anon**, i32) + +declare void @bc_raise(%struct.anon*, %struct.anon*, %struct.anon**, i32) + +declare i32 @bc_divide(%struct.anon*, %struct.anon*, %struct.anon**, i32) + +declare void @bc_add(%struct.anon*, %struct.anon*, %struct.anon**) + +declare i32 @_do_compare(%struct.anon*, %struct.anon*, i32, i32) + +declare i32 @printf(i8*, ...) + +define i32 @bc_sqrt(%struct.anon** %num, i32 %scale) { +entry: + %guess = alloca %struct.anon* ; <%struct.anon**> [#uses=7] + %guess1 = alloca %struct.anon* ; <%struct.anon**> [#uses=7] + %point5 = alloca %struct.anon* ; <%struct.anon**> [#uses=3] + %tmp = load %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp1 = load %struct.anon** @_zero_ ; <%struct.anon*> [#uses=1] + %tmp.upgrd.1 = call i32 @bc_compare( %struct.anon* %tmp, %struct.anon* %tmp1 ) ; <i32> [#uses=2] + %tmp.upgrd.2 = icmp slt i32 %tmp.upgrd.1, 0 ; <i1> [#uses=1] + br i1 %tmp.upgrd.2, label %cond_true, label %cond_false +cond_true: ; preds = %entry + ret i32 0 +cond_false: ; preds = %entry + %tmp5 = icmp eq i32 %tmp.upgrd.1, 0 ; <i1> [#uses=1] + br i1 %tmp5, label %cond_true6, label %cond_next13 +cond_true6: ; preds = %cond_false + call void @free_num( %struct.anon** %num ) + %tmp8 = load %struct.anon** @_zero_ ; <%struct.anon*> [#uses=1] + %tmp9 = call %struct.anon* @copy_num( %struct.anon* %tmp8 ) ; <%struct.anon*> [#uses=1] + store %struct.anon* %tmp9, %struct.anon** %num + ret i32 1 +cond_next13: ; preds = %cond_false + %tmp15 = load %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp16 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp17 = call i32 @bc_compare( %struct.anon* %tmp15, %struct.anon* %tmp16 ) ; <i32> [#uses=2] + %tmp19 = icmp eq i32 %tmp17, 0 ; <i1> [#uses=1] + br i1 %tmp19, label %cond_true20, label %cond_next27 +cond_true20: ; preds = %cond_next13 + call void @free_num( %struct.anon** %num ) + %tmp22 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp23 = call %struct.anon* @copy_num( %struct.anon* %tmp22 ) ; <%struct.anon*> [#uses=1] + store %struct.anon* %tmp23, %struct.anon** %num + ret i32 1 +cond_next27: ; preds = %cond_next13 + %tmp29 = load %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp30 = getelementptr %struct.anon* %tmp29, i32 0, i32 2 ; <i32*> [#uses=1] + %tmp31 = load i32* %tmp30 ; <i32> [#uses=2] + %tmp33 = icmp sge i32 %tmp31, %scale ; <i1> [#uses=1] + %max = select i1 %tmp33, i32 %tmp31, i32 %scale ; <i32> [#uses=4] + %tmp35 = add i32 %max, 2 ; <i32> [#uses=0] + call void @init_num( %struct.anon** %guess ) + call void @init_num( %struct.anon** %guess1 ) + %tmp36 = call %struct.anon* @new_num( i32 1, i32 1 ) ; <%struct.anon*> [#uses=2] + store %struct.anon* %tmp36, %struct.anon** %point5 + %tmp.upgrd.3 = getelementptr %struct.anon* %tmp36, i32 0, i32 4, i32 1 ; <i8*> [#uses=1] + store i8 5, i8* %tmp.upgrd.3 + %tmp39 = icmp slt i32 %tmp17, 0 ; <i1> [#uses=1] + br i1 %tmp39, label %cond_true40, label %cond_false43 +cond_true40: ; preds = %cond_next27 + %tmp41 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp42 = call %struct.anon* @copy_num( %struct.anon* %tmp41 ) ; <%struct.anon*> [#uses=1] + store %struct.anon* %tmp42, %struct.anon** %guess + br label %bb80.outer +cond_false43: ; preds = %cond_next27 + call void @int2num( %struct.anon** %guess, i32 10 ) + %tmp45 = load %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp46 = getelementptr %struct.anon* %tmp45, i32 0, i32 1 ; <i32*> [#uses=1] + %tmp47 = load i32* %tmp46 ; <i32> [#uses=1] + call void @int2num( %struct.anon** %guess1, i32 %tmp47 ) + %tmp48 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] + %tmp49 = load %struct.anon** %point5 ; <%struct.anon*> [#uses=1] + call void @bc_multiply( %struct.anon* %tmp48, %struct.anon* %tmp49, %struct.anon** %guess1, i32 %max ) + %tmp51 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] + %tmp52 = getelementptr %struct.anon* %tmp51, i32 0, i32 2 ; <i32*> [#uses=1] + store i32 0, i32* %tmp52 + %tmp53 = load %struct.anon** %guess ; <%struct.anon*> [#uses=1] + %tmp54 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] + call void @bc_raise( %struct.anon* %tmp53, %struct.anon* %tmp54, %struct.anon** %guess, i32 %max ) + br label %bb80.outer +bb80.outer: ; preds = %cond_true83, %cond_false43, %cond_true40 + %done.1.ph = phi i32 [ 1, %cond_true83 ], [ 0, %cond_true40 ], [ 0, %cond_false43 ] ; <i32> [#uses=1] + br label %bb80 +bb80: ; preds = %cond_true83, %bb80.outer + %tmp82 = icmp eq i32 %done.1.ph, 0 ; <i1> [#uses=1] + br i1 %tmp82, label %cond_true83, label %bb86 +cond_true83: ; preds = %bb80 + %tmp71 = call i32 @_do_compare( %struct.anon* null, %struct.anon* null, i32 0, i32 1 ) ; <i32> [#uses=1] + %tmp76 = icmp eq i32 %tmp71, 0 ; <i1> [#uses=1] + br i1 %tmp76, label %bb80.outer, label %bb80 +bb86: ; preds = %bb80 + call void @free_num( %struct.anon** %num ) + %tmp88 = load %struct.anon** %guess ; <%struct.anon*> [#uses=1] + %tmp89 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp92 = call i32 @bc_divide( %struct.anon* %tmp88, %struct.anon* %tmp89, %struct.anon** %num, i32 %max ) ; <i32> [#uses=0] + call void @free_num( %struct.anon** %guess ) + call void @free_num( %struct.anon** %guess1 ) + call void @free_num( %struct.anon** %point5 ) + ret i32 1 +} diff --git a/test/Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll b/test/Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll new file mode 100644 index 0000000..32f49e6 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll @@ -0,0 +1,27 @@ +; RUN: opt < %s -simplifycfg -disable-output + +define void @polnel_() { +entry: + %tmp595 = icmp slt i32 0, 0 ; <i1> [#uses=4] + br i1 %tmp595, label %bb148.critedge, label %cond_true40 +bb36: ; preds = %bb43 + br i1 %tmp595, label %bb43, label %cond_true40 +cond_true40: ; preds = %bb46, %cond_true40, %bb36, %entry + %tmp397 = icmp sgt i32 0, 0 ; <i1> [#uses=1] + br i1 %tmp397, label %bb43, label %cond_true40 +bb43: ; preds = %cond_true40, %bb36 + br i1 false, label %bb53, label %bb36 +bb46: ; preds = %bb53 + br i1 %tmp595, label %bb53, label %cond_true40 +bb53: ; preds = %bb46, %bb43 + br i1 false, label %bb102, label %bb46 +bb92.preheader: ; preds = %bb102 + ret void +bb102: ; preds = %bb53 + br i1 %tmp595, label %bb148, label %bb92.preheader +bb148.critedge: ; preds = %entry + ret void +bb148: ; preds = %bb102 + ret void +} + diff --git a/test/Transforms/SimplifyCFG/2006-06-12-InfLoop.ll b/test/Transforms/SimplifyCFG/2006-06-12-InfLoop.ll new file mode 100644 index 0000000..21cfb26 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2006-06-12-InfLoop.ll @@ -0,0 +1,413 @@ +; RUN: opt < %s -simplifycfg -disable-output +; END. + +define void @main(i32 %c) { +entry: + %tmp.9 = icmp eq i32 %c, 2 ; <i1> [#uses=1] + br i1 %tmp.9, label %endif.0, label %then.0 +then.0: ; preds = %entry + ret void +endif.0: ; preds = %entry + br i1 false, label %then.1, label %endif.1 +then.1: ; preds = %endif.0 + ret void +endif.1: ; preds = %endif.0 + br i1 false, label %then.2, label %endif.2 +then.2: ; preds = %endif.1 + ret void +endif.2: ; preds = %endif.1 + br i1 false, label %then.3, label %loopentry.0 +then.3: ; preds = %endif.2 + ret void +loopentry.0: ; preds = %endif.2 + br i1 false, label %no_exit.0.preheader, label %loopexit.0 +no_exit.0.preheader: ; preds = %loopentry.0 + br label %no_exit.0 +no_exit.0: ; preds = %endif.4, %no_exit.0.preheader + br i1 false, label %then.4, label %endif.4 +then.4: ; preds = %no_exit.0 + ret void +endif.4: ; preds = %no_exit.0 + br i1 false, label %no_exit.0, label %loopexit.0.loopexit +loopexit.0.loopexit: ; preds = %endif.4 + br label %loopexit.0 +loopexit.0: ; preds = %loopexit.0.loopexit, %loopentry.0 + br i1 false, label %then.5, label %loopentry.1 +then.5: ; preds = %loopexit.0 + ret void +loopentry.1: ; preds = %loopexit.0 + %tmp.143 = icmp sgt i32 0, 0 ; <i1> [#uses=4] + br i1 %tmp.143, label %no_exit.1.preheader, label %loopexit.1 +no_exit.1.preheader: ; preds = %loopentry.1 + br label %no_exit.1 +no_exit.1: ; preds = %endif.6, %no_exit.1.preheader + br i1 false, label %then.6, label %shortcirc_next.3 +shortcirc_next.3: ; preds = %no_exit.1 + br i1 false, label %then.6, label %shortcirc_next.4 +shortcirc_next.4: ; preds = %shortcirc_next.3 + br i1 false, label %then.6, label %endif.6 +then.6: ; preds = %shortcirc_next.4, %shortcirc_next.3, %no_exit.1 + ret void +endif.6: ; preds = %shortcirc_next.4 + br i1 false, label %no_exit.1, label %loopexit.1.loopexit +loopexit.1.loopexit: ; preds = %endif.6 + br label %loopexit.1 +loopexit.1: ; preds = %loopexit.1.loopexit, %loopentry.1 + br i1 false, label %then.i, label %loopentry.0.i +then.i: ; preds = %loopexit.1 + ret void +loopentry.0.i: ; preds = %loopexit.1 + br i1 %tmp.143, label %no_exit.0.i.preheader, label %readvector.exit +no_exit.0.i.preheader: ; preds = %loopentry.0.i + br label %no_exit.0.i +no_exit.0.i: ; preds = %loopexit.1.i, %no_exit.0.i.preheader + br i1 false, label %no_exit.1.i.preheader, label %loopexit.1.i +no_exit.1.i.preheader: ; preds = %no_exit.0.i + br label %no_exit.1.i +no_exit.1.i: ; preds = %loopexit.2.i, %no_exit.1.i.preheader + br i1 false, label %no_exit.2.i.preheader, label %loopexit.2.i +no_exit.2.i.preheader: ; preds = %no_exit.1.i + br label %no_exit.2.i +no_exit.2.i: ; preds = %no_exit.2.i, %no_exit.2.i.preheader + br i1 false, label %no_exit.2.i, label %loopexit.2.i.loopexit +loopexit.2.i.loopexit: ; preds = %no_exit.2.i + br label %loopexit.2.i +loopexit.2.i: ; preds = %loopexit.2.i.loopexit, %no_exit.1.i + br i1 false, label %no_exit.1.i, label %loopexit.1.i.loopexit +loopexit.1.i.loopexit: ; preds = %loopexit.2.i + br label %loopexit.1.i +loopexit.1.i: ; preds = %loopexit.1.i.loopexit, %no_exit.0.i + br i1 false, label %no_exit.0.i, label %readvector.exit.loopexit +readvector.exit.loopexit: ; preds = %loopexit.1.i + br label %readvector.exit +readvector.exit: ; preds = %readvector.exit.loopexit, %loopentry.0.i + br i1 %tmp.143, label %loopentry.1.preheader.i, label %loopexit.0.i +loopentry.1.preheader.i: ; preds = %readvector.exit + br label %loopentry.1.outer.i +loopentry.1.outer.i: ; preds = %loopexit.1.i110, %loopentry.1.preheader.i + br label %loopentry.1.i85 +loopentry.1.i85.loopexit: ; preds = %hamming.exit16.i + br label %loopentry.1.i85 +loopentry.1.i85: ; preds = %loopentry.1.i85.loopexit, %loopentry.1.outer.i + br i1 false, label %no_exit.1.preheader.i, label %loopexit.1.i110.loopexit1 +no_exit.1.preheader.i: ; preds = %loopentry.1.i85 + br label %no_exit.1.i87 +no_exit.1.i87: ; preds = %then.1.i107, %no_exit.1.preheader.i + br i1 false, label %no_exit.i.i101.preheader, label %hamming.exit.i104 +no_exit.i.i101.preheader: ; preds = %no_exit.1.i87 + br label %no_exit.i.i101 +no_exit.i.i101: ; preds = %no_exit.i.i101, %no_exit.i.i101.preheader + br i1 false, label %no_exit.i.i101, label %hamming.exit.i104.loopexit +hamming.exit.i104.loopexit: ; preds = %no_exit.i.i101 + br label %hamming.exit.i104 +hamming.exit.i104: ; preds = %hamming.exit.i104.loopexit, %no_exit.1.i87 + br i1 false, label %no_exit.i15.i.preheader, label %hamming.exit16.i +no_exit.i15.i.preheader: ; preds = %hamming.exit.i104 + br label %no_exit.i15.i +no_exit.i15.i: ; preds = %no_exit.i15.i, %no_exit.i15.i.preheader + br i1 false, label %no_exit.i15.i, label %hamming.exit16.i.loopexit +hamming.exit16.i.loopexit: ; preds = %no_exit.i15.i + br label %hamming.exit16.i +hamming.exit16.i: ; preds = %hamming.exit16.i.loopexit, %hamming.exit.i104 + br i1 false, label %loopentry.1.i85.loopexit, label %then.1.i107 +then.1.i107: ; preds = %hamming.exit16.i + br i1 false, label %no_exit.1.i87, label %loopexit.1.i110.loopexit +loopexit.1.i110.loopexit: ; preds = %then.1.i107 + br label %loopexit.1.i110 +loopexit.1.i110.loopexit1: ; preds = %loopentry.1.i85 + br label %loopexit.1.i110 +loopexit.1.i110: ; preds = %loopexit.1.i110.loopexit1, %loopexit.1.i110.loopexit + br i1 false, label %loopentry.1.outer.i, label %loopexit.0.i.loopexit +loopexit.0.i.loopexit: ; preds = %loopexit.1.i110 + br label %loopexit.0.i +loopexit.0.i: ; preds = %loopexit.0.i.loopexit, %readvector.exit + br i1 false, label %UnifiedReturnBlock.i113, label %then.2.i112 +then.2.i112: ; preds = %loopexit.0.i + br label %checkham.exit +UnifiedReturnBlock.i113: ; preds = %loopexit.0.i + br label %checkham.exit +checkham.exit: ; preds = %UnifiedReturnBlock.i113, %then.2.i112 + br i1 false, label %loopentry.1.i14.preheader, label %loopentry.3.i.preheader +loopentry.1.i14.preheader: ; preds = %checkham.exit + br label %loopentry.1.i14 +loopentry.1.i14: ; preds = %loopexit.1.i18, %loopentry.1.i14.preheader + br i1 false, label %no_exit.1.i16.preheader, label %loopexit.1.i18 +no_exit.1.i16.preheader: ; preds = %loopentry.1.i14 + br label %no_exit.1.i16 +no_exit.1.i16: ; preds = %no_exit.1.i16, %no_exit.1.i16.preheader + br i1 false, label %no_exit.1.i16, label %loopexit.1.i18.loopexit +loopexit.1.i18.loopexit: ; preds = %no_exit.1.i16 + br label %loopexit.1.i18 +loopexit.1.i18: ; preds = %loopexit.1.i18.loopexit, %loopentry.1.i14 + br i1 false, label %loopentry.1.i14, label %loopentry.3.i.loopexit +loopentry.3.i.loopexit: ; preds = %loopexit.1.i18 + br label %loopentry.3.i.preheader +loopentry.3.i.preheader: ; preds = %loopentry.3.i.loopexit, %checkham.exit + br label %loopentry.3.i +loopentry.3.i: ; preds = %endif.1.i, %loopentry.3.i.preheader + br i1 false, label %loopentry.4.i.preheader, label %endif.1.i +loopentry.4.i.preheader: ; preds = %loopentry.3.i + br label %loopentry.4.i +loopentry.4.i: ; preds = %loopexit.4.i, %loopentry.4.i.preheader + br i1 false, label %no_exit.4.i.preheader, label %loopexit.4.i +no_exit.4.i.preheader: ; preds = %loopentry.4.i + br label %no_exit.4.i +no_exit.4.i: ; preds = %no_exit.4.i.backedge, %no_exit.4.i.preheader + br i1 false, label %endif.0.i, label %else.i +else.i: ; preds = %no_exit.4.i + br i1 false, label %no_exit.4.i.backedge, label %loopexit.4.i.loopexit +no_exit.4.i.backedge: ; preds = %endif.0.i, %else.i + br label %no_exit.4.i +endif.0.i: ; preds = %no_exit.4.i + br i1 false, label %no_exit.4.i.backedge, label %loopexit.4.i.loopexit +loopexit.4.i.loopexit: ; preds = %endif.0.i, %else.i + br label %loopexit.4.i +loopexit.4.i: ; preds = %loopexit.4.i.loopexit, %loopentry.4.i + br i1 false, label %loopentry.4.i, label %endif.1.i.loopexit +endif.1.i.loopexit: ; preds = %loopexit.4.i + br label %endif.1.i +endif.1.i: ; preds = %endif.1.i.loopexit, %loopentry.3.i + %exitcond = icmp eq i32 0, 10 ; <i1> [#uses=1] + br i1 %exitcond, label %generateT.exit, label %loopentry.3.i +generateT.exit: ; preds = %endif.1.i + br i1 false, label %then.0.i, label %loopentry.1.i30.preheader +then.0.i: ; preds = %generateT.exit + ret void +loopentry.1.i30.loopexit: ; preds = %loopexit.3.i + br label %loopentry.1.i30.backedge +loopentry.1.i30.preheader: ; preds = %generateT.exit + br label %loopentry.1.i30 +loopentry.1.i30: ; preds = %loopentry.1.i30.backedge, %loopentry.1.i30.preheader + br i1 %tmp.143, label %no_exit.0.i31.preheader, label %loopentry.1.i30.backedge +loopentry.1.i30.backedge: ; preds = %loopentry.1.i30, %loopentry.1.i30.loopexit + br label %loopentry.1.i30 +no_exit.0.i31.preheader: ; preds = %loopentry.1.i30 + br label %no_exit.0.i31 +no_exit.0.i31: ; preds = %loopexit.3.i, %no_exit.0.i31.preheader + br i1 false, label %then.1.i, label %else.0.i +then.1.i: ; preds = %no_exit.0.i31 + br i1 undef, label %then.0.i29, label %loopentry.0.i31 +then.0.i29: ; preds = %then.1.i + unreachable +loopentry.0.i31: ; preds = %then.1.i + br i1 false, label %no_exit.0.i38.preheader, label %loopentry.1.i.preheader +no_exit.0.i38.preheader: ; preds = %loopentry.0.i31 + br label %no_exit.0.i38 +no_exit.0.i38: ; preds = %no_exit.0.i38, %no_exit.0.i38.preheader + br i1 undef, label %no_exit.0.i38, label %loopentry.1.i.preheader.loopexit +loopentry.1.i.preheader.loopexit: ; preds = %no_exit.0.i38 + br label %loopentry.1.i.preheader +loopentry.1.i.preheader: ; preds = %loopentry.1.i.preheader.loopexit, %loopentry.0.i31 + br label %loopentry.1.i +loopentry.1.i: ; preds = %endif.2.i, %loopentry.1.i.preheader + br i1 undef, label %loopentry.2.i39.preheader, label %loopexit.1.i79.loopexit2 +loopentry.2.i39.preheader: ; preds = %loopentry.1.i + br label %loopentry.2.i39 +loopentry.2.i39: ; preds = %loopexit.5.i77, %loopentry.2.i39.preheader + br i1 false, label %loopentry.3.i40.preheader, label %hamming.exit.i71 +loopentry.3.i40.preheader: ; preds = %loopentry.2.i39 + br label %loopentry.3.i40 +loopentry.3.i40: ; preds = %loopexit.3.i51, %loopentry.3.i40.preheader + br i1 false, label %no_exit.3.preheader.i42, label %loopexit.3.i51 +no_exit.3.preheader.i42: ; preds = %loopentry.3.i40 + br label %no_exit.3.i49 +no_exit.3.i49: ; preds = %no_exit.3.i49, %no_exit.3.preheader.i42 + br i1 undef, label %no_exit.3.i49, label %loopexit.3.i51.loopexit +loopexit.3.i51.loopexit: ; preds = %no_exit.3.i49 + br label %loopexit.3.i51 +loopexit.3.i51: ; preds = %loopexit.3.i51.loopexit, %loopentry.3.i40 + br i1 undef, label %loopentry.3.i40, label %loopentry.4.i52 +loopentry.4.i52: ; preds = %loopexit.3.i51 + br i1 false, label %no_exit.4.i54.preheader, label %hamming.exit.i71 +no_exit.4.i54.preheader: ; preds = %loopentry.4.i52 + br label %no_exit.4.i54 +no_exit.4.i54: ; preds = %no_exit.4.backedge.i, %no_exit.4.i54.preheader + br i1 undef, label %then.1.i55, label %endif.1.i56 +then.1.i55: ; preds = %no_exit.4.i54 + br i1 undef, label %no_exit.4.backedge.i, label %loopexit.4.i57 +no_exit.4.backedge.i: ; preds = %endif.1.i56, %then.1.i55 + br label %no_exit.4.i54 +endif.1.i56: ; preds = %no_exit.4.i54 + br i1 undef, label %no_exit.4.backedge.i, label %loopexit.4.i57 +loopexit.4.i57: ; preds = %endif.1.i56, %then.1.i55 + br i1 false, label %no_exit.i.i69.preheader, label %hamming.exit.i71 +no_exit.i.i69.preheader: ; preds = %loopexit.4.i57 + br label %no_exit.i.i69 +no_exit.i.i69: ; preds = %no_exit.i.i69, %no_exit.i.i69.preheader + br i1 undef, label %no_exit.i.i69, label %hamming.exit.i71.loopexit +hamming.exit.i71.loopexit: ; preds = %no_exit.i.i69 + br label %hamming.exit.i71 +hamming.exit.i71: ; preds = %hamming.exit.i71.loopexit, %loopexit.4.i57, %loopentry.4.i52, %loopentry.2.i39 + br i1 undef, label %endif.2.i, label %loopentry.5.i72 +loopentry.5.i72: ; preds = %hamming.exit.i71 + br i1 false, label %shortcirc_next.i74.preheader, label %loopexit.5.i77 +shortcirc_next.i74.preheader: ; preds = %loopentry.5.i72 + br label %shortcirc_next.i74 +shortcirc_next.i74: ; preds = %no_exit.5.i76, %shortcirc_next.i74.preheader + br i1 undef, label %no_exit.5.i76, label %loopexit.5.i77.loopexit +no_exit.5.i76: ; preds = %shortcirc_next.i74 + br i1 undef, label %shortcirc_next.i74, label %loopexit.5.i77.loopexit +loopexit.5.i77.loopexit: ; preds = %no_exit.5.i76, %shortcirc_next.i74 + br label %loopexit.5.i77 +loopexit.5.i77: ; preds = %loopexit.5.i77.loopexit, %loopentry.5.i72 + br i1 undef, label %loopentry.2.i39, label %loopexit.1.i79.loopexit +endif.2.i: ; preds = %hamming.exit.i71 + br label %loopentry.1.i +loopexit.1.i79.loopexit: ; preds = %loopexit.5.i77 + br label %loopexit.1.i79 +loopexit.1.i79.loopexit2: ; preds = %loopentry.1.i + br label %loopexit.1.i79 +loopexit.1.i79: ; preds = %loopexit.1.i79.loopexit2, %loopexit.1.i79.loopexit + br i1 undef, label %then.3.i, label %loopentry.6.i80 +then.3.i: ; preds = %loopexit.1.i79 + br i1 false, label %no_exit.6.i82.preheader, label %run.exit +loopentry.6.i80: ; preds = %loopexit.1.i79 + br i1 false, label %no_exit.6.i82.preheader, label %run.exit +no_exit.6.i82.preheader: ; preds = %loopentry.6.i80, %then.3.i + br label %no_exit.6.i82 +no_exit.6.i82: ; preds = %no_exit.6.i82, %no_exit.6.i82.preheader + br i1 undef, label %no_exit.6.i82, label %run.exit.loopexit +run.exit.loopexit: ; preds = %no_exit.6.i82 + br label %run.exit +run.exit: ; preds = %run.exit.loopexit, %loopentry.6.i80, %then.3.i + br i1 false, label %no_exit.1.i36.preheader, label %loopentry.3.i37 +else.0.i: ; preds = %no_exit.0.i31 + br i1 false, label %then.0.i4, label %loopentry.0.i6 +then.0.i4: ; preds = %else.0.i + unreachable +loopentry.0.i6: ; preds = %else.0.i + br i1 false, label %no_exit.0.i8.preheader, label %loopentry.2.i.preheader +no_exit.0.i8.preheader: ; preds = %loopentry.0.i6 + br label %no_exit.0.i8 +no_exit.0.i8: ; preds = %no_exit.0.i8, %no_exit.0.i8.preheader + br i1 false, label %no_exit.0.i8, label %loopentry.2.i.preheader.loopexit +loopentry.2.i.preheader.loopexit: ; preds = %no_exit.0.i8 + br label %loopentry.2.i.preheader +loopentry.2.i.preheader: ; preds = %loopentry.2.i.preheader.loopexit, %loopentry.0.i6 + br label %loopentry.2.i +loopentry.2.i: ; preds = %endif.3.i19, %loopentry.2.i.preheader + br i1 false, label %loopentry.3.i10.preheader, label %loopentry.4.i15 +loopentry.3.i10.preheader: ; preds = %loopentry.2.i + br label %loopentry.3.i10 +loopentry.3.i10: ; preds = %loopexit.3.i14, %loopentry.3.i10.preheader + br i1 false, label %no_exit.3.preheader.i, label %loopexit.3.i14 +no_exit.3.preheader.i: ; preds = %loopentry.3.i10 + br label %no_exit.3.i12 +no_exit.3.i12: ; preds = %no_exit.3.i12, %no_exit.3.preheader.i + br i1 false, label %no_exit.3.i12, label %loopexit.3.i14.loopexit +loopexit.3.i14.loopexit: ; preds = %no_exit.3.i12 + br label %loopexit.3.i14 +loopexit.3.i14: ; preds = %loopexit.3.i14.loopexit, %loopentry.3.i10 + br i1 false, label %loopentry.3.i10, label %loopentry.4.i15.loopexit +loopentry.4.i15.loopexit: ; preds = %loopexit.3.i14 + br label %loopentry.4.i15 +loopentry.4.i15: ; preds = %loopentry.4.i15.loopexit, %loopentry.2.i + br i1 false, label %loopentry.5.outer.i.preheader, label %loopentry.7.i +loopentry.5.outer.i.preheader: ; preds = %loopentry.4.i15 + br label %loopentry.5.outer.i +loopentry.5.outer.i: ; preds = %loopexit.5.i, %loopentry.5.outer.i.preheader + br label %loopentry.5.i +loopentry.5.i: ; preds = %endif.1.i18, %loopentry.5.outer.i + br i1 false, label %no_exit.5.i.preheader, label %loopexit.5.i.loopexit3 +no_exit.5.i.preheader: ; preds = %loopentry.5.i + br label %no_exit.5.i +no_exit.5.i: ; preds = %then.2.i, %no_exit.5.i.preheader + br i1 false, label %loopentry.6.i, label %endif.1.i18 +loopentry.6.i: ; preds = %no_exit.5.i + br i1 false, label %no_exit.6.preheader.i, label %loopexit.6.i +no_exit.6.preheader.i: ; preds = %loopentry.6.i + br label %no_exit.6.i +no_exit.6.i: ; preds = %no_exit.6.i, %no_exit.6.preheader.i + br i1 false, label %no_exit.6.i, label %loopexit.6.i.loopexit +loopexit.6.i.loopexit: ; preds = %no_exit.6.i + br label %loopexit.6.i +loopexit.6.i: ; preds = %loopexit.6.i.loopexit, %loopentry.6.i + br i1 false, label %then.2.i, label %endif.1.i18 +then.2.i: ; preds = %loopexit.6.i + br i1 false, label %no_exit.5.i, label %loopexit.5.i.loopexit +endif.1.i18: ; preds = %loopexit.6.i, %no_exit.5.i + br label %loopentry.5.i +loopexit.5.i.loopexit: ; preds = %then.2.i + br label %loopexit.5.i +loopexit.5.i.loopexit3: ; preds = %loopentry.5.i + br label %loopexit.5.i +loopexit.5.i: ; preds = %loopexit.5.i.loopexit3, %loopexit.5.i.loopexit + br i1 false, label %loopentry.5.outer.i, label %loopentry.7.i.loopexit +loopentry.7.i.loopexit: ; preds = %loopexit.5.i + br label %loopentry.7.i +loopentry.7.i: ; preds = %loopentry.7.i.loopexit, %loopentry.4.i15 + br i1 false, label %no_exit.7.i.preheader, label %hamming.exit.i +no_exit.7.i.preheader: ; preds = %loopentry.7.i + br label %no_exit.7.i +no_exit.7.i: ; preds = %no_exit.7.i, %no_exit.7.i.preheader + br i1 false, label %no_exit.7.i, label %loopexit.7.i +loopexit.7.i: ; preds = %no_exit.7.i + br i1 false, label %no_exit.i.i.preheader, label %hamming.exit.i +no_exit.i.i.preheader: ; preds = %loopexit.7.i + br label %no_exit.i.i +no_exit.i.i: ; preds = %no_exit.i.i, %no_exit.i.i.preheader + br i1 false, label %no_exit.i.i, label %hamming.exit.i.loopexit +hamming.exit.i.loopexit: ; preds = %no_exit.i.i + br label %hamming.exit.i +hamming.exit.i: ; preds = %hamming.exit.i.loopexit, %loopexit.7.i, %loopentry.7.i + br i1 false, label %endif.3.i19, label %loopentry.8.i +loopentry.8.i: ; preds = %hamming.exit.i + br i1 false, label %shortcirc_next.i.preheader, label %loopexit.8.i +shortcirc_next.i.preheader: ; preds = %loopentry.8.i + br label %shortcirc_next.i +shortcirc_next.i: ; preds = %no_exit.8.i, %shortcirc_next.i.preheader + br i1 false, label %no_exit.8.i, label %loopexit.8.i.loopexit +no_exit.8.i: ; preds = %shortcirc_next.i + br i1 false, label %shortcirc_next.i, label %loopexit.8.i.loopexit +loopexit.8.i.loopexit: ; preds = %no_exit.8.i, %shortcirc_next.i + br label %loopexit.8.i +loopexit.8.i: ; preds = %loopexit.8.i.loopexit, %loopentry.8.i + br i1 false, label %no_exit.9.i.preheader, label %endif.3.i19 +no_exit.9.i.preheader: ; preds = %loopexit.8.i + br label %no_exit.9.i +no_exit.9.i: ; preds = %no_exit.9.i, %no_exit.9.i.preheader + br i1 false, label %no_exit.9.i, label %endif.3.i19.loopexit +endif.3.i19.loopexit: ; preds = %no_exit.9.i + br label %endif.3.i19 +endif.3.i19: ; preds = %endif.3.i19.loopexit, %loopexit.8.i, %hamming.exit.i + br i1 false, label %loopentry.2.i, label %loopexit.1.i20 +loopexit.1.i20: ; preds = %endif.3.i19 + br i1 false, label %then.4.i, label %UnifiedReturnBlock.i +then.4.i: ; preds = %loopexit.1.i20 + br label %runcont.exit +UnifiedReturnBlock.i: ; preds = %loopexit.1.i20 + br label %runcont.exit +runcont.exit: ; preds = %UnifiedReturnBlock.i, %then.4.i + br i1 false, label %no_exit.1.i36.preheader, label %loopentry.3.i37 +no_exit.1.i36.preheader: ; preds = %runcont.exit, %run.exit + br label %no_exit.1.i36 +no_exit.1.i36: ; preds = %no_exit.1.i36, %no_exit.1.i36.preheader + br i1 false, label %no_exit.1.i36, label %loopentry.3.i37.loopexit +loopentry.3.i37.loopexit: ; preds = %no_exit.1.i36 + br label %loopentry.3.i37 +loopentry.3.i37: ; preds = %loopentry.3.i37.loopexit, %runcont.exit, %run.exit + br i1 false, label %loopentry.4.i38.preheader, label %loopexit.3.i +loopentry.4.i38.preheader: ; preds = %loopentry.3.i37 + br label %loopentry.4.i38 +loopentry.4.i38: ; preds = %loopexit.4.i42, %loopentry.4.i38.preheader + br i1 false, label %no_exit.3.i.preheader, label %loopexit.4.i42 +no_exit.3.i.preheader: ; preds = %loopentry.4.i38 + br label %no_exit.3.i +no_exit.3.i: ; preds = %no_exit.3.i.backedge, %no_exit.3.i.preheader + br i1 false, label %endif.3.i, label %else.1.i +else.1.i: ; preds = %no_exit.3.i + br i1 false, label %no_exit.3.i.backedge, label %loopexit.4.i42.loopexit +no_exit.3.i.backedge: ; preds = %endif.3.i, %else.1.i + br label %no_exit.3.i +endif.3.i: ; preds = %no_exit.3.i + br i1 false, label %no_exit.3.i.backedge, label %loopexit.4.i42.loopexit +loopexit.4.i42.loopexit: ; preds = %endif.3.i, %else.1.i + br label %loopexit.4.i42 +loopexit.4.i42: ; preds = %loopexit.4.i42.loopexit, %loopentry.4.i38 + br i1 false, label %loopentry.4.i38, label %loopexit.3.i.loopexit +loopexit.3.i.loopexit: ; preds = %loopexit.4.i42 + br label %loopexit.3.i +loopexit.3.i: ; preds = %loopexit.3.i.loopexit, %loopentry.3.i37 + %tmp.13.i155 = icmp slt i32 0, 0 ; <i1> [#uses=1] + br i1 %tmp.13.i155, label %no_exit.0.i31, label %loopentry.1.i30.loopexit +} diff --git a/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll new file mode 100644 index 0000000..2c84c93 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll @@ -0,0 +1,98 @@ +; RUN: opt < %s -gvn -simplifycfg \ +; RUN: -disable-output +; PR867 +; END. + +target datalayout = "E-p:32:32" +target triple = "powerpc-apple-darwin8" + %struct.CUMULATIVE_ARGS = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + %struct.eh_status = type opaque + %struct.emit_status = type { i32, i32, %struct.rtx_def*, %struct.rtx_def*, %struct.sequence_stack*, i32, %struct.location_t, i32, i8*, %struct.rtx_def** } + %struct.expr_status = type { i32, i32, i32, %struct.rtx_def*, %struct.rtx_def*, %struct.rtx_def* } + %struct.function = type { %struct.eh_status*, %struct.expr_status*, %struct.emit_status*, %struct.varasm_status*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.function*, i32, i32, i32, i32, %struct.rtx_def*, %struct.CUMULATIVE_ARGS, %struct.rtx_def*, %struct.rtx_def*, %struct.initial_value_struct*, %struct.rtx_def*, %struct.rtx_def*, %struct.rtx_def*, %struct.rtx_def*, %struct.rtx_def*, %struct.rtx_def*, i8, i32, i64, %struct.tree_node*, %struct.tree_node*, %struct.rtx_def*, %struct.varray_head_tag*, %struct.temp_slot*, i32, %struct.var_refs_queue*, i32, i32, %struct.rtvec_def*, %struct.tree_node*, i32, i32, i32, %struct.machine_function*, i32, i32, i8, i8, %struct.language_function*, %struct.rtx_def*, i32, i32, i32, i32, %struct.location_t, %struct.varray_head_tag*, %struct.tree_node*, i8, i8, i8 } + %struct.initial_value_struct = type opaque + %struct.lang_decl = type opaque + %struct.lang_type = type opaque + %struct.language_function = type opaque + %struct.location_t = type { i8*, i32 } + %struct.machine_function = type { i32, i32, i8*, i32, i32 } + %struct.rtunion = type { i32 } + %struct.rtvec_def = type { i32, [1 x %struct.rtx_def*] } + %struct.rtx_def = type { i16, i8, i8, %struct.u } + %struct.sequence_stack = type { %struct.rtx_def*, %struct.rtx_def*, %struct.sequence_stack* } + %struct.temp_slot = type opaque + %struct.tree_common = type { %struct.tree_node*, %struct.tree_node*, %union.tree_ann_d*, i8, i8, i8, i8, i8 } + %struct.tree_decl = type { %struct.tree_common, %struct.location_t, i32, %struct.tree_node*, i8, i8, i8, i8, i8, i8, i8, i8, i32, %struct.tree_decl_u1, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.rtx_def*, %struct.tree_decl_u2, %struct.tree_node*, %struct.tree_node*, i64, %struct.lang_decl* } + %struct.tree_decl_u1 = type { i64 } + %struct.tree_decl_u2 = type { %struct.function* } + %struct.tree_node = type { %struct.tree_decl } + %struct.tree_type = type { %struct.tree_common, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, i32, i16, i8, i8, i32, %struct.tree_node*, %struct.tree_node*, %struct.rtunion, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, i64, %struct.lang_type* } + %struct.u = type { [1 x i64] } + %struct.var_refs_queue = type { %struct.rtx_def*, i32, i32, %struct.var_refs_queue* } + %struct.varasm_status = type opaque + %struct.varray_head_tag = type { i32, i32, i32, i8*, %struct.u } + %union.tree_ann_d = type opaque +@mode_class = external global [35 x i8] ; <[35 x i8]*> [#uses=3] + +define void @fold_builtin_classify() { +entry: + %tmp63 = load i32* null ; <i32> [#uses=1] + switch i32 %tmp63, label %bb276 [ + i32 414, label %bb145 + i32 417, label %bb + ] +bb: ; preds = %entry + ret void +bb145: ; preds = %entry + %tmp146 = load %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] + %tmp148 = getelementptr %struct.tree_node* %tmp146, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] + %tmp149 = load %struct.tree_node** %tmp148 ; <%struct.tree_node*> [#uses=1] + %tmp150 = bitcast %struct.tree_node* %tmp149 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1] + %tmp151 = getelementptr %struct.tree_type* %tmp150, i32 0, i32 6 ; <i16*> [#uses=1] + %tmp151.upgrd.1 = bitcast i16* %tmp151 to i32* ; <i32*> [#uses=1] + %tmp152 = load i32* %tmp151.upgrd.1 ; <i32> [#uses=1] + %tmp154 = lshr i32 %tmp152, 16 ; <i32> [#uses=1] + %tmp154.mask = and i32 %tmp154, 127 ; <i32> [#uses=1] + %gep.upgrd.2 = zext i32 %tmp154.mask to i64 ; <i64> [#uses=1] + %tmp155 = getelementptr [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.2 ; <i8*> [#uses=1] + %tmp156 = load i8* %tmp155 ; <i8> [#uses=1] + %tmp157 = icmp eq i8 %tmp156, 4 ; <i1> [#uses=1] + br i1 %tmp157, label %cond_next241, label %cond_true158 +cond_true158: ; preds = %bb145 + %tmp172 = load %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] + %tmp174 = getelementptr %struct.tree_node* %tmp172, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] + %tmp175 = load %struct.tree_node** %tmp174 ; <%struct.tree_node*> [#uses=1] + %tmp176 = bitcast %struct.tree_node* %tmp175 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1] + %tmp177 = getelementptr %struct.tree_type* %tmp176, i32 0, i32 6 ; <i16*> [#uses=1] + %tmp177.upgrd.3 = bitcast i16* %tmp177 to i32* ; <i32*> [#uses=1] + %tmp178 = load i32* %tmp177.upgrd.3 ; <i32> [#uses=1] + %tmp180 = lshr i32 %tmp178, 16 ; <i32> [#uses=1] + %tmp180.mask = and i32 %tmp180, 127 ; <i32> [#uses=1] + %gep.upgrd.4 = zext i32 %tmp180.mask to i64 ; <i64> [#uses=1] + %tmp181 = getelementptr [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.4 ; <i8*> [#uses=1] + %tmp182 = load i8* %tmp181 ; <i8> [#uses=1] + %tmp183 = icmp eq i8 %tmp182, 8 ; <i1> [#uses=1] + br i1 %tmp183, label %cond_next241, label %cond_true184 +cond_true184: ; preds = %cond_true158 + %tmp185 = load %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] + %tmp187 = getelementptr %struct.tree_node* %tmp185, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] + %tmp188 = load %struct.tree_node** %tmp187 ; <%struct.tree_node*> [#uses=1] + %tmp189 = bitcast %struct.tree_node* %tmp188 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1] + %tmp190 = getelementptr %struct.tree_type* %tmp189, i32 0, i32 6 ; <i16*> [#uses=1] + %tmp190.upgrd.5 = bitcast i16* %tmp190 to i32* ; <i32*> [#uses=1] + %tmp191 = load i32* %tmp190.upgrd.5 ; <i32> [#uses=1] + %tmp193 = lshr i32 %tmp191, 16 ; <i32> [#uses=1] + %tmp193.mask = and i32 %tmp193, 127 ; <i32> [#uses=1] + %gep.upgrd.6 = zext i32 %tmp193.mask to i64 ; <i64> [#uses=1] + %tmp194 = getelementptr [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.6 ; <i8*> [#uses=1] + %tmp195 = load i8* %tmp194 ; <i8> [#uses=1] + %tmp196 = icmp eq i8 %tmp195, 4 ; <i1> [#uses=1] + br i1 %tmp196, label %cond_next241, label %cond_true197 +cond_true197: ; preds = %cond_true184 + ret void +cond_next241: ; preds = %cond_true184, %cond_true158, %bb145 + %tmp245 = load i32* null ; <i32> [#uses=0] + ret void +bb276: ; preds = %entry + ret void +} diff --git a/test/Transforms/SimplifyCFG/2006-10-19-UncondDiv.ll b/test/Transforms/SimplifyCFG/2006-10-19-UncondDiv.ll new file mode 100644 index 0000000..009d1c8 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2006-10-19-UncondDiv.ll @@ -0,0 +1,28 @@ +; PR957 +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep select + +@G = extern_weak global i32 + +define i32 @test(i32 %tmp) { +cond_false179: + %tmp181 = icmp eq i32 %tmp, 0 ; <i1> [#uses=1] + br i1 %tmp181, label %cond_true182, label %cond_next185 +cond_true182: ; preds = %cond_false179 + br label %cond_next185 +cond_next185: ; preds = %cond_true182, %cond_false179 + %d0.3 = phi i32 [ udiv (i32 1, i32 ptrtoint (i32* @G to i32)), %cond_true182 ], [ %tmp, %cond_false179 ] ; <i32> [#uses=1] + ret i32 %d0.3 +} + +define i32 @test2(i32 %tmp) { +cond_false179: + %tmp181 = icmp eq i32 %tmp, 0 ; <i1> [#uses=1] + br i1 %tmp181, label %cond_true182, label %cond_next185 +cond_true182: ; preds = %cond_false179 + br label %cond_next185 +cond_next185: ; preds = %cond_true182, %cond_false179 + %d0.3 = phi i32 [ udiv (i32 1, i32 ptrtoint (i32* @G to i32)), %cond_true182 ], [ %tmp, %cond_false179 ] ; <i32> [#uses=1] + call i32 @test( i32 4 ) ; <i32>:0 [#uses=0] + ret i32 %d0.3 +} diff --git a/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll new file mode 100644 index 0000000..dba41c9 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll @@ -0,0 +1,555 @@ +; RUN: opt < %s -simplifycfg -disable-output +; END. + %struct..4._102 = type { %struct.QVectorData* } + %struct..5._125 = type { %struct.QMapData* } + %struct.QAbstractTextDocumentLayout = type { %struct.QObject } + %struct.QBasicAtomic = type { i32 } + %struct.QFont = type { %struct.QFontPrivate*, i32 } + %struct.QFontMetrics = type { %struct.QFontPrivate* } + %struct.QFontPrivate = type opaque + %"struct.QFragmentMap<QTextBlockData>" = type { %struct.QFragmentMapData } + %struct.QFragmentMapData = type { %"struct.QFragmentMapData::._154", i32 } + %"struct.QFragmentMapData::._154" = type { %"struct.QFragmentMapData::Header"* } + %"struct.QFragmentMapData::Header" = type { i32, i32, i32, i32, i32, i32, i32, i32 } + %"struct.QHash<uint,QHashDummyValue>" = type { %"struct.QHash<uint,QHashDummyValue>::._152" } + %"struct.QHash<uint,QHashDummyValue>::._152" = type { %struct.QHashData* } + %struct.QHashData = type { %"struct.QHashData::Node"*, %"struct.QHashData::Node"**, %struct.QBasicAtomic, i32, i32, i16, i16, i32, i8 } + %"struct.QHashData::Node" = type { %"struct.QHashData::Node"*, i32 } + %"struct.QList<QObject*>::._92" = type { %struct.QListData } + %"struct.QList<QPointer<QObject> >" = type { %"struct.QList<QObject*>::._92" } + %struct.QListData = type { %"struct.QListData::Data"* } + %"struct.QListData::Data" = type { %struct.QBasicAtomic, i32, i32, i32, i8, [1 x i8*] } + %"struct.QMap<QUrl,QVariant>" = type { %struct..5._125 } + %struct.QMapData = type { %"struct.QMapData::Node"*, [12 x %"struct.QMapData::Node"*], %struct.QBasicAtomic, i32, i32, i32, i8 } + %"struct.QMapData::Node" = type { %"struct.QMapData::Node"*, [1 x %"struct.QMapData::Node"*] } + %struct.QObject = type { i32 (...)**, %struct.QObjectData* } + %struct.QObjectData = type { i32 (...)**, %struct.QObject*, %struct.QObject*, %"struct.QList<QPointer<QObject> >", i8, [3 x i8], i32, i32 } + %struct.QObjectPrivate = type { %struct.QObjectData, i32, %struct.QObject*, %"struct.QList<QPointer<QObject> >", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %struct.QString } + %struct.QPaintDevice = type { i32 (...)**, i16 } + %struct.QPainter = type { %struct.QPainterPrivate* } + %struct.QPainterPrivate = type opaque + %struct.QPointF = type { double, double } + %struct.QPrinter = type { %struct.QPaintDevice, %struct.QPrinterPrivate* } + %struct.QPrinterPrivate = type opaque + %struct.QRectF = type { double, double, double, double } + %"struct.QSet<uint>" = type { %"struct.QHash<uint,QHashDummyValue>" } + %"struct.QSharedDataPointer<QTextFormatPrivate>" = type { %struct.QTextFormatPrivate* } + %struct.QString = type { %"struct.QString::Data"* } + %"struct.QString::Data" = type { %struct.QBasicAtomic, i32, i32, i16*, i8, i8, [1 x i16] } + %struct.QTextBlockFormat = type { %struct.QTextFormat } + %struct.QTextBlockGroup = type { %struct.QAbstractTextDocumentLayout } + %struct.QTextDocumentConfig = type { %struct.QString } + %struct.QTextDocumentPrivate = type { %struct.QObjectPrivate, %struct.QString, %"struct.QVector<QAbstractTextDocumentLayout::Selection>", i1, i32, i32, i1, i32, i32, i32, i32, i1, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, %"struct.QFragmentMap<QTextBlockData>", %"struct.QFragmentMap<QTextBlockData>", i32, %"struct.QList<QPointer<QObject> >", %"struct.QList<QPointer<QObject> >", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %struct.QTextDocumentConfig, i1, i1, %struct.QPointF } + %struct.QTextFormat = type { %"struct.QSharedDataPointer<QTextFormatPrivate>", i32 } + %struct.QTextFormatCollection = type { %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QSet<uint>", %struct.QFont } + %struct.QTextFormatPrivate = type opaque + %"struct.QVector<QAbstractTextDocumentLayout::Selection>" = type { %struct..4._102 } + %struct.QVectorData = type { %struct.QBasicAtomic, i32, i32, i8 } + +define void @_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) { +entry: + %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %tmp.upgrd.1 = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5] + %tmp2 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] + %tmp.upgrd.2 = alloca %struct.QFontMetrics, align 16 ; <%struct.QFontMetrics*> [#uses=4] + %tmp.upgrd.3 = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=4] + %tmp3 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %p = alloca %struct.QPainter, align 16 ; <%struct.QPainter*> [#uses=14] + %body = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=9] + %pageNumberPos = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=4] + %scaledPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=6] + %printerPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] + %fmt = alloca %struct.QTextBlockFormat, align 16 ; <%struct.QTextBlockFormat*> [#uses=5] + %font = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=5] + %tmp.upgrd.4 = call %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv( %struct.QAbstractTextDocumentLayout* %this ) ; <%struct.QTextDocumentPrivate*> [#uses=5] + %tmp.upgrd.5 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + call void @_ZN8QPainterC1EP12QPaintDevice( %struct.QPainter* %p, %struct.QPaintDevice* %tmp.upgrd.5 ) + %tmp.upgrd.6 = invoke i1 @_ZNK8QPainter8isActiveEv( %struct.QPainter* %p ) + to label %invcont unwind label %cleanup329 ; <i1> [#uses=1] +invcont: ; preds = %entry + br i1 %tmp.upgrd.6, label %cond_next, label %cleanup328 +cond_next: ; preds = %invcont + %tmp8 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) + to label %invcont7 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=0] +invcont7: ; preds = %cond_next + %tmp10 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp, double 0.000000e+00, double 0.000000e+00 ) + call void @_ZN6QRectFC1ERK7QPointFRK6QSizeF( %struct.QRectF* %body, %struct.QPointF* %tmp, %struct.QPointF* %tmp10 ) + call void @_ZN7QPointFC1Ev( %struct.QPointF* %pageNumberPos ) + %tmp12 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + %tmp13 = call i1 @_ZNK6QSizeF7isValidEv( %struct.QPointF* %tmp12 ) ; <i1> [#uses=1] + br i1 %tmp13, label %cond_next15, label %bb +cond_next15: ; preds = %invcont7 + %tmp17 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + %tmp.upgrd.7 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %tmp17 ) ; <double> [#uses=1] + %tmp18 = fcmp oeq double %tmp.upgrd.7, 0x41DFFFFFFFC00000 ; <i1> [#uses=1] + br i1 %tmp18, label %bb, label %cond_next20 +cond_next20: ; preds = %cond_next15 + br label %bb21 +bb: ; preds = %cond_next15, %invcont7 + br label %bb21 +bb21: ; preds = %bb, %cond_next20 + %iftmp.406.0 = phi i1 [ false, %bb ], [ true, %cond_next20 ] ; <i1> [#uses=1] + br i1 %iftmp.406.0, label %cond_true24, label %cond_false +cond_true24: ; preds = %bb21 + %tmp.upgrd.8 = invoke i32 @_Z13qt_defaultDpiv( ) + to label %invcont25 unwind label %cleanup329 ; <i32> [#uses=1] +invcont25: ; preds = %cond_true24 + %tmp26 = sitofp i32 %tmp.upgrd.8 to double ; <double> [#uses=2] + %tmp30 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) + to label %invcont29 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] +invcont29: ; preds = %invcont25 + %tmp32 = invoke %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv( %struct.QAbstractTextDocumentLayout* %tmp30 ) + to label %invcont31 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=3] +invcont31: ; preds = %invcont29 + %tmp34 = icmp eq %struct.QPaintDevice* %tmp32, null ; <i1> [#uses=1] + br i1 %tmp34, label %cond_next42, label %cond_true35 +cond_true35: ; preds = %invcont31 + %tmp38 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp32 ) + to label %invcont37 unwind label %cleanup329 ; <i32> [#uses=1] +invcont37: ; preds = %cond_true35 + %tmp38.upgrd.9 = sitofp i32 %tmp38 to double ; <double> [#uses=1] + %tmp41 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp32 ) + to label %invcont40 unwind label %cleanup329 ; <i32> [#uses=1] +invcont40: ; preds = %invcont37 + %tmp41.upgrd.10 = sitofp i32 %tmp41 to double ; <double> [#uses=1] + br label %cond_next42 +cond_next42: ; preds = %invcont40, %invcont31 + %sourceDpiY.2 = phi double [ %tmp41.upgrd.10, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] + %sourceDpiX.2 = phi double [ %tmp38.upgrd.9, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] + %tmp44 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp46 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp44 ) + to label %invcont45 unwind label %cleanup329 ; <i32> [#uses=1] +invcont45: ; preds = %cond_next42 + %tmp46.upgrd.11 = sitofp i32 %tmp46 to double ; <double> [#uses=1] + %tmp48 = fdiv double %tmp46.upgrd.11, %sourceDpiX.2 ; <double> [#uses=2] + %tmp50 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp52 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp50 ) + to label %invcont51 unwind label %cleanup329 ; <i32> [#uses=1] +invcont51: ; preds = %invcont45 + %tmp52.upgrd.12 = sitofp i32 %tmp52 to double ; <double> [#uses=1] + %tmp54 = fdiv double %tmp52.upgrd.12, %sourceDpiY.2 ; <double> [#uses=2] + invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp48, double %tmp54 ) + to label %invcont57 unwind label %cleanup329 +invcont57: ; preds = %invcont51 + %tmp.upgrd.13 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 0 ; <double*> [#uses=1] + %tmp60 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 0 ; <double*> [#uses=1] + %tmp61 = load double* %tmp60 ; <double> [#uses=1] + store double %tmp61, double* %tmp.upgrd.13 + %tmp62 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 1 ; <double*> [#uses=1] + %tmp63 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 1 ; <double*> [#uses=1] + %tmp64 = load double* %tmp63 ; <double> [#uses=1] + store double %tmp64, double* %tmp62 + %tmp65 = call double* @_ZN6QSizeF6rwidthEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] + %tmp67 = load double* %tmp65 ; <double> [#uses=1] + %tmp69 = fmul double %tmp67, %tmp48 ; <double> [#uses=1] + store double %tmp69, double* %tmp65 + %tmp71 = call double* @_ZN6QSizeF7rheightEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] + %tmp73 = load double* %tmp71 ; <double> [#uses=1] + %tmp75 = fmul double %tmp73, %tmp54 ; <double> [#uses=1] + store double %tmp75, double* %tmp71 + %tmp78 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp80 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 ) + to label %invcont79 unwind label %cleanup329 ; <i32> [#uses=1] +invcont79: ; preds = %invcont57 + %tmp82 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp84 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp82 ) + to label %invcont83 unwind label %cleanup329 ; <i32> [#uses=1] +invcont83: ; preds = %invcont79 + %tmp80.upgrd.14 = sitofp i32 %tmp80 to double ; <double> [#uses=1] + %tmp84.upgrd.15 = sitofp i32 %tmp84 to double ; <double> [#uses=1] + call void @_ZN6QSizeFC1Edd( %struct.QPointF* %printerPageSize, double %tmp84.upgrd.15, double %tmp80.upgrd.14 ) + %tmp85 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] + %tmp86 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] + %tmp87 = fdiv double %tmp85, %tmp86 ; <double> [#uses=1] + %tmp88 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] + %tmp89 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] + %tmp90 = fdiv double %tmp88, %tmp89 ; <double> [#uses=1] + invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp90, double %tmp87 ) + to label %cond_next194 unwind label %cleanup329 +cond_false: ; preds = %bb21 + %tmp.upgrd.16 = getelementptr %struct.QAbstractTextDocumentLayout* %this, i32 0, i32 0 ; <%struct.QObject*> [#uses=1] + %tmp95 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject( %struct.QAbstractTextDocumentLayout* %this, %struct.QObject* %tmp.upgrd.16 ) + to label %invcont94 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=9] +invcont94: ; preds = %cond_false + %tmp99 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont98 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] +invcont98: ; preds = %invcont94 + %tmp101 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont100 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] +invcont100: ; preds = %invcont98 + invoke void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice( %struct.QAbstractTextDocumentLayout* %tmp99, %struct.QPaintDevice* %tmp101 ) + to label %invcont103 unwind label %cleanup329 +invcont103: ; preds = %invcont100 + %tmp105 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont104 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] +invcont104: ; preds = %invcont103 + %tmp107 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp105 ) + to label %invcont106 unwind label %cleanup329 ; <i32> [#uses=1] +invcont106: ; preds = %invcont104 + %tmp108 = sitofp i32 %tmp107 to double ; <double> [#uses=1] + %tmp109 = fmul double %tmp108, 0x3FE93264C993264C ; <double> [#uses=1] + %tmp109.upgrd.17 = fptosi double %tmp109 to i32 ; <i32> [#uses=3] + %tmp.upgrd.18 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] + invoke void @_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* sret %fmt, %struct.QTextBlockGroup* %tmp.upgrd.18 ) + to label %invcont111 unwind label %cleanup329 +invcont111: ; preds = %invcont106 + %tmp112 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] + invoke void @_ZN16QTextFrameFormat9setMarginEd( %struct.QTextBlockFormat* %fmt, double %tmp112 ) + to label %invcont114 unwind label %cleanup192 +invcont114: ; preds = %invcont111 + %tmp116 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] + invoke void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat( %struct.QTextBlockGroup* %tmp116, %struct.QTextBlockFormat* %fmt ) + to label %invcont117 unwind label %cleanup192 +invcont117: ; preds = %invcont114 + %tmp119 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont118 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont118: ; preds = %invcont117 + %tmp121 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp119 ) + to label %invcont120 unwind label %cleanup192 ; <i32> [#uses=1] +invcont120: ; preds = %invcont118 + %tmp121.upgrd.19 = sitofp i32 %tmp121 to double ; <double> [#uses=1] + %tmp123 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont122 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont122: ; preds = %invcont120 + %tmp125 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp123 ) + to label %invcont124 unwind label %cleanup192 ; <i32> [#uses=1] +invcont124: ; preds = %invcont122 + %tmp125.upgrd.20 = sitofp i32 %tmp125 to double ; <double> [#uses=1] + call void @_ZN6QRectFC1Edddd( %struct.QRectF* %tmp.upgrd.1, double 0.000000e+00, double 0.000000e+00, double %tmp125.upgrd.20, double %tmp121.upgrd.19 ) + %tmp126 = getelementptr %struct.QRectF* %body, i32 0, i32 0 ; <double*> [#uses=1] + %tmp127 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 0 ; <double*> [#uses=1] + %tmp128 = load double* %tmp127 ; <double> [#uses=1] + store double %tmp128, double* %tmp126 + %tmp129 = getelementptr %struct.QRectF* %body, i32 0, i32 1 ; <double*> [#uses=1] + %tmp130 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 1 ; <double*> [#uses=1] + %tmp131 = load double* %tmp130 ; <double> [#uses=1] + store double %tmp131, double* %tmp129 + %tmp132 = getelementptr %struct.QRectF* %body, i32 0, i32 2 ; <double*> [#uses=1] + %tmp133 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 2 ; <double*> [#uses=1] + %tmp134 = load double* %tmp133 ; <double> [#uses=1] + store double %tmp134, double* %tmp132 + %tmp135 = getelementptr %struct.QRectF* %body, i32 0, i32 3 ; <double*> [#uses=1] + %tmp136 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 3 ; <double*> [#uses=1] + %tmp137 = load double* %tmp136 ; <double> [#uses=1] + store double %tmp137, double* %tmp135 + %tmp138 = call double @_ZNK6QRectF6heightEv( %struct.QRectF* %body ) ; <double> [#uses=1] + %tmp139 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] + %tmp140 = fsub double %tmp138, %tmp139 ; <double> [#uses=1] + %tmp142 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont141 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont141: ; preds = %invcont124 + invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %tmp.upgrd.3, %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont144 unwind label %cleanup192 +invcont144: ; preds = %invcont141 + invoke void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice( %struct.QFontMetrics* %tmp.upgrd.2, %struct.QFont* %tmp.upgrd.3, %struct.QPaintDevice* %tmp142 ) + to label %invcont146 unwind label %cleanup173 +invcont146: ; preds = %invcont144 + %tmp149 = invoke i32 @_ZNK12QFontMetrics6ascentEv( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %invcont148 unwind label %cleanup168 ; <i32> [#uses=1] +invcont148: ; preds = %invcont146 + %tmp149.upgrd.21 = sitofp i32 %tmp149 to double ; <double> [#uses=1] + %tmp150 = fadd double %tmp140, %tmp149.upgrd.21 ; <double> [#uses=1] + %tmp152 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont151 unwind label %cleanup168 ; <%struct.QPaintDevice*> [#uses=1] +invcont151: ; preds = %invcont148 + %tmp154 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp152 ) + to label %invcont153 unwind label %cleanup168 ; <i32> [#uses=1] +invcont153: ; preds = %invcont151 + %tmp155 = mul i32 %tmp154, 5 ; <i32> [#uses=1] + %tmp156 = sdiv i32 %tmp155, 72 ; <i32> [#uses=1] + %tmp156.upgrd.22 = sitofp i32 %tmp156 to double ; <double> [#uses=1] + %tmp157 = fadd double %tmp150, %tmp156.upgrd.22 ; <double> [#uses=1] + %tmp158 = call double @_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; <double> [#uses=1] + %tmp159 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] + %tmp160 = fsub double %tmp158, %tmp159 ; <double> [#uses=1] + call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp2, double %tmp160, double %tmp157 ) + %tmp161 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 0 ; <double*> [#uses=1] + %tmp162 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 0 ; <double*> [#uses=1] + %tmp163 = load double* %tmp162 ; <double> [#uses=1] + store double %tmp163, double* %tmp161 + %tmp164 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 1 ; <double*> [#uses=1] + %tmp165 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 1 ; <double*> [#uses=1] + %tmp166 = load double* %tmp165 ; <double> [#uses=1] + store double %tmp166, double* %tmp164 + invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %cleanup171 unwind label %cleanup173 +cleanup168: ; preds = %invcont151, %invcont148, %invcont146 + invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %cleanup173 unwind label %cleanup173 +cleanup171: ; preds = %invcont153 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) + to label %finally170 unwind label %cleanup192 +cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) + to label %cleanup192 unwind label %cleanup192 +finally170: ; preds = %cleanup171 + invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %font, %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont177 unwind label %cleanup192 +invcont177: ; preds = %finally170 + invoke void @_ZN5QFont12setPointSizeEi( %struct.QFont* %font, i32 10 ) + to label %invcont179 unwind label %cleanup187 +invcont179: ; preds = %invcont177 + invoke void @_ZN13QTextDocument14setDefaultFontERK5QFont( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QFont* %font ) + to label %invcont181 unwind label %cleanup187 +invcont181: ; preds = %invcont179 + call void @_ZNK6QRectF4sizeEv( %struct.QPointF* sret %tmp3, %struct.QRectF* %body ) + invoke void @_ZN13QTextDocument11setPageSizeERK6QSizeF( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QPointF* %tmp3 ) + to label %cleanup185 unwind label %cleanup187 +cleanup185: ; preds = %invcont181 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) + to label %cleanup190 unwind label %cleanup192 +cleanup187: ; preds = %invcont181, %invcont179, %invcont177 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) + to label %cleanup192 unwind label %cleanup192 +cleanup190: ; preds = %cleanup185 + invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) + to label %cond_next194 unwind label %cleanup329 +cleanup192: ; preds = %cleanup187, %cleanup187, %cleanup185, %finally170, %cleanup173, %cleanup173, %cleanup171, %invcont141, %invcont124, %invcont122, %invcont120, %invcont118, %invcont117, %invcont114, %invcont111 + invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) + to label %cleanup329 unwind label %cleanup329 +cond_next194: ; preds = %cleanup190, %invcont83 + %clonedDoc.1 = phi %struct.QAbstractTextDocumentLayout* [ null, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=3] + %doc.1 = phi %struct.QAbstractTextDocumentLayout* [ %this, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=2] + %tmp197 = invoke i1 @_ZNK8QPrinter13collateCopiesEv( %struct.QPrinter* %printer ) + to label %invcont196 unwind label %cleanup329 ; <i1> [#uses=1] +invcont196: ; preds = %cond_next194 + br i1 %tmp197, label %cond_true200, label %cond_false204 +cond_true200: ; preds = %invcont196 + %tmp203 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) + to label %invcont202 unwind label %cleanup329 ; <i32> [#uses=1] +invcont202: ; preds = %cond_true200 + br label %cond_next208 +cond_false204: ; preds = %invcont196 + %tmp207 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) + to label %invcont206 unwind label %cleanup329 ; <i32> [#uses=1] +invcont206: ; preds = %cond_false204 + br label %cond_next208 +cond_next208: ; preds = %invcont206, %invcont202 + %pageCopies.0 = phi i32 [ %tmp203, %invcont202 ], [ 1, %invcont206 ] ; <i32> [#uses=2] + %docCopies.0 = phi i32 [ 1, %invcont202 ], [ %tmp207, %invcont206 ] ; <i32> [#uses=2] + %tmp211 = invoke i32 @_ZNK8QPrinter8fromPageEv( %struct.QPrinter* %printer ) + to label %invcont210 unwind label %cleanup329 ; <i32> [#uses=3] +invcont210: ; preds = %cond_next208 + %tmp214 = invoke i32 @_ZNK8QPrinter6toPageEv( %struct.QPrinter* %printer ) + to label %invcont213 unwind label %cleanup329 ; <i32> [#uses=3] +invcont213: ; preds = %invcont210 + %tmp216 = icmp eq i32 %tmp211, 0 ; <i1> [#uses=1] + br i1 %tmp216, label %cond_true217, label %cond_next225 +cond_true217: ; preds = %invcont213 + %tmp219 = icmp eq i32 %tmp214, 0 ; <i1> [#uses=1] + br i1 %tmp219, label %cond_true220, label %cond_next225 +cond_true220: ; preds = %cond_true217 + %tmp223 = invoke i32 @_ZNK13QTextDocument9pageCountEv( %struct.QAbstractTextDocumentLayout* %doc.1 ) + to label %invcont222 unwind label %cleanup329 ; <i32> [#uses=1] +invcont222: ; preds = %cond_true220 + br label %cond_next225 +cond_next225: ; preds = %invcont222, %cond_true217, %invcont213 + %toPage.1 = phi i32 [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; <i32> [#uses=2] + %fromPage.1 = phi i32 [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; <i32> [#uses=2] + %tmp.page = invoke i32 @_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer ) + to label %invcont227 unwind label %cleanup329 ; <i32> [#uses=1] +invcont227: ; preds = %cond_next225 + %tmp228 = icmp eq i32 %tmp.page, 1 ; <i1> [#uses=1] + br i1 %tmp228, label %cond_true230, label %cond_next234 +cond_true230: ; preds = %invcont227 + br label %cond_next234 +cond_next234: ; preds = %cond_true230, %invcont227 + %ascending.1 = phi i1 [ false, %cond_true230 ], [ true, %invcont227 ] ; <i1> [#uses=1] + %toPage.2 = phi i32 [ %fromPage.1, %cond_true230 ], [ %toPage.1, %invcont227 ] ; <i32> [#uses=1] + %fromPage.2 = phi i32 [ %toPage.1, %cond_true230 ], [ %fromPage.1, %invcont227 ] ; <i32> [#uses=1] + br label %bb309 +bb237: ; preds = %cond_true313, %cond_next293 + %iftmp.410.4 = phi i1 [ %iftmp.410.5, %cond_true313 ], [ %iftmp.410.1, %cond_next293 ] ; <i1> [#uses=1] + %page.4 = phi i32 [ %fromPage.2, %cond_true313 ], [ %page.3, %cond_next293 ] ; <i32> [#uses=4] + br label %bb273 +invcont240: ; preds = %cond_true277 + %tmp242 = icmp eq i32 %tmp241, 2 ; <i1> [#uses=1] + br i1 %tmp242, label %bb252, label %cond_next244 +cond_next244: ; preds = %invcont240 + %tmp247 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) + to label %invcont246 unwind label %cleanup329 ; <i32> [#uses=1] +invcont246: ; preds = %cond_next244 + %tmp248 = icmp eq i32 %tmp247, 3 ; <i1> [#uses=1] + br i1 %tmp248, label %bb252, label %bb253 +bb252: ; preds = %invcont246, %invcont240 + br label %bb254 +bb253: ; preds = %invcont246 + br label %bb254 +bb254: ; preds = %bb253, %bb252 + %iftmp.410.0 = phi i1 [ true, %bb252 ], [ false, %bb253 ] ; <i1> [#uses=2] + br i1 %iftmp.410.0, label %UserCanceled, label %cond_next258 +cond_next258: ; preds = %bb254 + invoke fastcc void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF( i32 %page.4, %struct.QPainter* %p, %struct.QAbstractTextDocumentLayout* %doc.1, %struct.QRectF* %body, %struct.QPointF* %pageNumberPos ) + to label %invcont261 unwind label %cleanup329 +invcont261: ; preds = %cond_next258 + %tmp263 = add i32 %pageCopies.0, -1 ; <i32> [#uses=1] + %tmp265 = icmp sgt i32 %tmp263, %j.4 ; <i1> [#uses=1] + br i1 %tmp265, label %cond_true266, label %cond_next270 +cond_true266: ; preds = %invcont261 + %tmp269 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %cond_next270 unwind label %cleanup329 ; <i1> [#uses=0] +cond_next270: ; preds = %cond_true266, %invcont261 + %tmp272 = add i32 %j.4, 1 ; <i32> [#uses=1] + br label %bb273 +bb273: ; preds = %cond_next270, %bb237 + %iftmp.410.1 = phi i1 [ %iftmp.410.4, %bb237 ], [ %iftmp.410.0, %cond_next270 ] ; <i1> [#uses=2] + %j.4 = phi i32 [ 0, %bb237 ], [ %tmp272, %cond_next270 ] ; <i32> [#uses=3] + %tmp276 = icmp slt i32 %j.4, %pageCopies.0 ; <i1> [#uses=1] + br i1 %tmp276, label %cond_true277, label %bb280 +cond_true277: ; preds = %bb273 + %tmp241 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) + to label %invcont240 unwind label %cleanup329 ; <i32> [#uses=1] +bb280: ; preds = %bb273 + %tmp283 = icmp eq i32 %page.4, %toPage.2 ; <i1> [#uses=1] + br i1 %tmp283, label %bb297, label %cond_next285 +cond_next285: ; preds = %bb280 + br i1 %ascending.1, label %cond_true287, label %cond_false290 +cond_true287: ; preds = %cond_next285 + %tmp289 = add i32 %page.4, 1 ; <i32> [#uses=1] + br label %cond_next293 +cond_false290: ; preds = %cond_next285 + %tmp292 = add i32 %page.4, -1 ; <i32> [#uses=1] + br label %cond_next293 +cond_next293: ; preds = %cond_false290, %cond_true287 + %page.3 = phi i32 [ %tmp289, %cond_true287 ], [ %tmp292, %cond_false290 ] ; <i32> [#uses=1] + %tmp296 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %bb237 unwind label %cleanup329 ; <i1> [#uses=0] +bb297: ; preds = %bb280 + %tmp299 = add i32 %docCopies.0, -1 ; <i32> [#uses=1] + %tmp301 = icmp sgt i32 %tmp299, %i.1 ; <i1> [#uses=1] + br i1 %tmp301, label %cond_true302, label %cond_next306 +cond_true302: ; preds = %bb297 + %tmp305 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %cond_next306 unwind label %cleanup329 ; <i1> [#uses=0] +cond_next306: ; preds = %cond_true302, %bb297 + %tmp308 = add i32 %i.1, 1 ; <i32> [#uses=1] + br label %bb309 +bb309: ; preds = %cond_next306, %cond_next234 + %iftmp.410.5 = phi i1 [ undef, %cond_next234 ], [ %iftmp.410.1, %cond_next306 ] ; <i1> [#uses=1] + %i.1 = phi i32 [ 0, %cond_next234 ], [ %tmp308, %cond_next306 ] ; <i32> [#uses=3] + %tmp312 = icmp slt i32 %i.1, %docCopies.0 ; <i1> [#uses=1] + br i1 %tmp312, label %cond_true313, label %UserCanceled +cond_true313: ; preds = %bb309 + br label %bb237 +UserCanceled: ; preds = %bb309, %bb254 + %tmp318 = icmp eq %struct.QAbstractTextDocumentLayout* %clonedDoc.1, null ; <i1> [#uses=1] + br i1 %tmp318, label %cleanup327, label %cond_true319 +cond_true319: ; preds = %UserCanceled + %tmp.upgrd.23 = getelementptr %struct.QAbstractTextDocumentLayout* %clonedDoc.1, i32 0, i32 0, i32 0 ; <i32 (...)***> [#uses=1] + %tmp.upgrd.24 = load i32 (...)*** %tmp.upgrd.23 ; <i32 (...)**> [#uses=1] + %tmp322 = getelementptr i32 (...)** %tmp.upgrd.24, i32 4 ; <i32 (...)**> [#uses=1] + %tmp.upgrd.25 = load i32 (...)** %tmp322 ; <i32 (...)*> [#uses=1] + %tmp.upgrd.26 = bitcast i32 (...)* %tmp.upgrd.25 to void (%struct.QAbstractTextDocumentLayout*)* ; <void (%struct.QAbstractTextDocumentLayout*)*> [#uses=1] + invoke void %tmp.upgrd.26( %struct.QAbstractTextDocumentLayout* %clonedDoc.1 ) + to label %cleanup327 unwind label %cleanup329 +cleanup327: ; preds = %cond_true319, %UserCanceled + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + ret void +cleanup328: ; preds = %invcont + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + ret void +cleanup329: ; preds = %cond_true319, %cond_true302, %cond_next293, %cond_true277, %cond_true266, %cond_next258, %cond_next244, %cond_next225, %cond_true220, %invcont210, %cond_next208, %cond_false204, %cond_true200, %cond_next194, %cleanup192, %cleanup192, %cleanup190, %invcont106, %invcont104, %invcont103, %invcont100, %invcont98, %invcont94, %cond_false, %invcont83, %invcont79, %invcont57, %invcont51, %invcont45, %cond_next42, %invcont37, %cond_true35, %invcont29, %invcont25, %cond_true24, %cond_next, %entry + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + unwind +} + +declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) + +declare i1 @_ZNK6QSizeF7isValidEv(%struct.QPointF*) + +declare double @_ZNK6QSizeF5widthEv(%struct.QPointF*) + +declare double @_ZNK6QSizeF6heightEv(%struct.QPointF*) + +declare double* @_ZN6QSizeF6rwidthEv(%struct.QPointF*) + +declare double* @_ZN6QSizeF7rheightEv(%struct.QPointF*) + +declare %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZN7QPointFC1Ev(%struct.QPointF*) + +declare void @_ZN7QPointFC1Edd(%struct.QPointF*, double, double) + +declare void @_ZN16QTextFrameFormat9setMarginEd(%struct.QTextBlockFormat*, double) + +declare void @_ZN6QRectFC1Edddd(%struct.QRectF*, double, double, double, double) + +declare void @_ZN6QRectFC1ERK7QPointFRK6QSizeF(%struct.QRectF*, %struct.QPointF*, %struct.QPointF*) + +declare double @_ZNK6QRectF5widthEv(%struct.QRectF*) + +declare double @_ZNK6QRectF6heightEv(%struct.QRectF*) + +declare void @_ZNK6QRectF4sizeEv(%struct.QPointF*, %struct.QRectF*) + +declare void @_ZN16QTextFrameFormatD1Ev(%struct.QTextBlockFormat*) + +declare void @_ZNK10QTextFrame11frameFormatEv(%struct.QTextBlockFormat*, %struct.QTextBlockGroup*) + +declare void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat(%struct.QTextBlockGroup*, %struct.QTextBlockFormat*) + +declare i32 @_ZNK12QPaintDevice5widthEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice6heightEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice11logicalDpiXEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice11logicalDpiYEv(%struct.QPaintDevice*) + +declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject(%struct.QAbstractTextDocumentLayout*, %struct.QObject*) + +declare void @_ZN5QFontD1Ev(%struct.QFont*) + +declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv(%struct.QAbstractTextDocumentLayout*) + +declare %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv(%struct.QAbstractTextDocumentLayout*) + +declare i32 @_ZNK13QTextDocument9pageCountEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZNK13QTextDocument11defaultFontEv(%struct.QFont*, %struct.QAbstractTextDocumentLayout*) + +declare void @_ZN13QTextDocument14setDefaultFontERK5QFont(%struct.QAbstractTextDocumentLayout*, %struct.QFont*) + +declare void @_ZN13QTextDocument11setPageSizeERK6QSizeF(%struct.QAbstractTextDocumentLayout*, %struct.QPointF*) + +declare void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF(i32, %struct.QPainter*, %struct.QAbstractTextDocumentLayout*, %struct.QRectF*, %struct.QPointF*) + +declare void @_ZN12QFontMetricsD1Ev(%struct.QFontMetrics*) + +declare void @_ZN8QPainterC1EP12QPaintDevice(%struct.QPainter*, %struct.QPaintDevice*) + +declare i1 @_ZNK8QPainter8isActiveEv(%struct.QPainter*) + +declare i32 @_Z13qt_defaultDpiv() + +declare %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZN8QPainter5scaleEdd(%struct.QPainter*, double, double) + +declare %struct.QPaintDevice* @_ZNK8QPainter6deviceEv(%struct.QPainter*) + +declare void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice(%struct.QAbstractTextDocumentLayout*, %struct.QPaintDevice*) + +declare void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice(%struct.QFontMetrics*, %struct.QFont*, %struct.QPaintDevice*) + +declare i32 @_ZNK12QFontMetrics6ascentEv(%struct.QFontMetrics*) + +declare void @_ZN5QFont12setPointSizeEi(%struct.QFont*, i32) + +declare i1 @_ZNK8QPrinter13collateCopiesEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter9numCopiesEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter8fromPageEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter6toPageEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter9pageOrderEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) + +declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) + +declare void @_ZN8QPainterD1Ev(%struct.QPainter*) diff --git a/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll b/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll new file mode 100644 index 0000000..af865ce --- /dev/null +++ b/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll @@ -0,0 +1,131 @@ +; RUN: opt < %s -simplifycfg | llvm-dis +; END. + +; ModuleID = '2006-12-08-Ptr-ICmp-Branch.ll' +target datalayout = "e-p:32:32" +target triple = "i686-pc-linux-gnu" + %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] } + %struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] } + %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 } + %struct.charsequence = type { i8*, i32, i32 } + %struct.trie_s = type { [26 x %struct.trie_s*], i32 } +@str = external global [14 x i8] ; <[14 x i8]*> [#uses=0] +@str.upgrd.1 = external global [32 x i8] ; <[32 x i8]*> [#uses=0] +@str.upgrd.2 = external global [12 x i8] ; <[12 x i8]*> [#uses=0] +@C.0.2294 = external global %struct.charsequence ; <%struct.charsequence*> [#uses=3] +@t = external global %struct.trie_s* ; <%struct.trie_s**> [#uses=0] +@str.upgrd.3 = external global [3 x i8] ; <[3 x i8]*> [#uses=0] +@str.upgrd.4 = external global [26 x i8] ; <[26 x i8]*> [#uses=0] + +declare void @charsequence_reset(%struct.charsequence*) + +declare void @free(i8*) + +declare void @charsequence_push(%struct.charsequence*, i8) + +declare i8* @charsequence_val(%struct.charsequence*) + +declare i32 @_IO_getc(%struct.FILE*) + +declare i32 @tolower(i32) + +declare %struct.trie_s* @trie_insert(%struct.trie_s*, i8*) + +declare i32 @feof(%struct.FILE*) + +define void @addfile(%struct.trie_s* %t, %struct.FILE* %f) { +entry: + %t_addr = alloca %struct.trie_s* ; <%struct.trie_s**> [#uses=2] + %f_addr = alloca %struct.FILE* ; <%struct.FILE**> [#uses=3] + %c = alloca i8, align 1 ; <i8*> [#uses=7] + %wstate = alloca i32, align 4 ; <i32*> [#uses=4] + %cs = alloca %struct.charsequence, align 16 ; <%struct.charsequence*> [#uses=7] + %str = alloca i8*, align 4 ; <i8**> [#uses=3] + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + store %struct.trie_s* %t, %struct.trie_s** %t_addr + store %struct.FILE* %f, %struct.FILE** %f_addr + store i32 0, i32* %wstate + %tmp = getelementptr %struct.charsequence* %cs, i64 0, i32 0 ; <i8**> [#uses=1] + %tmp1 = getelementptr %struct.charsequence* @C.0.2294, i64 0, i32 0 ; <i8**> [#uses=1] + %tmp.upgrd.5 = load i8** %tmp1 ; <i8*> [#uses=1] + store i8* %tmp.upgrd.5, i8** %tmp + %tmp.upgrd.6 = getelementptr %struct.charsequence* %cs, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp2 = getelementptr %struct.charsequence* @C.0.2294, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp.upgrd.7 = load i32* %tmp2 ; <i32> [#uses=1] + store i32 %tmp.upgrd.7, i32* %tmp.upgrd.6 + %tmp3 = getelementptr %struct.charsequence* %cs, i64 0, i32 2 ; <i32*> [#uses=1] + %tmp4 = getelementptr %struct.charsequence* @C.0.2294, i64 0, i32 2 ; <i32*> [#uses=1] + %tmp5 = load i32* %tmp4 ; <i32> [#uses=1] + store i32 %tmp5, i32* %tmp3 + br label %bb33 +bb: ; preds = %bb33 + %tmp.upgrd.8 = load %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1] + %tmp.upgrd.9 = call i32 @_IO_getc( %struct.FILE* %tmp.upgrd.8 ) ; <i32> [#uses=1] + %tmp6 = call i32 @tolower( i32 %tmp.upgrd.9 ) ; <i32> [#uses=1] + %tmp6.upgrd.10 = trunc i32 %tmp6 to i8 ; <i8> [#uses=1] + store i8 %tmp6.upgrd.10, i8* %c + %tmp7 = load i32* %wstate ; <i32> [#uses=1] + %tmp.upgrd.11 = icmp ne i32 %tmp7, 0 ; <i1> [#uses=1] + br i1 %tmp.upgrd.11, label %cond_true, label %cond_false +cond_true: ; preds = %bb + %tmp.upgrd.12 = load i8* %c ; <i8> [#uses=1] + %tmp8 = icmp sle i8 %tmp.upgrd.12, 96 ; <i1> [#uses=1] + br i1 %tmp8, label %cond_true9, label %cond_next +cond_true9: ; preds = %cond_true + br label %bb16 +cond_next: ; preds = %cond_true + %tmp10 = load i8* %c ; <i8> [#uses=1] + %tmp11 = icmp sgt i8 %tmp10, 122 ; <i1> [#uses=1] + br i1 %tmp11, label %cond_true12, label %cond_next13 +cond_true12: ; preds = %cond_next + br label %bb16 +cond_next13: ; preds = %cond_next + %tmp14 = load i8* %c ; <i8> [#uses=1] + %tmp14.upgrd.13 = sext i8 %tmp14 to i32 ; <i32> [#uses=1] + %tmp1415 = trunc i32 %tmp14.upgrd.13 to i8 ; <i8> [#uses=1] + call void @charsequence_push( %struct.charsequence* %cs, i8 %tmp1415 ) + br label %bb21 +bb16: ; preds = %cond_true12, %cond_true9 + %tmp17 = call i8* @charsequence_val( %struct.charsequence* %cs ) ; <i8*> [#uses=1] + store i8* %tmp17, i8** %str + %tmp.upgrd.14 = load %struct.trie_s** %t_addr ; <%struct.trie_s*> [#uses=1] + %tmp18 = load i8** %str ; <i8*> [#uses=1] + %tmp19 = call %struct.trie_s* @trie_insert( %struct.trie_s* %tmp.upgrd.14, i8* %tmp18 ) ; <%struct.trie_s*> [#uses=0] + %tmp20 = load i8** %str ; <i8*> [#uses=1] + call void @free( i8* %tmp20 ) + store i32 0, i32* %wstate + br label %bb21 +bb21: ; preds = %bb16, %cond_next13 + br label %cond_next32 +cond_false: ; preds = %bb + %tmp22 = load i8* %c ; <i8> [#uses=1] + %tmp23 = icmp sgt i8 %tmp22, 96 ; <i1> [#uses=1] + br i1 %tmp23, label %cond_true24, label %cond_next31 +cond_true24: ; preds = %cond_false + %tmp25 = load i8* %c ; <i8> [#uses=1] + %tmp26 = icmp sle i8 %tmp25, 122 ; <i1> [#uses=1] + br i1 %tmp26, label %cond_true27, label %cond_next30 +cond_true27: ; preds = %cond_true24 + call void @charsequence_reset( %struct.charsequence* %cs ) + %tmp28 = load i8* %c ; <i8> [#uses=1] + %tmp28.upgrd.15 = sext i8 %tmp28 to i32 ; <i32> [#uses=1] + %tmp2829 = trunc i32 %tmp28.upgrd.15 to i8 ; <i8> [#uses=1] + call void @charsequence_push( %struct.charsequence* %cs, i8 %tmp2829 ) + store i32 1, i32* %wstate + br label %cond_next30 +cond_next30: ; preds = %cond_true27, %cond_true24 + br label %cond_next31 +cond_next31: ; preds = %cond_next30, %cond_false + br label %cond_next32 +cond_next32: ; preds = %cond_next31, %bb21 + br label %bb33 +bb33: ; preds = %cond_next32, %entry + %tmp34 = load %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1] + %tmp35 = call i32 @feof( %struct.FILE* %tmp34 ) ; <i32> [#uses=1] + %tmp36 = icmp eq i32 %tmp35, 0 ; <i1> [#uses=1] + br i1 %tmp36, label %bb, label %bb37 +bb37: ; preds = %bb33 + br label %return +return: ; preds = %bb37 + ret void +} diff --git a/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll b/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll new file mode 100644 index 0000000..a20c46e --- /dev/null +++ b/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll @@ -0,0 +1,14 @@ +; RUN: opt < %s -simplifycfg -S | not grep invoke + +declare i32 @func(i8*) nounwind + +define i32 @test() { + invoke i32 @func( i8* null ) + to label %Cont unwind label %Other ; <i32>:1 [#uses=0] + +Cont: ; preds = %0 + ret i32 0 + +Other: ; preds = %0 + ret i32 1 +} diff --git a/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll b/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll new file mode 100644 index 0000000..46df0f0 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll @@ -0,0 +1,37 @@ +;RUN: opt < %s -simplifycfg -disable-output +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" + +define i32 @bork() nounwind { +entry: + br label %bb5.outer + +bb5.outer.loopexit: ; preds = %bb5 + br label %bb5.outer + +bb5.outer: ; preds = %bb5.outer.loopexit, %entry + %undo.0.ph = phi i32 [ 0, %entry ], [ 1, %bb5.outer.loopexit ] ; <i32> [#uses=1] + br label %bb5 + +bb5: ; preds = %bb5, %bb5.outer + %tmp6 = tail call i32 (...)* @foo( ) nounwind ; <i32> [#uses=1] + switch i32 %tmp6, label %bb13 [ + i32 -1, label %bb10 + i32 102, label %bb5 + i32 110, label %bb5.outer.loopexit + ] + +bb10: ; preds = %bb5 + %tmp12 = tail call i32 (...)* @bar( i32 %undo.0.ph ) nounwind ; <i32> [#uses=0] + br label %UnifiedReturnBlock + +bb13: ; preds = %bb5 + br label %UnifiedReturnBlock + +UnifiedReturnBlock: ; preds = %bb13, %bb10 + %UnifiedRetVal = phi i32 [ 1, %bb10 ], [ 258, %bb13 ] ; <i32> [#uses=1] + ret i32 %UnifiedRetVal +} + +declare i32 @foo(...) + +declare i32 @bar(...) diff --git a/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll b/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll new file mode 100644 index 0000000..00f2d5b --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll @@ -0,0 +1,26 @@ +; The phi should not be eliminated in this case, because the fp op could trap. +; RUN: opt < %s -simplifycfg -S | grep {= phi double} + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" +@G = weak global double 0.000000e+00, align 8 ; <double*> [#uses=2] + +define void @test(i32 %X, i32 %Y, double %Z) { +entry: + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + %tmp = load double* @G, align 8 ; <double> [#uses=2] + %tmp3 = icmp eq i32 %X, %Y ; <i1> [#uses=1] + %tmp34 = zext i1 %tmp3 to i8 ; <i8> [#uses=1] + %toBool = icmp ne i8 %tmp34, 0 ; <i1> [#uses=1] + br i1 %toBool, label %cond_true, label %cond_next + +cond_true: ; preds = %entry + %tmp7 = fadd double %tmp, %Z ; <double> [#uses=1] + br label %cond_next + +cond_next: ; preds = %cond_true, %entry + %F.0 = phi double [ %tmp, %entry ], [ %tmp7, %cond_true ] ; <double> [#uses=1] + store double %F.0, double* @G, align 8 + ret void +} + diff --git a/test/Transforms/SimplifyCFG/2008-04-23-MergeMultipleResultRet.ll b/test/Transforms/SimplifyCFG/2008-04-23-MergeMultipleResultRet.ll new file mode 100644 index 0000000..8e05a3c --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-04-23-MergeMultipleResultRet.ll @@ -0,0 +1,43 @@ +; RUN: opt < %s -simplifycfg -disable-output +; rdar://5882392 +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" +target triple = "x86_64-apple-darwin9" + %struct.Py_complex = type { double, double } + +define %struct.Py_complex @_Py_c_pow(double %a.0, double %a.1, double %b.0, double %b.1) nounwind { +entry: + %tmp7 = fcmp une double %b.0, 0.000000e+00 ; <i1> [#uses=1] + %tmp11 = fcmp une double %b.1, 0.000000e+00 ; <i1> [#uses=1] + %bothcond = or i1 %tmp7, %tmp11 ; <i1> [#uses=1] + br i1 %bothcond, label %bb15, label %bb53 + +bb15: ; preds = %entry + %tmp18 = fcmp une double %a.0, 0.000000e+00 ; <i1> [#uses=1] + %tmp24 = fcmp une double %a.1, 0.000000e+00 ; <i1> [#uses=1] + %bothcond1 = or i1 %tmp18, %tmp24 ; <i1> [#uses=1] + br i1 %bothcond1, label %bb29, label %bb27 + +bb27: ; preds = %bb15 + %tmp28 = call i32* @__error( ) nounwind ; <i32*> [#uses=1] + store i32 33, i32* %tmp28, align 4 + ret double undef, double undef + +bb29: ; preds = %bb15 + %tmp36 = fcmp une double %b.1, 0.000000e+00 ; <i1> [#uses=1] + br i1 %tmp36, label %bb39, label %bb47 + +bb39: ; preds = %bb29 + br label %bb47 + +bb47: ; preds = %bb39, %bb29 + ret double undef, double undef + +bb53: ; preds = %entry + ret double undef, double undef +} + +declare i32* @__error() + +declare double @pow(double, double) nounwind readonly + +declare double @cos(double) nounwind readonly diff --git a/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll b/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll new file mode 100644 index 0000000..ba33d84 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll @@ -0,0 +1,30 @@ +; RUN: opt < %s -simplifycfg -disable-output +; PR2256 +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" +target triple = "x86_64-mingw32" + +define { x86_fp80, x86_fp80 } @catanl({ x86_fp80, x86_fp80 }* byval %Z, i1 %cond) nounwind { +bb: ; preds = %entry + br i1 %cond, label %bb48, label %bb40 + +bb40: ; preds = %bb + store i32 34, i32* null, align 4 + br label %bb196 + +bb48: ; preds = %bb.bb48_crit_edge, %entry.bb48_crit_edge + %tmp53 = icmp eq i32 0, 1280 ; <i1> [#uses=1] + br i1 %tmp53, label %bb56, label %bb174 + +bb56: ; preds = %bb48 + %iftmp.0.0 = select i1 false, x86_fp80 0xK3FFFC90FDAA22168C235, x86_fp80 0xKBFFFC90FDAA22168C235 ; <x86_fp80> [#uses=0] + br label %bb196 + + +bb174: ; preds = %bb144, %bb114 + %tmp191 = fmul x86_fp80 0xK00000000000000000000, 0xK3FFE8000000000000000 ; <x86_fp80> [#uses=1] + br label %bb196 + +bb196: ; preds = %bb174, %bb56, %bb40 + %Res.1.0 = phi x86_fp80 [ 0xK7FFF8000000000000000, %bb40 ], [ %tmp191, %bb174 ], [ 0xK00000000000000000000, %bb56 ] ; <x86_fp80> [#uses=1] + ret x86_fp80 0xK00000000000000000000, x86_fp80 %Res.1.0 +} diff --git a/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll b/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll new file mode 100644 index 0000000..59e886b --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll @@ -0,0 +1,131 @@ +; RUN: opt < %s -simplifycfg -S > %t +; RUN: not grep {^BB.tomerge} %t +; RUN grep {^BB.nomerge} %t | count 2 + +; ModuleID = '<stdin>' +declare i1 @foo() + +declare i1 @bar(i32) + +; This function can't be merged +define void @a() { +entry: + br label %BB.nomerge + +BB.nomerge: ; preds = %Common, %entry + ; This phi has a conflicting value (0) with below phi (2), so blocks + ; can't be merged. + %a = phi i32 [ 1, %entry ], [ 0, %Common ] ; <i32> [#uses=1] + br label %Succ + +Succ: ; preds = %Common, %BB.nomerge + %b = phi i32 [ %a, %BB.nomerge ], [ 2, %Common ] ; <i32> [#uses=0] + %conde = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %conde, label %Common, label %Exit + +Common: ; preds = %Succ + %cond = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %cond, label %BB.nomerge, label %Succ + +Exit: ; preds = %Succ + ret void +} + +; This function can't be merged +define void @b() { +entry: + br label %BB.nomerge + +BB.nomerge: ; preds = %Common, %entry + br label %Succ + +Succ: ; preds = %Common, %BB.nomerge + ; This phi has confliction values for Common and (through BB) Common, + ; blocks can't be merged + %b = phi i32 [ 1, %BB.nomerge ], [ 2, %Common ] ; <i32> [#uses=0] + %conde = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %conde, label %Common, label %Exit + +Common: ; preds = %Succ + %cond = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %cond, label %BB.nomerge, label %Succ + +Exit: ; preds = %Succ + ret void +} + +; This function can be merged +define void @c() { +entry: + br label %BB.tomerge + +BB.tomerge: ; preds = %Common, %entry + br label %Succ + +Succ: ; preds = %Common, %BB.tomerge, %Pre-Exit + ; This phi has identical values for Common and (through BB) Common, + ; blocks can't be merged + %b = phi i32 [ 1, %BB.tomerge ], [ 1, %Common ], [ 2, %Pre-Exit ] + %conde = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %conde, label %Common, label %Pre-Exit + +Common: ; preds = %Succ + %cond = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %cond, label %BB.tomerge, label %Succ + +Pre-Exit: ; preds = %Succ + ; This adds a backedge, so the %b phi node gets a third branch and is + ; not completely trivial + %cond2 = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %cond2, label %Succ, label %Exit + +Exit: ; preds = %Pre-Exit + ret void +} + +; This function can be merged +define void @d() { +entry: + br label %BB.tomerge + +BB.tomerge: ; preds = %Common, %entry + ; This phi has a matching value (0) with below phi (0), so blocks + ; can be merged. + %a = phi i32 [ 1, %entry ], [ 0, %Common ] ; <i32> [#uses=1] + br label %Succ + +Succ: ; preds = %Common, %BB.tomerge + %b = phi i32 [ %a, %BB.tomerge ], [ 0, %Common ] ; <i32> [#uses=0] + %conde = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %conde, label %Common, label %Exit + +Common: ; preds = %Succ + %cond = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %cond, label %BB.tomerge, label %Succ + +Exit: ; preds = %Succ + ret void +} + +; This function can be merged +define void @e() { +entry: + br label %BB.tomerge + +BB.tomerge: ; preds = %Use, %entry + ; This phi is used somewhere else than Succ, but this should not prevent + ; merging this block + %a = phi i32 [ 1, %entry ], [ 0, %Use ] ; <i32> [#uses=1] + br label %Succ + +Succ: ; preds = %BB.tomerge + %conde = call i1 @foo( ) ; <i1> [#uses=1] + br i1 %conde, label %Use, label %Exit + +Use: ; preds = %Succ + %cond = call i1 @bar( i32 %a ) ; <i1> [#uses=1] + br i1 %cond, label %BB.tomerge, label %Exit + +Exit: ; preds = %Use, %Succ + ret void +} diff --git a/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll b/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll new file mode 100644 index 0000000..d025dee --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll @@ -0,0 +1,36 @@ +; RUN: opt < %s -simplifycfg -S | grep {%outval = phi i32 .*mux} +; PR2540 +; Outval should end up with a select from 0/2, not all constants. + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" +target triple = "i386-pc-linux-gnu" +@g_37 = common global i32 0 ; <i32*> [#uses=1] +@.str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] + +define i32 @main() nounwind { +entry: + %l = load i32* @g_37, align 4 ; <i32> [#uses=1] + %cmpa = icmp ne i32 %l, 0 ; <i1> [#uses=3] + br i1 %cmpa, label %func_1.exit, label %mooseblock + +mooseblock: ; preds = %entry + %cmpb = icmp eq i1 %cmpa, false ; <i1> [#uses=2] + br i1 %cmpb, label %monkeyblock, label %beeblock + +monkeyblock: ; preds = %monkeyblock, %mooseblock + br i1 %cmpb, label %cowblock, label %monkeyblock + +beeblock: ; preds = %beeblock, %mooseblock + br i1 %cmpa, label %cowblock, label %beeblock + +cowblock: ; preds = %beeblock, %monkeyblock + %cowval = phi i32 [ 2, %beeblock ], [ 0, %monkeyblock ] ; <i32> [#uses=1] + br label %func_1.exit + +func_1.exit: ; preds = %cowblock, %entry + %outval = phi i32 [ %cowval, %cowblock ], [ 1, %entry ] ; <i32> [#uses=1] + %pout = tail call i32 (i8*, ...)* @printf( i8* noalias getelementptr ([4 x i8]* @.str, i32 0, i32 0), i32 %outval ) nounwind ; <i32> [#uses=0] + ret i32 0 +} + +declare i32 @printf(i8*, ...) nounwind diff --git a/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll b/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll new file mode 100644 index 0000000..ac9622d --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll @@ -0,0 +1,60 @@ +; RUN: opt < %s -simplifycfg -disable-output +; PR 2777 +@g_103 = common global i32 0 ; <i32*> [#uses=1] + +define i32 @func_127(i32 %p_129) nounwind { +entry: + load i32* @g_103, align 4 ; <i32>:0 [#uses=1] + icmp eq i32 %0, 0 ; <i1>:1 [#uses=2] + br i1 %1, label %bb6.preheader, label %entry.return_crit_edge + +entry.return_crit_edge: ; preds = %entry + br label %return + +bb6.preheader: ; preds = %entry + br i1 %1, label %bb6.preheader.split.us, label %bb6.preheader.split + +bb6.preheader.split.us: ; preds = %bb6.preheader + br label %return.loopexit.split + +bb6.preheader.split: ; preds = %bb6.preheader + br label %bb6 + +bb6: ; preds = %bb17.bb6_crit_edge, %bb6.preheader.split + %indvar35 = phi i32 [ 0, %bb6.preheader.split ], [ %indvar.next36, %bb17.bb6_crit_edge ] ; <i32> [#uses=1] + %p_129_addr.3.reg2mem.0 = phi i32 [ %p_129_addr.2, %bb17.bb6_crit_edge ], [ %p_129, %bb6.preheader.split ] ; <i32> [#uses=3] + icmp eq i32 %p_129_addr.3.reg2mem.0, 0 ; <i1>:2 [#uses=1] + br i1 %2, label %bb6.bb17_crit_edge, label %bb8 + +bb6.bb17_crit_edge: ; preds = %bb6 + br label %bb17 + +bb8: ; preds = %bb6 + br label %bb13 + +bb13: ; preds = %bb8 + br label %bb17 + +bb17: ; preds = %bb13, %bb6.bb17_crit_edge + %p_129_addr.2 = phi i32 [ %p_129_addr.3.reg2mem.0, %bb13 ], [ %p_129_addr.3.reg2mem.0, %bb6.bb17_crit_edge ] ; <i32> [#uses=1] + %indvar.next36 = add i32 %indvar35, 1 ; <i32> [#uses=2] + %exitcond37 = icmp eq i32 %indvar.next36, -1 ; <i1> [#uses=1] + br i1 %exitcond37, label %return.loopexit, label %bb17.bb6_crit_edge + +bb17.bb6_crit_edge: ; preds = %bb17 + br label %bb6 + +return.loopexit: ; preds = %bb17 + br label %return.loopexit.split + +return.loopexit.split: ; preds = %return.loopexit, %bb6.preheader.split.us + br label %return + +return: ; preds = %return.loopexit.split, %entry.return_crit_edge + ret i32 1 +} + +define i32 @func_135(i8 zeroext %p_137, i32 %p_138, i32 %p_140) nounwind { +entry: + ret i32 undef +} diff --git a/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll b/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll new file mode 100644 index 0000000..f864184 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-09-17-SpeculativeHoist.ll @@ -0,0 +1,18 @@ +; RUN: opt < %s -simplifycfg -disable-output +; PR 2800 + +define void @foo() { +start: + %tmp = call i1 @bar( ) ; <i1> [#uses=4] + br i1 %tmp, label %brtrue, label %brfalse + +brtrue: ; preds = %start + %tmpnew = and i1 %tmp, %tmp ; <i1> [#uses=1] + br label %brfalse + +brfalse: ; preds = %brtrue, %start + %andandtmp.0 = phi i1 [ %tmp, %start ], [ %tmpnew, %brtrue ] ; <i1> [#uses=0] + ret void +} + +declare i1 @bar() diff --git a/test/Transforms/SimplifyCFG/2008-10-03-SpeculativelyExecuteBeforePHI.ll b/test/Transforms/SimplifyCFG/2008-10-03-SpeculativelyExecuteBeforePHI.ll new file mode 100644 index 0000000..bb137c1 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-10-03-SpeculativelyExecuteBeforePHI.ll @@ -0,0 +1,36 @@ +; RUN: opt < %s -simplifycfg +; PR2855 + +define i32 @_Z1fPii(i32* %b, i32 %f) nounwind { +entry: + br label %bb + +bb: ; preds = %bb9, %bb7, %bb, %entry + %__c2.2 = phi i32 [ undef, %entry ], [ %__c2.1, %bb7 ], [ %__c2.1, %bb9 ] ; <i32> [#uses=2] + %s.0 = phi i32 [ 0, %entry ], [ 0, %bb7 ], [ %2, %bb9 ] ; <i32> [#uses=1] + br label %bb1 + +bb1: ; preds = %bb + %0 = icmp slt i32 0, %f ; <i1> [#uses=1] + br i1 %0, label %bb3, label %bb6 + +bb3: ; preds = %bb1 + %1 = icmp eq i32 0, 0 ; <i1> [#uses=1] + br i1 %1, label %bb6, label %bb5 + +bb5: ; preds = %bb3 + br label %bb7 + +bb6: ; preds = %bb3, %bb1 + %__c2.0 = phi i32 [ 0, %bb3 ], [ %__c2.2, %bb1 ] ; <i32> [#uses=1] + br label %bb7 + +bb7: ; preds = %bb6, %bb5 + %__c2.1 = phi i32 [ 0, %bb5 ], [ %__c2.0, %bb6 ] ; <i32> [#uses=2] + %iftmp.1.0 = phi i1 [ false, %bb5 ], [ true, %bb6 ] ; <i1> [#uses=1] + br i1 %iftmp.1.0, label %bb, label %bb9 + +bb9: ; preds = %bb7 + %2 = add i32 %s.0, 2 ; <i32> [#uses=1] + br label %bb +} diff --git a/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll b/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll new file mode 100644 index 0000000..d3c7c32 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll @@ -0,0 +1,13 @@ +; RUN: opt < %s -simplifycfg | llvm-dis +define i32 @test() { +entry: + br label %T +T: + %C = phi i1 [false, %entry] + br i1 %C, label %X, label %Y +X: + ret i32 2 +Y: + add i32 1, 2 + ret i32 1 +} diff --git a/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll b/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll new file mode 100644 index 0000000..7271024 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll @@ -0,0 +1,46 @@ +; RUN: opt < %s -simplifycfg -S | not grep icmp +; ModuleID = '/tmp/x.bc' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-pc-linux-gnu" + +define i32 @x(i32 %x) { +entry: + %cmp = icmp eq i32 %x, 8 ; <i1> [#uses=1] + br i1 %cmp, label %ifthen, label %ifend + +ifthen: ; preds = %entry + %call = call i32 (...)* @foo() ; <i32> [#uses=0] + br label %ifend + +ifend: ; preds = %ifthen, %entry + %cmp2 = icmp ne i32 %x, 8 ; <i1> [#uses=1] + br i1 %cmp2, label %ifthen3, label %ifend5 + +ifthen3: ; preds = %ifend + %call4 = call i32 (...)* @foo() ; <i32> [#uses=0] + br label %ifend5 + +ifend5: ; preds = %ifthen3, %ifend + %cmp7 = icmp eq i32 %x, 9 ; <i1> [#uses=1] + br i1 %cmp7, label %ifthen8, label %ifend10 + +ifthen8: ; preds = %ifend5 + %call9 = call i32 (...)* @bar() ; <i32> [#uses=0] + br label %ifend10 + +ifend10: ; preds = %ifthen8, %ifend5 + %cmp12 = icmp ne i32 %x, 9 ; <i1> [#uses=1] + br i1 %cmp12, label %ifthen13, label %ifend15 + +ifthen13: ; preds = %ifend10 + %call14 = call i32 (...)* @bar() ; <i32> [#uses=0] + br label %ifend15 + +ifend15: ; preds = %ifthen13, %ifend10 + ret i32 0 +} + +declare i32 @foo(...) + +declare i32 @bar(...) + diff --git a/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll b/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll new file mode 100644 index 0000000..c6ae6ac --- /dev/null +++ b/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll @@ -0,0 +1,30 @@ +; RUN: opt < %s -simplifycfg -disable-output +; PR3016 +; Dead use caused invariant violation. + +define i32 @func_105(i1 %tmp5, i1 %tmp7) nounwind { +BB: + br i1 true, label %BB2, label %BB1 + +BB1: ; preds = %BB + br label %BB2 + +BB2: ; preds = %BB1, %BB + %tmp3 = phi i1 [ true, %BB ], [ false, %BB1 ] ; <i1> [#uses=1] + br label %BB9 + +BB9: ; preds = %BB11, %BB2 + %tmp10 = phi i32 [ 0, %BB2 ], [ %tmp12, %BB11 ] ; <i32> [#uses=1] + br i1 %tmp5, label %BB11, label %BB13 + +BB11: ; preds = %BB13, %BB9 + %tmp12 = phi i32 [ 0, %BB13 ], [ %tmp10, %BB9 ] ; <i32> [#uses=2] + br i1 %tmp3, label %BB9, label %BB20 + +BB13: ; preds = %BB13, %BB9 + %tmp14 = phi i32 [ 0, %BB9 ], [ %tmp14, %BB13 ] ; <i32> [#uses=1] + br i1 %tmp7, label %BB13, label %BB11 + +BB20: ; preds = %BB11 + ret i32 %tmp12 +} diff --git a/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll b/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll new file mode 100644 index 0000000..33167bd --- /dev/null +++ b/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll @@ -0,0 +1,31 @@ +; RUN: opt < %s -simplifycfg -S | grep {br i1 } | count 4 +; PR3354 +; Do not merge bb1 into the entry block, it might trap. + +@G = extern_weak global i32 + +define i32 @test(i32 %tmp21, i32 %tmp24) { + %tmp25 = icmp sle i32 %tmp21, %tmp24 + br i1 %tmp25, label %bb2, label %bb1 + +bb1: ; preds = %bb + %tmp26 = icmp sgt i32 sdiv (i32 -32768, i32 ptrtoint (i32* @G to i32)), 0 + br i1 %tmp26, label %bb6, label %bb2 +bb2: + ret i32 42 + +bb6: + unwind +} + +define i32 @test2(i32 %tmp21, i32 %tmp24, i1 %tmp34) { + br i1 %tmp34, label %bb5, label %bb6 + +bb5: ; preds = %bb4 + br i1 icmp sgt (i32 sdiv (i32 32767, i32 ptrtoint (i32* @G to i32)), i32 0), label %bb6, label %bb7 +bb6: + ret i32 42 +bb7: + unwind +} + diff --git a/test/Transforms/SimplifyCFG/2009-03-05-Speculative-Hoist-Dbg.ll b/test/Transforms/SimplifyCFG/2009-03-05-Speculative-Hoist-Dbg.ll new file mode 100644 index 0000000..db56fdb --- /dev/null +++ b/test/Transforms/SimplifyCFG/2009-03-05-Speculative-Hoist-Dbg.ll @@ -0,0 +1,108 @@ +; RUN: opt < %s -simplifycfg -S | grep select + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" + +@.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +external global <{ i8 }> ; <<{ i8 }>*>:0 [#uses=0] +@__dso_handle = external global i8* ; <i8**> [#uses=0] +@_ZSt3cin = external global { i32 (...)**, i32, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, \3 }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } } ; <{ i32 (...)**, i32, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, \3 }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] +@_ZSt4cout = external global { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } } ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] +external constant [2 x i8] ; <[2 x i8]*>:1 [#uses=1] +@llvm.global_ctors = external global [1 x { i32, void ()* }] ; <[1 x { i32, void ()* }]*> [#uses=0] + +define i32 @main(i32, i8**) { +; <label>:2 + %3 = alloca [4096 x i8], align 1 ; <[4096 x i8]*> [#uses=1] + %4 = call { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* @_ZNKSt9basic_iosIcSt11char_traitsIcEE5rdbufEv({ { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* }* getelementptr ({ i32 (...)**, i32, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, \3 }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZSt3cin, i32 0, i32 2)) ; <{ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*> [#uses=1] + %5 = getelementptr [4096 x i8]* %3, i32 0, i32 0 ; <i8*> [#uses=1] + %6 = call { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* @_ZNSt15basic_streambufIcSt11char_traitsIcEE9pubsetbufEPci({ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* %4, i8* %5, i32 4096) ; <{ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*> [#uses=0] + %7 = call { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* @_ZNKSt9basic_iosIcSt11char_traitsIcEE5rdbufEv({ { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* }* getelementptr ({ i32 (...)**, i32, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, \3 }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZSt3cin, i32 0, i32 2)) ; <{ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*> [#uses=1] + br label %25 + +; <label>:8 ; preds = %25 + %9 = trunc i32 %26 to i8 ; <i8> [#uses=4] + %10 = add i32 %.02, 1 ; <i32> [#uses=3] + %11 = icmp eq i8 %9, 10 ; <i1> [#uses=1] + br i1 %11, label %12, label %14 + +; <label>:12 ; preds = %8 + %13 = add i32 %.1, 1 ; <i32> [#uses=1] + br label %14 + +; <label>:14 ; preds = %12, %8 + %.0 = phi i32 [ %.1, %8 ], [ %13, %12 ] ; <i32> [#uses=3] + %15 = icmp eq i8 %9, 32 ; <i1> [#uses=1] + br i1 %15, label %20, label %16 + +; <label>:16 ; preds = %14 + %17 = icmp eq i8 %9, 10 ; <i1> [#uses=1] + br i1 %17, label %20, label %18 + +; <label>:18 ; preds = %16 + %19 = icmp eq i8 %9, 9 ; <i1> [#uses=1] + br i1 %19, label %20, label %21 + +; <label>:20 ; preds = %18, %16, %14 + br label %25 + +; <label>:21 ; preds = %18 + %22 = icmp eq i32 %.03, 0 ; <i1> [#uses=1] + br i1 %22, label %23, label %25 + +; <label>:23 ; preds = %21 + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %24 = add i32 %.01, 1 ; <i32> [#uses=1] + br label %25 + +; <label>:25 ; preds = %23, %21, %20, %2 + %.03 = phi i32 [ 0, %2 ], [ %.03, %21 ], [ 1, %23 ], [ 0, %20 ] ; <i32> [#uses=2] + %.02 = phi i32 [ 0, %2 ], [ %10, %21 ], [ %10, %23 ], [ %10, %20 ] ; <i32> [#uses=2] + %.01 = phi i32 [ 0, %2 ], [ %.01, %21 ], [ %24, %23 ], [ %.01, %20 ] ; <i32> [#uses=4] + %.1 = phi i32 [ 0, %2 ], [ %.0, %21 ], [ %.0, %23 ], [ %.0, %20 ] ; <i32> [#uses=3] + %26 = call i32 @_ZNSt15basic_streambufIcSt11char_traitsIcEE6sbumpcEv({ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* %7) ; <i32> [#uses=2] + %27 = icmp eq i32 %26, -1 ; <i1> [#uses=1] + br i1 %27, label %28, label %8 + +; <label>:28 ; preds = %25 + %29 = call { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZNSolsEi({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZSt4cout, i32 %.1) ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] + %30 = call { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* %29, i8* getelementptr ([2 x i8]* @1, i32 0, i32 0)) ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] + %31 = call { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZNSolsEi({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* %30, i32 %.01) ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] + %32 = call { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* %31, i8* getelementptr ([2 x i8]* @1, i32 0, i32 0)) ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] + %33 = call { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZNSolsEi({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* %32, i32 %.02) ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=1] + %34 = call { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZNSolsEPFRSoS_E({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* %33, { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* ({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*)* @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_) ; <{ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*> [#uses=0] + ret i32 0 +} + +declare void @""() section "__TEXT,__StaticInit,regular,pure_instructions" + +declare fastcc void @""() section "__TEXT,__StaticInit,regular,pure_instructions" + +declare void @_ZNSt8ios_base4InitC1Ev(<{ i8 }>*) + +declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) nounwind + +declare void @""(i8*) + +declare void @_ZNSt8ios_base4InitD1Ev(<{ i8 }>*) + +declare { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* @_ZNKSt9basic_iosIcSt11char_traitsIcEE5rdbufEv({ { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* }*) + +declare { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }* @_ZNSt15basic_streambufIcSt11char_traitsIcEE9pubsetbufEPci({ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, i8*, i32) + +declare i32 @_ZNSt15basic_streambufIcSt11char_traitsIcEE6sbumpcEv({ i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*) + +declare { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZNSolsEi({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*, i32) + +declare { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*, i8*) + +declare { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZNSolsEPFRSoS_E({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*, { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* ({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*)*) + +declare { i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }* @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_({ i32 (...)**, { { i32 (...)**, i32, i32, i32, i32, i32, { \2, void (i32, \6*, i32)*, i32, i32 }*, { i8*, i32 }, [8 x { i8*, i32 }], i32, { i8*, i32 }*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }, \3*, i8, i8, { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, { { i32, { i32 (...)**, i32 }**, i32, { i32 (...)**, i32 }**, i8** }* } }*, { { i32 (...)**, i32 }, i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 }*, { { i32 (...)**, i32 } }*, { { i32 (...)**, i32 } }* } }*) diff --git a/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll b/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll new file mode 100644 index 0000000..419feb6 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll @@ -0,0 +1,47 @@ +; RUN: opt < %s -simplifycfg -S | not grep select +; ModuleID = '<stdin>' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin10.0" +module asm ".globl _foo" +module asm "_foo: ret" +module asm ".globl _i" +module asm ".set _i, 0" +@i = extern_weak global i32 ; <i32*> [#uses=2] +@j = common global i32 0 ; <i32*> [#uses=1] +@ed = common global double 0.000000e+00, align 8 ; <double*> [#uses=1] + +define i32 @main() nounwind ssp { +entry: + br label %bb4 + +bb: ; preds = %bb4 + br i1 icmp ne (i32* @i, i32* null), label %bb1, label %bb2 + +bb1: ; preds = %bb + %0 = load i32* @i, align 4 ; <i32> [#uses=1] + br label %bb3 + +bb2: ; preds = %bb + br label %bb3 + +bb3: ; preds = %bb2, %bb1 + %storemerge = phi i32 [ %0, %bb1 ], [ 0, %bb2 ] ; <i32> [#uses=2] + store i32 %storemerge, i32* @j + %1 = sitofp i32 %storemerge to double ; <double> [#uses=1] + %2 = call double @sin(double %1) nounwind readonly ; <double> [#uses=1] + %3 = fadd double %2, %d.0 ; <double> [#uses=1] + %4 = add i32 %l.0, 1 ; <i32> [#uses=1] + br label %bb4 + +bb4: ; preds = %bb3, %entry + %d.0 = phi double [ undef, %entry ], [ %3, %bb3 ] ; <double> [#uses=2] + %l.0 = phi i32 [ 0, %entry ], [ %4, %bb3 ] ; <i32> [#uses=2] + %5 = icmp sgt i32 %l.0, 99 ; <i1> [#uses=1] + br i1 %5, label %bb5, label %bb + +bb5: ; preds = %bb4 + store double %d.0, double* @ed, align 8 + ret i32 0 +} + +declare double @sin(double) nounwind readonly diff --git a/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll new file mode 100644 index 0000000..72a15b1 --- /dev/null +++ b/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll @@ -0,0 +1,557 @@ +; RUN: opt < %s -simplifycfg -disable-output +; END. + %struct..4._102 = type { %struct.QVectorData* } + %struct..5._125 = type { %struct.QMapData* } + %struct.QAbstractTextDocumentLayout = type { %struct.QObject } + %struct.QBasicAtomic = type { i32 } + %struct.QFont = type { %struct.QFontPrivate*, i32 } + %struct.QFontMetrics = type { %struct.QFontPrivate* } + %struct.QFontPrivate = type opaque + %"struct.QFragmentMap<QTextBlockData>" = type { %struct.QFragmentMapData } + %struct.QFragmentMapData = type { %"struct.QFragmentMapData::._154", i32 } + %"struct.QFragmentMapData::._154" = type { %"struct.QFragmentMapData::Header"* } + %"struct.QFragmentMapData::Header" = type { i32, i32, i32, i32, i32, i32, i32, i32 } + %"struct.QHash<uint,QHashDummyValue>" = type { %"struct.QHash<uint,QHashDummyValue>::._152" } + %"struct.QHash<uint,QHashDummyValue>::._152" = type { %struct.QHashData* } + %struct.QHashData = type { %"struct.QHashData::Node"*, %"struct.QHashData::Node"**, %struct.QBasicAtomic, i32, i32, i16, i16, i32, i8 } + %"struct.QHashData::Node" = type { %"struct.QHashData::Node"*, i32 } + %"struct.QList<QObject*>::._92" = type { %struct.QListData } + %"struct.QList<QPointer<QObject> >" = type { %"struct.QList<QObject*>::._92" } + %struct.QListData = type { %"struct.QListData::Data"* } + %"struct.QListData::Data" = type { %struct.QBasicAtomic, i32, i32, i32, i8, [1 x i8*] } + %"struct.QMap<QUrl,QVariant>" = type { %struct..5._125 } + %struct.QMapData = type { %"struct.QMapData::Node"*, [12 x %"struct.QMapData::Node"*], %struct.QBasicAtomic, i32, i32, i32, i8 } + %"struct.QMapData::Node" = type { %"struct.QMapData::Node"*, [1 x %"struct.QMapData::Node"*] } + %struct.QObject = type { i32 (...)**, %struct.QObjectData* } + %struct.QObjectData = type { i32 (...)**, %struct.QObject*, %struct.QObject*, %"struct.QList<QPointer<QObject> >", i8, [3 x i8], i32, i32 } + %struct.QObjectPrivate = type { %struct.QObjectData, i32, %struct.QObject*, %"struct.QList<QPointer<QObject> >", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %struct.QString } + %struct.QPaintDevice = type { i32 (...)**, i16 } + %struct.QPainter = type { %struct.QPainterPrivate* } + %struct.QPainterPrivate = type opaque + %struct.QPointF = type { double, double } + %struct.QPrinter = type { %struct.QPaintDevice, %struct.QPrinterPrivate* } + %struct.QPrinterPrivate = type opaque + %struct.QRectF = type { double, double, double, double } + %"struct.QSet<uint>" = type { %"struct.QHash<uint,QHashDummyValue>" } + %"struct.QSharedDataPointer<QTextFormatPrivate>" = type { %struct.QTextFormatPrivate* } + %struct.QString = type { %"struct.QString::Data"* } + %"struct.QString::Data" = type { %struct.QBasicAtomic, i32, i32, i16*, i8, i8, [1 x i16] } + %struct.QTextBlockFormat = type { %struct.QTextFormat } + %struct.QTextBlockGroup = type { %struct.QAbstractTextDocumentLayout } + %struct.QTextDocumentConfig = type { %struct.QString } + %struct.QTextDocumentPrivate = type { %struct.QObjectPrivate, %struct.QString, %"struct.QVector<QAbstractTextDocumentLayout::Selection>", i1, i32, i32, i1, i32, i32, i32, i32, i1, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, %"struct.QFragmentMap<QTextBlockData>", %"struct.QFragmentMap<QTextBlockData>", i32, %"struct.QList<QPointer<QObject> >", %"struct.QList<QPointer<QObject> >", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %"struct.QMap<QUrl,QVariant>", %struct.QTextDocumentConfig, i1, i1, %struct.QPointF } + %struct.QTextFormat = type { %"struct.QSharedDataPointer<QTextFormatPrivate>", i32 } + %struct.QTextFormatCollection = type { %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QVector<QAbstractTextDocumentLayout::Selection>", %"struct.QSet<uint>", %struct.QFont } + %struct.QTextFormatPrivate = type opaque + %"struct.QVector<QAbstractTextDocumentLayout::Selection>" = type { %struct..4._102 } + %struct.QVectorData = type { %struct.QBasicAtomic, i32, i32, i8 } + +define void @_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) { +entry: + %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %tmp.upgrd.1 = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5] + %tmp2 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] + %tmp.upgrd.2 = alloca %struct.QFontMetrics, align 16 ; <%struct.QFontMetrics*> [#uses=4] + %tmp.upgrd.3 = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=4] + %tmp3 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %p = alloca %struct.QPainter, align 16 ; <%struct.QPainter*> [#uses=14] + %body = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=9] + %foo = alloca double, align 8 + %bar = alloca double, align 8 + %pageNumberPos = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=4] + %scaledPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=6] + %printerPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] + %fmt = alloca %struct.QTextBlockFormat, align 16 ; <%struct.QTextBlockFormat*> [#uses=5] + %font = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=5] + %tmp.upgrd.4 = call %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv( %struct.QAbstractTextDocumentLayout* %this ) ; <%struct.QTextDocumentPrivate*> [#uses=5] + %tmp.upgrd.5 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + call void @_ZN8QPainterC1EP12QPaintDevice( %struct.QPainter* %p, %struct.QPaintDevice* %tmp.upgrd.5 ) + %tmp.upgrd.6 = invoke i1 @_ZNK8QPainter8isActiveEv( %struct.QPainter* %p ) + to label %invcont unwind label %cleanup329 ; <i1> [#uses=1] +invcont: ; preds = %entry + br i1 %tmp.upgrd.6, label %cond_next, label %cleanup328 +cond_next: ; preds = %invcont + %tmp8 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) + to label %invcont7 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=0] +invcont7: ; preds = %cond_next + %tmp10 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp, double 0.000000e+00, double 0.000000e+00 ) + call void @_ZN6QRectFC1ERK7QPointFRK6QSizeF( %struct.QRectF* %body, %struct.QPointF* %tmp, %struct.QPointF* %tmp10 ) + call void @_ZN7QPointFC1Ev( %struct.QPointF* %pageNumberPos ) + %tmp12 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + %tmp13 = call i1 @_ZNK6QSizeF7isValidEv( %struct.QPointF* %tmp12 ) ; <i1> [#uses=1] + br i1 %tmp13, label %cond_next15, label %bb +cond_next15: ; preds = %invcont7 + %tmp17 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + %tmp.upgrd.7 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %tmp17 ) ; <double> [#uses=1] + %tmp18 = fcmp oeq double %tmp.upgrd.7, 0x41DFFFFFFFC00000 ; <i1> [#uses=1] + br i1 %tmp18, label %bb, label %cond_next20 +cond_next20: ; preds = %cond_next15 + br label %bb21 +bb: ; preds = %cond_next15, %invcont7 + br label %bb21 +bb21: ; preds = %bb, %cond_next20 + %iftmp.406.0 = phi i1 [ false, %bb ], [ true, %cond_next20 ] ; <i1> [#uses=1] + br i1 %iftmp.406.0, label %cond_true24, label %cond_false +cond_true24: ; preds = %bb21 + %tmp.upgrd.8 = invoke i32 @_Z13qt_defaultDpiv( ) + to label %invcont25 unwind label %cleanup329 ; <i32> [#uses=1] +invcont25: ; preds = %cond_true24 + %tmp26 = sitofp i32 %tmp.upgrd.8 to double ; <double> [#uses=2] + %tmp30 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) + to label %invcont29 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] +invcont29: ; preds = %invcont25 + %tmp32 = invoke %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv( %struct.QAbstractTextDocumentLayout* %tmp30 ) + to label %invcont31 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=3] +invcont31: ; preds = %invcont29 + %tmp34 = icmp eq %struct.QPaintDevice* %tmp32, null ; <i1> [#uses=1] + br i1 %tmp34, label %cond_next42, label %cond_true35 +cond_true35: ; preds = %invcont31 + %tmp38 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp32 ) + to label %invcont37 unwind label %cleanup329 ; <i32> [#uses=1] +invcont37: ; preds = %cond_true35 + %tmp38.upgrd.9 = sitofp i32 %tmp38 to double ; <double> [#uses=1] + %tmp41 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp32 ) + to label %invcont40 unwind label %cleanup329 ; <i32> [#uses=1] +invcont40: ; preds = %invcont37 + %tmp41.upgrd.10 = sitofp i32 %tmp41 to double ; <double> [#uses=1] + br label %cond_next42 +cond_next42: ; preds = %invcont40, %invcont31 + %sourceDpiY.2 = phi double [ %tmp41.upgrd.10, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] + %sourceDpiX.2 = phi double [ %tmp38.upgrd.9, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1] + %tmp44 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp46 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp44 ) + to label %invcont45 unwind label %cleanup329 ; <i32> [#uses=1] +invcont45: ; preds = %cond_next42 + %tmp46.upgrd.11 = sitofp i32 %tmp46 to double ; <double> [#uses=1] + %tmp48 = fdiv double %tmp46.upgrd.11, %sourceDpiX.2 ; <double> [#uses=2] + %tmp50 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp52 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp50 ) + to label %invcont51 unwind label %cleanup329 ; <i32> [#uses=1] +invcont51: ; preds = %invcont45 + %tmp52.upgrd.12 = sitofp i32 %tmp52 to double ; <double> [#uses=1] + %tmp54 = fdiv double %tmp52.upgrd.12, %sourceDpiY.2 ; <double> [#uses=2] + invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp48, double %tmp54 ) + to label %invcont57 unwind label %cleanup329 +invcont57: ; preds = %invcont51 + %tmp.upgrd.13 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 0 ; <double*> [#uses=1] + %tmp60 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 0 ; <double*> [#uses=1] + %tmp61 = load double* %tmp60 ; <double> [#uses=1] + store double %tmp61, double* %tmp.upgrd.13 + %tmp62 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 1 ; <double*> [#uses=1] + %tmp63 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 1 ; <double*> [#uses=1] + %tmp64 = load double* %tmp63 ; <double> [#uses=1] + store double %tmp64, double* %tmp62 + %tmp65 = call double* @_ZN6QSizeF6rwidthEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] + %tmp67 = load double* %tmp65 ; <double> [#uses=1] + %tmp69 = mul double %tmp67, %tmp48 ; <double> [#uses=1] + store double %tmp69, double* %tmp65 + %tmp71 = call double* @_ZN6QSizeF7rheightEv( %struct.QPointF* %scaledPageSize ) ; <double*> [#uses=2] + %tmp73 = load double* %tmp71 ; <double> [#uses=1] + %tmp75 = mul double %tmp73, %tmp54 ; <double> [#uses=1] + store double %tmp75, double* %tmp71 + %tmp78 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp80 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 ) + to label %invcont79 unwind label %cleanup329 ; <i32> [#uses=1] +invcont79: ; preds = %invcont57 + %tmp82 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp84 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp82 ) + to label %invcont83 unwind label %cleanup329 ; <i32> [#uses=1] +invcont83: ; preds = %invcont79 + %tmp80.upgrd.14 = sitofp i32 %tmp80 to double ; <double> [#uses=1] + %tmp84.upgrd.15 = sitofp i32 %tmp84 to double ; <double> [#uses=1] + call void @_ZN6QSizeFC1Edd( %struct.QPointF* %printerPageSize, double %tmp84.upgrd.15, double %tmp80.upgrd.14 ) + %tmp85 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] + %tmp86 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] + %tmp87 = fdiv double %tmp85, %tmp86 ; <double> [#uses=1] + %tmp88 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %printerPageSize ) ; <double> [#uses=1] + %tmp89 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %scaledPageSize ) ; <double> [#uses=1] + %tmp90 = fdiv double %tmp88, %tmp89 ; <double> [#uses=1] + invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp90, double %tmp87 ) + to label %cond_next194 unwind label %cleanup329 +cond_false: ; preds = %bb21 + %tmp.upgrd.16 = getelementptr %struct.QAbstractTextDocumentLayout* %this, i32 0, i32 0 ; <%struct.QObject*> [#uses=1] + %tmp95 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject( %struct.QAbstractTextDocumentLayout* %this, %struct.QObject* %tmp.upgrd.16 ) + to label %invcont94 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=9] +invcont94: ; preds = %cond_false + %tmp99 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont98 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] +invcont98: ; preds = %invcont94 + %tmp101 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont100 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] +invcont100: ; preds = %invcont98 + invoke void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice( %struct.QAbstractTextDocumentLayout* %tmp99, %struct.QPaintDevice* %tmp101 ) + to label %invcont103 unwind label %cleanup329 +invcont103: ; preds = %invcont100 + %tmp105 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont104 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] +invcont104: ; preds = %invcont103 + %tmp107 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp105 ) + to label %invcont106 unwind label %cleanup329 ; <i32> [#uses=1] +invcont106: ; preds = %invcont104 + %tmp108 = sitofp i32 %tmp107 to double ; <double> [#uses=1] + %tmp109 = mul double %tmp108, 0x3FE93264C993264C ; <double> [#uses=1] + %tmp109.upgrd.17 = fptosi double %tmp109 to i32 ; <i32> [#uses=3] + %tmp.upgrd.18 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] + invoke void @_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* sret %fmt, %struct.QTextBlockGroup* %tmp.upgrd.18 ) + to label %invcont111 unwind label %cleanup329 +invcont111: ; preds = %invcont106 + %tmp112 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] + invoke void @_ZN16QTextFrameFormat9setMarginEd( %struct.QTextBlockFormat* %fmt, double %tmp112 ) + to label %invcont114 unwind label %cleanup192 +invcont114: ; preds = %invcont111 + %tmp116 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] + invoke void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat( %struct.QTextBlockGroup* %tmp116, %struct.QTextBlockFormat* %fmt ) + to label %invcont117 unwind label %cleanup192 +invcont117: ; preds = %invcont114 + %tmp119 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont118 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont118: ; preds = %invcont117 + %tmp121 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp119 ) + to label %invcont120 unwind label %cleanup192 ; <i32> [#uses=1] +invcont120: ; preds = %invcont118 + %tmp121.upgrd.19 = sitofp i32 %tmp121 to double ; <double> [#uses=1] + %tmp123 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont122 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont122: ; preds = %invcont120 + %tmp125 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp123 ) + to label %invcont124 unwind label %cleanup192 ; <i32> [#uses=1] +invcont124: ; preds = %invcont122 + %tmp125.upgrd.20 = sitofp i32 %tmp125 to double ; <double> [#uses=1] + call void @_ZN6QRectFC1Edddd( %struct.QRectF* %tmp.upgrd.1, double 0.000000e+00, double 0.000000e+00, double %tmp125.upgrd.20, double %tmp121.upgrd.19 ) + %tmp126 = getelementptr %struct.QRectF* %body, i32 0, i32 0 ; <double*> [#uses=1] + %tmp127 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 0 ; <double*> [#uses=1] + %tmp128 = load double* %tmp127 ; <double> [#uses=1] + store double %tmp128, double* %tmp126 + %tmp129 = getelementptr %struct.QRectF* %body, i32 0, i32 1 ; <double*> [#uses=1] + %tmp130 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 1 ; <double*> [#uses=1] + %tmp131 = load double* %tmp130 ; <double> [#uses=1] + store double %tmp131, double* %tmp129 + %tmp132 = getelementptr %struct.QRectF* %body, i32 0, i32 2 ; <double*> [#uses=1] + %tmp133 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 2 ; <double*> [#uses=1] + %tmp134 = load double* %tmp133 ; <double> [#uses=1] + store double %tmp134, double* %tmp132 + %tmp135 = getelementptr %struct.QRectF* %body, i32 0, i32 3 ; <double*> [#uses=1] + %tmp136 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 3 ; <double*> [#uses=1] + %tmp137 = load double* %tmp136 ; <double> [#uses=1] + store double %tmp137, double* %tmp135 + %tmp138 = call double @_ZNK6QRectF6heightEv( %struct.QRectF* %body ) ; <double> [#uses=1] + %tmp139 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] + %tmp140 = sub double %tmp138, %tmp139 ; <double> [#uses=1] + %tmp142 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont141 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont141: ; preds = %invcont124 + invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %tmp.upgrd.3, %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont144 unwind label %cleanup192 +invcont144: ; preds = %invcont141 + invoke void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice( %struct.QFontMetrics* %tmp.upgrd.2, %struct.QFont* %tmp.upgrd.3, %struct.QPaintDevice* %tmp142 ) + to label %invcont146 unwind label %cleanup173 +invcont146: ; preds = %invcont144 + %tmp149 = invoke i32 @_ZNK12QFontMetrics6ascentEv( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %invcont148 unwind label %cleanup168 ; <i32> [#uses=1] +invcont148: ; preds = %invcont146 + %tmp149.upgrd.21 = sitofp i32 %tmp149 to double ; <double> [#uses=1] + %tmp150 = add double %tmp140, %tmp149.upgrd.21 ; <double> [#uses=1] + %tmp152 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont151 unwind label %cleanup168 ; <%struct.QPaintDevice*> [#uses=1] +invcont151: ; preds = %invcont148 + %tmp154 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp152 ) + to label %invcont153 unwind label %cleanup168 ; <i32> [#uses=1] +invcont153: ; preds = %invcont151 + %tmp155 = mul i32 %tmp154, 5 ; <i32> [#uses=1] + %tmp156 = sdiv i32 %tmp155, 72 ; <i32> [#uses=1] + %tmp156.upgrd.22 = sitofp i32 %tmp156 to double ; <double> [#uses=1] + %tmp157 = add double %tmp150, %tmp156.upgrd.22 ; <double> [#uses=1] + %tmp158 = call double @_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; <double> [#uses=1] + %tmp159 = sitofp i32 %tmp109.upgrd.17 to double ; <double> [#uses=1] + %tmp160 = sub double %tmp158, %tmp159 ; <double> [#uses=1] + call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp2, double %tmp160, double %tmp157 ) + %tmp161 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 0 ; <double*> [#uses=1] + %tmp162 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 0 ; <double*> [#uses=1] + %tmp163 = load double* %tmp162 ; <double> [#uses=1] + store double %tmp163, double* %tmp161 + %tmp164 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 1 ; <double*> [#uses=1] + %tmp165 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 1 ; <double*> [#uses=1] + %tmp166 = load double* %tmp165 ; <double> [#uses=1] + store double %tmp166, double* %tmp164 + invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %cleanup171 unwind label %cleanup173 +cleanup168: ; preds = %invcont151, %invcont148, %invcont146 + invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %cleanup173 unwind label %cleanup173 +cleanup171: ; preds = %invcont153 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) + to label %finally170 unwind label %cleanup192 +cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) + to label %cleanup192 unwind label %cleanup192 +finally170: ; preds = %cleanup171 + invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %font, %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont177 unwind label %cleanup192 +invcont177: ; preds = %finally170 + invoke void @_ZN5QFont12setPointSizeEi( %struct.QFont* %font, i32 10 ) + to label %invcont179 unwind label %cleanup187 +invcont179: ; preds = %invcont177 + invoke void @_ZN13QTextDocument14setDefaultFontERK5QFont( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QFont* %font ) + to label %invcont181 unwind label %cleanup187 +invcont181: ; preds = %invcont179 + call void @_ZNK6QRectF4sizeEv( %struct.QPointF* sret %tmp3, %struct.QRectF* %body ) + invoke void @_ZN13QTextDocument11setPageSizeERK6QSizeF( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QPointF* %tmp3 ) + to label %cleanup185 unwind label %cleanup187 +cleanup185: ; preds = %invcont181 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) + to label %cleanup190 unwind label %cleanup192 +cleanup187: ; preds = %invcont181, %invcont179, %invcont177 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) + to label %cleanup192 unwind label %cleanup192 +cleanup190: ; preds = %cleanup185 + invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) + to label %cond_next194 unwind label %cleanup329 +cleanup192: ; preds = %cleanup187, %cleanup187, %cleanup185, %finally170, %cleanup173, %cleanup173, %cleanup171, %invcont141, %invcont124, %invcont122, %invcont120, %invcont118, %invcont117, %invcont114, %invcont111 + invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) + to label %cleanup329 unwind label %cleanup329 +cond_next194: ; preds = %cleanup190, %invcont83 + %clonedDoc.1 = phi %struct.QAbstractTextDocumentLayout* [ null, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=3] + %doc.1 = phi %struct.QAbstractTextDocumentLayout* [ %this, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=2] + %tmp197 = invoke i1 @_ZNK8QPrinter13collateCopiesEv( %struct.QPrinter* %printer ) + to label %invcont196 unwind label %cleanup329 ; <i1> [#uses=1] +invcont196: ; preds = %cond_next194 + br i1 %tmp197, label %cond_true200, label %cond_false204 +cond_true200: ; preds = %invcont196 + %tmp2000 = load double* %foo + store double %tmp2000, double* %bar + %tmp203 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) + to label %cond_next208 unwind label %cleanup329 ; <i32> [#uses=1] +cond_false204: ; preds = %invcont196 + %tmp2001 = load double* %foo + store double %tmp2001, double* %bar + %tmp207 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) + to label %cond_next208 unwind label %cleanup329 ; <i32> [#uses=1] +cond_next208: ; preds = %invcont206, %invcont202 + %pageCopies.0 = phi i32 [ %tmp203, %cond_true200 ], [ 1, %cond_false204 ] ; <i32> [#uses=2] + %docCopies.0 = phi i32 [ 1, %cond_true200 ], [ %tmp207, %cond_false204 ] ; <i32> [#uses=2] + %tmp211 = invoke i32 @_ZNK8QPrinter8fromPageEv( %struct.QPrinter* %printer ) + to label %invcont210 unwind label %cleanup329 ; <i32> [#uses=3] +invcont210: ; preds = %cond_next208 + %tmp214 = invoke i32 @_ZNK8QPrinter6toPageEv( %struct.QPrinter* %printer ) + to label %invcont213 unwind label %cleanup329 ; <i32> [#uses=3] +invcont213: ; preds = %invcont210 + %tmp216 = icmp eq i32 %tmp211, 0 ; <i1> [#uses=1] + br i1 %tmp216, label %cond_true217, label %cond_next225 +cond_true217: ; preds = %invcont213 + %tmp219 = icmp eq i32 %tmp214, 0 ; <i1> [#uses=1] + br i1 %tmp219, label %cond_true220, label %cond_next225 +cond_true220: ; preds = %cond_true217 + %tmp223 = invoke i32 @_ZNK13QTextDocument9pageCountEv( %struct.QAbstractTextDocumentLayout* %doc.1 ) + to label %invcont222 unwind label %cleanup329 ; <i32> [#uses=1] +invcont222: ; preds = %cond_true220 + br label %cond_next225 +cond_next225: ; preds = %invcont222, %cond_true217, %invcont213 + %toPage.1 = phi i32 [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; <i32> [#uses=2] + %fromPage.1 = phi i32 [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; <i32> [#uses=2] + %tmp.page = invoke i32 @_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer ) + to label %invcont227 unwind label %cleanup329 ; <i32> [#uses=1] +invcont227: ; preds = %cond_next225 + %tmp228 = icmp eq i32 %tmp.page, 1 ; <i1> [#uses=1] + br i1 %tmp228, label %cond_true230, label %cond_next234 +cond_true230: ; preds = %invcont227 + br label %cond_next234 +cond_next234: ; preds = %cond_true230, %invcont227 + %ascending.1 = phi i1 [ false, %cond_true230 ], [ true, %invcont227 ] ; <i1> [#uses=1] + %toPage.2 = phi i32 [ %fromPage.1, %cond_true230 ], [ %toPage.1, %invcont227 ] ; <i32> [#uses=1] + %fromPage.2 = phi i32 [ %toPage.1, %cond_true230 ], [ %fromPage.1, %invcont227 ] ; <i32> [#uses=1] + br label %bb309 +bb237: ; preds = %cond_true313, %cond_next293 + %iftmp.410.4 = phi i1 [ %iftmp.410.5, %cond_true313 ], [ %iftmp.410.1, %cond_next293 ] ; <i1> [#uses=1] + %page.4 = phi i32 [ %fromPage.2, %cond_true313 ], [ %page.3, %cond_next293 ] ; <i32> [#uses=4] + br label %bb273 +invcont240: ; preds = %cond_true277 + %tmp242 = icmp eq i32 %tmp241, 2 ; <i1> [#uses=1] + br i1 %tmp242, label %bb252, label %cond_next244 +cond_next244: ; preds = %invcont240 + %tmp247 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) + to label %invcont246 unwind label %cleanup329 ; <i32> [#uses=1] +invcont246: ; preds = %cond_next244 + %tmp248 = icmp eq i32 %tmp247, 3 ; <i1> [#uses=1] + br i1 %tmp248, label %bb252, label %bb253 +bb252: ; preds = %invcont246, %invcont240 + br label %bb254 +bb253: ; preds = %invcont246 + br label %bb254 +bb254: ; preds = %bb253, %bb252 + %iftmp.410.0 = phi i1 [ true, %bb252 ], [ false, %bb253 ] ; <i1> [#uses=2] + br i1 %iftmp.410.0, label %UserCanceled, label %cond_next258 +cond_next258: ; preds = %bb254 + invoke fastcc void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF( i32 %page.4, %struct.QPainter* %p, %struct.QAbstractTextDocumentLayout* %doc.1, %struct.QRectF* %body, %struct.QPointF* %pageNumberPos ) + to label %invcont261 unwind label %cleanup329 +invcont261: ; preds = %cond_next258 + %tmp263 = add i32 %pageCopies.0, -1 ; <i32> [#uses=1] + %tmp265 = icmp sgt i32 %tmp263, %j.4 ; <i1> [#uses=1] + br i1 %tmp265, label %cond_true266, label %cond_next270 +cond_true266: ; preds = %invcont261 + %tmp269 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %cond_next270 unwind label %cleanup329 ; <i1> [#uses=0] +cond_next270: ; preds = %cond_true266, %invcont261 + %tmp272 = add i32 %j.4, 1 ; <i32> [#uses=1] + br label %bb273 +bb273: ; preds = %cond_next270, %bb237 + %iftmp.410.1 = phi i1 [ %iftmp.410.4, %bb237 ], [ %iftmp.410.0, %cond_next270 ] ; <i1> [#uses=2] + %j.4 = phi i32 [ 0, %bb237 ], [ %tmp272, %cond_next270 ] ; <i32> [#uses=3] + %tmp276 = icmp slt i32 %j.4, %pageCopies.0 ; <i1> [#uses=1] + br i1 %tmp276, label %cond_true277, label %bb280 +cond_true277: ; preds = %bb273 + %tmp241 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) + to label %invcont240 unwind label %cleanup329 ; <i32> [#uses=1] +bb280: ; preds = %bb273 + %tmp283 = icmp eq i32 %page.4, %toPage.2 ; <i1> [#uses=1] + br i1 %tmp283, label %bb297, label %cond_next285 +cond_next285: ; preds = %bb280 + br i1 %ascending.1, label %cond_true287, label %cond_false290 +cond_true287: ; preds = %cond_next285 + %tmp289 = add i32 %page.4, 1 ; <i32> [#uses=1] + br label %cond_next293 +cond_false290: ; preds = %cond_next285 + %tmp292 = add i32 %page.4, -1 ; <i32> [#uses=1] + br label %cond_next293 +cond_next293: ; preds = %cond_false290, %cond_true287 + %page.3 = phi i32 [ %tmp289, %cond_true287 ], [ %tmp292, %cond_false290 ] ; <i32> [#uses=1] + %tmp296 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %bb237 unwind label %cleanup329 ; <i1> [#uses=0] +bb297: ; preds = %bb280 + %tmp299 = add i32 %docCopies.0, -1 ; <i32> [#uses=1] + %tmp301 = icmp sgt i32 %tmp299, %i.1 ; <i1> [#uses=1] + br i1 %tmp301, label %cond_true302, label %cond_next306 +cond_true302: ; preds = %bb297 + %tmp305 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %cond_next306 unwind label %cleanup329 ; <i1> [#uses=0] +cond_next306: ; preds = %cond_true302, %bb297 + %tmp308 = add i32 %i.1, 1 ; <i32> [#uses=1] + br label %bb309 +bb309: ; preds = %cond_next306, %cond_next234 + %iftmp.410.5 = phi i1 [ undef, %cond_next234 ], [ %iftmp.410.1, %cond_next306 ] ; <i1> [#uses=1] + %i.1 = phi i32 [ 0, %cond_next234 ], [ %tmp308, %cond_next306 ] ; <i32> [#uses=3] + %tmp312 = icmp slt i32 %i.1, %docCopies.0 ; <i1> [#uses=1] + br i1 %tmp312, label %cond_true313, label %UserCanceled +cond_true313: ; preds = %bb309 + br label %bb237 +UserCanceled: ; preds = %bb309, %bb254 + %tmp318 = icmp eq %struct.QAbstractTextDocumentLayout* %clonedDoc.1, null ; <i1> [#uses=1] + br i1 %tmp318, label %cleanup327, label %cond_true319 +cond_true319: ; preds = %UserCanceled + %tmp.upgrd.23 = getelementptr %struct.QAbstractTextDocumentLayout* %clonedDoc.1, i32 0, i32 0, i32 0 ; <i32 (...)***> [#uses=1] + %tmp.upgrd.24 = load i32 (...)*** %tmp.upgrd.23 ; <i32 (...)**> [#uses=1] + %tmp322 = getelementptr i32 (...)** %tmp.upgrd.24, i32 4 ; <i32 (...)**> [#uses=1] + %tmp.upgrd.25 = load i32 (...)** %tmp322 ; <i32 (...)*> [#uses=1] + %tmp.upgrd.26 = bitcast i32 (...)* %tmp.upgrd.25 to void (%struct.QAbstractTextDocumentLayout*)* ; <void (%struct.QAbstractTextDocumentLayout*)*> [#uses=1] + invoke void %tmp.upgrd.26( %struct.QAbstractTextDocumentLayout* %clonedDoc.1 ) + to label %cleanup327 unwind label %cleanup329 +cleanup327: ; preds = %cond_true319, %UserCanceled + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + ret void +cleanup328: ; preds = %invcont + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + ret void +cleanup329: ; preds = %cond_true319, %cond_true302, %cond_next293, %cond_true277, %cond_true266, %cond_next258, %cond_next244, %cond_next225, %cond_true220, %invcont210, %cond_next208, %cond_false204, %cond_true200, %cond_next194, %cleanup192, %cleanup192, %cleanup190, %invcont106, %invcont104, %invcont103, %invcont100, %invcont98, %invcont94, %cond_false, %invcont83, %invcont79, %invcont57, %invcont51, %invcont45, %cond_next42, %invcont37, %cond_true35, %invcont29, %invcont25, %cond_true24, %cond_next, %entry + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + unwind +} + +declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) + +declare i1 @_ZNK6QSizeF7isValidEv(%struct.QPointF*) + +declare double @_ZNK6QSizeF5widthEv(%struct.QPointF*) + +declare double @_ZNK6QSizeF6heightEv(%struct.QPointF*) + +declare double* @_ZN6QSizeF6rwidthEv(%struct.QPointF*) + +declare double* @_ZN6QSizeF7rheightEv(%struct.QPointF*) + +declare %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZN7QPointFC1Ev(%struct.QPointF*) + +declare void @_ZN7QPointFC1Edd(%struct.QPointF*, double, double) + +declare void @_ZN16QTextFrameFormat9setMarginEd(%struct.QTextBlockFormat*, double) + +declare void @_ZN6QRectFC1Edddd(%struct.QRectF*, double, double, double, double) + +declare void @_ZN6QRectFC1ERK7QPointFRK6QSizeF(%struct.QRectF*, %struct.QPointF*, %struct.QPointF*) + +declare double @_ZNK6QRectF5widthEv(%struct.QRectF*) + +declare double @_ZNK6QRectF6heightEv(%struct.QRectF*) + +declare void @_ZNK6QRectF4sizeEv(%struct.QPointF*, %struct.QRectF*) + +declare void @_ZN16QTextFrameFormatD1Ev(%struct.QTextBlockFormat*) + +declare void @_ZNK10QTextFrame11frameFormatEv(%struct.QTextBlockFormat*, %struct.QTextBlockGroup*) + +declare void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat(%struct.QTextBlockGroup*, %struct.QTextBlockFormat*) + +declare i32 @_ZNK12QPaintDevice5widthEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice6heightEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice11logicalDpiXEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice11logicalDpiYEv(%struct.QPaintDevice*) + +declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject(%struct.QAbstractTextDocumentLayout*, %struct.QObject*) + +declare void @_ZN5QFontD1Ev(%struct.QFont*) + +declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv(%struct.QAbstractTextDocumentLayout*) + +declare %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv(%struct.QAbstractTextDocumentLayout*) + +declare i32 @_ZNK13QTextDocument9pageCountEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZNK13QTextDocument11defaultFontEv(%struct.QFont*, %struct.QAbstractTextDocumentLayout*) + +declare void @_ZN13QTextDocument14setDefaultFontERK5QFont(%struct.QAbstractTextDocumentLayout*, %struct.QFont*) + +declare void @_ZN13QTextDocument11setPageSizeERK6QSizeF(%struct.QAbstractTextDocumentLayout*, %struct.QPointF*) + +declare void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF(i32, %struct.QPainter*, %struct.QAbstractTextDocumentLayout*, %struct.QRectF*, %struct.QPointF*) + +declare void @_ZN12QFontMetricsD1Ev(%struct.QFontMetrics*) + +declare void @_ZN8QPainterC1EP12QPaintDevice(%struct.QPainter*, %struct.QPaintDevice*) + +declare i1 @_ZNK8QPainter8isActiveEv(%struct.QPainter*) + +declare i32 @_Z13qt_defaultDpiv() + +declare %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZN8QPainter5scaleEdd(%struct.QPainter*, double, double) + +declare %struct.QPaintDevice* @_ZNK8QPainter6deviceEv(%struct.QPainter*) + +declare void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice(%struct.QAbstractTextDocumentLayout*, %struct.QPaintDevice*) + +declare void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice(%struct.QFontMetrics*, %struct.QFont*, %struct.QPaintDevice*) + +declare i32 @_ZNK12QFontMetrics6ascentEv(%struct.QFontMetrics*) + +declare void @_ZN5QFont12setPointSizeEi(%struct.QFont*, i32) + +declare i1 @_ZNK8QPrinter13collateCopiesEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter9numCopiesEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter8fromPageEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter6toPageEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter9pageOrderEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) + +declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) + +declare void @_ZN8QPainterD1Ev(%struct.QPainter*) diff --git a/test/Transforms/SimplifyCFG/BrUnwind.ll b/test/Transforms/SimplifyCFG/BrUnwind.ll new file mode 100644 index 0000000..b19a27d --- /dev/null +++ b/test/Transforms/SimplifyCFG/BrUnwind.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep {br label} + +define void @test(i1 %C) { + br i1 %C, label %A, label %B +A: ; preds = %0 + call void @test( i1 %C ) + br label %X +B: ; preds = %0 + call void @test( i1 %C ) + br label %X +X: ; preds = %B, %A + unwind +} + diff --git a/test/Transforms/SimplifyCFG/DeadSetCC.ll b/test/Transforms/SimplifyCFG/DeadSetCC.ll new file mode 100644 index 0000000..8339462 --- /dev/null +++ b/test/Transforms/SimplifyCFG/DeadSetCC.ll @@ -0,0 +1,28 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep {icmp eq} + +; Check that simplifycfg deletes a dead 'seteq' instruction when it +; folds a conditional branch into a switch instruction. + +declare void @foo() + +declare void @bar() + +define void @testcfg(i32 %V) { + %C = icmp eq i32 %V, 18 ; <i1> [#uses=1] + %D = icmp eq i32 %V, 180 ; <i1> [#uses=1] + %E = or i1 %C, %D ; <i1> [#uses=1] + br i1 %E, label %L1, label %Sw +Sw: ; preds = %0 + switch i32 %V, label %L1 [ + i32 15, label %L2 + i32 16, label %L2 + ] +L1: ; preds = %Sw, %0 + call void @foo( ) + ret void +L2: ; preds = %Sw, %Sw + call void @bar( ) + ret void +} + diff --git a/test/Transforms/SimplifyCFG/EqualPHIEdgeBlockMerge.ll b/test/Transforms/SimplifyCFG/EqualPHIEdgeBlockMerge.ll new file mode 100644 index 0000000..912c755 --- /dev/null +++ b/test/Transforms/SimplifyCFG/EqualPHIEdgeBlockMerge.ll @@ -0,0 +1,18 @@ +; Test merging of blocks with phi nodes. +; +; RUN: opt < %s -simplifycfg -S | not grep N: +; + +define i32 @test(i1 %a) { +Q: + br i1 %a, label %N, label %M +N: ; preds = %Q + br label %M +M: ; preds = %N, %Q + ; It's ok to merge N and M because the incoming values for W are the + ; same for both cases... + %W = phi i32 [ 2, %N ], [ 2, %Q ] ; <i32> [#uses=1] + %R = add i32 %W, 1 ; <i32> [#uses=1] + ret i32 %R +} + diff --git a/test/Transforms/SimplifyCFG/HoistCode.ll b/test/Transforms/SimplifyCFG/HoistCode.ll new file mode 100644 index 0000000..9697e56 --- /dev/null +++ b/test/Transforms/SimplifyCFG/HoistCode.ll @@ -0,0 +1,11 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +define void @foo(i1 %C, i32* %P) { + br i1 %C, label %T, label %F +T: ; preds = %0 + store i32 7, i32* %P + ret void +F: ; preds = %0 + store i32 7, i32* %P + ret void +} diff --git a/test/Transforms/SimplifyCFG/MagicPointer.ll b/test/Transforms/SimplifyCFG/MagicPointer.ll new file mode 100644 index 0000000..54e5b14 --- /dev/null +++ b/test/Transforms/SimplifyCFG/MagicPointer.ll @@ -0,0 +1,76 @@ +; Test that simplifycfg can create switch instructions from constant pointers. +; +; RUN: opt < %s -simplifycfg -S | FileCheck %s + +; CHECK: switch i64 %magicptr +; CHECK: i64 0, label +; CHECK: i64 1, label +; CHECK: i64 2, label +; CHECK: i64 3, label +; CHECK: i64 4, label +; CHECK-NOT: br +; CHECK: } + +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-apple-darwin10.0.0" + +@.str = private constant [5 x i8] c"null\00" ; <[5 x i8]*> [#uses=2] +@.str1 = private constant [4 x i8] c"one\00" ; <[4 x i8]*> [#uses=2] +@.str2 = private constant [4 x i8] c"two\00" ; <[4 x i8]*> [#uses=2] +@.str3 = private constant [5 x i8] c"four\00" ; <[5 x i8]*> [#uses=2] + +define void @f(i8* %x) nounwind ssp { +entry: + %tobool = icmp eq i8* %x, null ; <i1> [#uses=1] + br i1 %tobool, label %if.then, label %if.else + +if.then: ; preds = %entry + %call = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + br label %if.end21 + +if.else: ; preds = %entry + %cmp = icmp eq i8* %x, inttoptr (i64 1 to i8*) ; <i1> [#uses=1] + br i1 %cmp, label %if.then2, label %if.else4 + +if.then2: ; preds = %if.else + %call3 = call i32 @puts(i8* getelementptr inbounds ([4 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + br label %if.end20 + +if.else4: ; preds = %if.else + %cmp6 = icmp eq i8* %x, inttoptr (i64 2 to i8*) ; <i1> [#uses=1] + br i1 %cmp6, label %if.then9, label %lor.lhs.false + +lor.lhs.false: ; preds = %if.else4 + %cmp8 = icmp eq i8* %x, inttoptr (i64 3 to i8*) ; <i1> [#uses=1] + br i1 %cmp8, label %if.then9, label %if.else11 + +if.then9: ; preds = %lor.lhs.false, %if.else4 + %call10 = call i32 @puts(i8* getelementptr inbounds ([4 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + br label %if.end19 + +if.else11: ; preds = %lor.lhs.false + %cmp13 = icmp eq i8* %x, inttoptr (i64 4 to i8*) ; <i1> [#uses=1] + br i1 %cmp13, label %if.then14, label %if.else16 + +if.then14: ; preds = %if.else11 + %call15 = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + br label %if.end + +if.else16: ; preds = %if.else11 + %call18 = call i32 @puts(i8* %x) nounwind ; <i32> [#uses=0] + br label %if.end + +if.end: ; preds = %if.else16, %if.then14 + br label %if.end19 + +if.end19: ; preds = %if.end, %if.then9 + br label %if.end20 + +if.end20: ; preds = %if.end19, %if.then2 + br label %if.end21 + +if.end21: ; preds = %if.end20, %if.then + ret void +} + +declare i32 @puts(i8*) diff --git a/test/Transforms/SimplifyCFG/PhiBlockMerge.ll b/test/Transforms/SimplifyCFG/PhiBlockMerge.ll new file mode 100644 index 0000000..a648efd --- /dev/null +++ b/test/Transforms/SimplifyCFG/PhiBlockMerge.ll @@ -0,0 +1,22 @@ +; Test merging of blocks that only have PHI nodes in them +; +; RUN: opt < %s -simplifycfg -S | not grep N: +; + +define i32 @test(i1 %a, i1 %b) { +; <label>:0 + br i1 %a, label %M, label %O +O: ; preds = %0 + br i1 %b, label %N, label %Q +Q: ; preds = %O + br label %N +N: ; preds = %Q, %O + ; This block should be foldable into M + %Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1] + br label %M +M: ; preds = %N, %0 + %W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1] + %R = add i32 %W, 1 ; <i32> [#uses=1] + ret i32 %R +} + diff --git a/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll b/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll new file mode 100644 index 0000000..fb5d600 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll @@ -0,0 +1,27 @@ +; Test merging of blocks that only have PHI nodes in them. This tests the case +; where the mergedinto block doesn't have any PHI nodes, and is in fact +; dominated by the block-to-be-eliminated +; +; RUN: opt < %s -simplifycfg -S | not grep N: +; + +declare i1 @foo() + +define i32 @test(i1 %a, i1 %b) { + %c = call i1 @foo() + br i1 %c, label %N, label %P +P: + %d = call i1 @foo() + br i1 %d, label %N, label %Q +Q: + br label %N +N: + %W = phi i32 [0, %0], [1, %Q], [2, %P] + ; This block should be foldable into M + br label %M + +M: + %R = add i32 %W, 1 + ret i32 %R +} + diff --git a/test/Transforms/SimplifyCFG/PhiEliminate.ll b/test/Transforms/SimplifyCFG/PhiEliminate.ll new file mode 100644 index 0000000..73cf466 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PhiEliminate.ll @@ -0,0 +1,41 @@ +; Test a bunch of cases where the cfg simplification code should +; be able to fold PHI nodes into computation in common cases. Folding the PHI +; nodes away allows the branches to be eliminated, performing a simple form of +; 'if conversion'. + +; RUN: opt < %s -simplifycfg -S > %t.xform +; RUN: not grep phi %t.xform +; RUN: grep ret %t.xform + +declare void @use(i1) + +declare void @use.upgrd.1(i32) + +define void @test2(i1 %c, i1 %d, i32 %V, i32 %V2) { +; <label>:0 + br i1 %d, label %X, label %F +X: ; preds = %0 + br i1 %c, label %T, label %F +T: ; preds = %X + br label %F +F: ; preds = %T, %X, %0 + %B1 = phi i1 [ true, %0 ], [ false, %T ], [ false, %X ] ; <i1> [#uses=1] + %I7 = phi i32 [ %V, %0 ], [ %V2, %T ], [ %V2, %X ] ; <i32> [#uses=1] + call void @use( i1 %B1 ) + call void @use.upgrd.1( i32 %I7 ) + ret void +} + +define void @test(i1 %c, i32 %V, i32 %V2) { +; <label>:0 + br i1 %c, label %T, label %F +T: ; preds = %0 + br label %F +F: ; preds = %T, %0 + %B1 = phi i1 [ true, %0 ], [ false, %T ] ; <i1> [#uses=1] + %I6 = phi i32 [ %V, %0 ], [ 0, %T ] ; <i32> [#uses=1] + call void @use( i1 %B1 ) + call void @use.upgrd.1( i32 %I6 ) + ret void +} + diff --git a/test/Transforms/SimplifyCFG/PhiEliminate2.ll b/test/Transforms/SimplifyCFG/PhiEliminate2.ll new file mode 100644 index 0000000..c0f6781 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PhiEliminate2.ll @@ -0,0 +1,14 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +define i32 @test(i1 %C, i32 %V1, i32 %V2) { +entry: + br i1 %C, label %then, label %Cont +then: ; preds = %entry + %V3 = or i32 %V2, %V1 ; <i32> [#uses=1] + br label %Cont +Cont: ; preds = %then, %entry + %V4 = phi i32 [ %V1, %entry ], [ %V3, %then ] ; <i32> [#uses=0] + call i32 @test( i1 false, i32 0, i32 0 ) ; <i32>:0 [#uses=0] + ret i32 %V1 +} + diff --git a/test/Transforms/SimplifyCFG/PhiNoEliminate.ll b/test/Transforms/SimplifyCFG/PhiNoEliminate.ll new file mode 100644 index 0000000..e9902e0 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PhiNoEliminate.ll @@ -0,0 +1,27 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep select + +;; The PHI node in this example should not be turned into a select, as we are +;; not able to ifcvt the entire block. As such, converting to a select just +;; introduces inefficiency without saving copies. + +define i32 @bar(i1 %C) { +entry: + br i1 %C, label %then, label %endif +then: ; preds = %entry + %tmp.3 = call i32 @qux( ) ; <i32> [#uses=0] + br label %endif +endif: ; preds = %then, %entry + %R = phi i32 [ 123, %entry ], [ 12312, %then ] ; <i32> [#uses=1] + ;; stuff to disable tail duplication + call i32 @qux( ) ; <i32>:0 [#uses=0] + call i32 @qux( ) ; <i32>:1 [#uses=0] + call i32 @qux( ) ; <i32>:2 [#uses=0] + call i32 @qux( ) ; <i32>:3 [#uses=0] + call i32 @qux( ) ; <i32>:4 [#uses=0] + call i32 @qux( ) ; <i32>:5 [#uses=0] + call i32 @qux( ) ; <i32>:6 [#uses=0] + ret i32 %R +} + +declare i32 @qux() diff --git a/test/Transforms/SimplifyCFG/SpeculativeExec.ll b/test/Transforms/SimplifyCFG/SpeculativeExec.ll new file mode 100644 index 0000000..5cfc77c --- /dev/null +++ b/test/Transforms/SimplifyCFG/SpeculativeExec.ll @@ -0,0 +1,21 @@ +; RUN: opt < %s -simplifycfg -S | grep select +; RUN: opt < %s -simplifycfg -S | grep br | count 2 + +define i32 @t2(i32 %a, i32 %b, i32 %c) nounwind { +entry: + %tmp1 = icmp eq i32 %b, 0 + br i1 %tmp1, label %bb1, label %bb3 + +bb1: ; preds = %entry + %tmp2 = icmp sgt i32 %c, 1 + br i1 %tmp2, label %bb2, label %bb3 + +bb2: ; preds = bb1 + %tmp3 = add i32 %a, 1 + br label %bb3 + +bb3: ; preds = %bb2, %entry + %tmp4 = phi i32 [ %b, %entry ], [ %a, %bb1 ], [ %tmp3, %bb2 ] + %tmp5 = sub i32 %tmp4, 1 + ret i32 %tmp5 +} diff --git a/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll new file mode 100644 index 0000000..bf9d953 --- /dev/null +++ b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll @@ -0,0 +1,33 @@ +; The unify-function-exit-nodes pass often makes basic blocks that just contain +; a PHI node and a return. Make sure the simplify cfg can straighten out this +; important case. This is basically the most trivial form of tail-duplication. + +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep {br label} + +define i32 @test(i1 %B, i32 %A, i32 %B.upgrd.1) { + br i1 %B, label %T, label %F +T: ; preds = %0 + br label %ret +F: ; preds = %0 + br label %ret +ret: ; preds = %F, %T + %X = phi i32 [ %A, %F ], [ %B.upgrd.1, %T ] ; <i32> [#uses=1] + ret i32 %X +} + + +; Make sure it's willing to move unconditional branches to return instructions +; as well, even if the return block is shared and the source blocks are +; non-empty. +define i32 @test2(i1 %B, i32 %A, i32 %B.upgrd.2) { + br i1 %B, label %T, label %F +T: ; preds = %0 + call i32 @test( i1 true, i32 5, i32 8 ) ; <i32>:1 [#uses=0] + br label %ret +F: ; preds = %0 + call i32 @test( i1 true, i32 5, i32 8 ) ; <i32>:2 [#uses=0] + br label %ret +ret: ; preds = %F, %T + ret i32 %A +} diff --git a/test/Transforms/SimplifyCFG/UnreachableEliminate.ll b/test/Transforms/SimplifyCFG/UnreachableEliminate.ll new file mode 100644 index 0000000..7133d98 --- /dev/null +++ b/test/Transforms/SimplifyCFG/UnreachableEliminate.ll @@ -0,0 +1,33 @@ +; RUN: opt < %s -simplifycfg -S | not grep unreachable + +define void @test1(i1 %C, i1* %BP) { + br i1 %C, label %T, label %F +T: ; preds = %0 + store i1 %C, i1* %BP + unreachable +F: ; preds = %0 + ret void +} + +define void @test2() { + invoke void @test2( ) + to label %N unwind label %U +U: ; preds = %0 + unreachable +N: ; preds = %0 + ret void +} + +define i32 @test3(i32 %v) { + switch i32 %v, label %default [ + i32 1, label %U + i32 2, label %T + ] +default: ; preds = %0 + ret i32 1 +U: ; preds = %0 + unreachable +T: ; preds = %0 + ret i32 2 +} + diff --git a/test/Transforms/SimplifyCFG/basictest.ll b/test/Transforms/SimplifyCFG/basictest.ll new file mode 100644 index 0000000..83a9fa7 --- /dev/null +++ b/test/Transforms/SimplifyCFG/basictest.ll @@ -0,0 +1,59 @@ +; Test CFG simplify removal of branch instructions. +; +; RUN: opt < %s -simplifycfg -S | FileCheck %s + +define void @test1() { + br label %BB1 +BB1: ; preds = %0 + ret void +; CHECK: @test1 +; CHECK-NEXT: ret void +} + +define void @test2() { + ret void +BB1: ; No predecessors! + ret void +; CHECK: @test2 +; CHECK-NEXT: ret void +; CHECK-NEXT: } +} + +define void @test3(i1 %T) { + br i1 %T, label %BB1, label %BB1 +BB1: ; preds = %0, %0 + ret void +; CHECK: @test3 +; CHECK-NEXT: ret void +} + + +define void @test4() { + br label %return +return: + ret void +; CHECK: @test4 +; CHECK-NEXT: ret void +} +@test4g = global i8* blockaddress(@test4, %return) + + +; PR5795 +define void @test5(i32 %A) { + switch i32 %A, label %return [ + i32 2, label %bb + i32 10, label %bb1 + ] + +bb: ; preds = %entry + ret void + +bb1: ; preds = %entry + ret void + +return: ; preds = %entry + ret void +; CHECK: @test5 +; CHECK-NEXT: bb: +; CHECK-NEXT: ret void +} diff --git a/test/Transforms/SimplifyCFG/branch-branch-dbginfo.ll b/test/Transforms/SimplifyCFG/branch-branch-dbginfo.ll new file mode 100644 index 0000000..761f0d5 --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch-branch-dbginfo.ll @@ -0,0 +1,70 @@ +; RUN: opt < %s -simplifycfg -S | grep {br i1} | count 1 + +; ModuleID = '<stdin>' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" +target triple = "i386-pc-linux-gnu" + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8* } + %llvm.dbg.derivedtype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }* } + %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } + %llvm.dbg.variable.type = type { i32, { }*, i8*, { }*, i32, { }* } +@llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type { i32 393262, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str3, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str3, i32 0, i32 0), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] +@llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { i32 393216, i32 46 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 393233, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([7 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([52 x i8]* @.str2, i32 0, i32 0) }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 393216, i32 17 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] +@.str = internal constant [7 x i8] c"cond.c\00", section "llvm.metadata" ; <[7 x i8]*> [#uses=1] +@.str1 = internal constant [5 x i8] c"/tmp\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] +@.str2 = internal constant [52 x i8] c"4.2.1 (Based on Apple Inc. build 5555) (LLVM build)\00", section "llvm.metadata" ; <[52 x i8]*> [#uses=1] +@.str3 = internal constant [4 x i8] c"foo\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type { i32 393252, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str4, i32 0, i32 0), { }* null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5 }, section "llvm.metadata" ; <%llvm.dbg.basictype.type*> [#uses=1] +@.str4 = internal constant [4 x i8] c"int\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@llvm.dbg.variable = internal constant %llvm.dbg.variable.type { i32 393473, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), i8* getelementptr ([2 x i8]* @.str5, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=0] +@.str5 = internal constant [2 x i8] c"x\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] +@llvm.dbg.variable6 = internal constant %llvm.dbg.variable.type { i32 393473, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), i8* getelementptr ([2 x i8]* @.str7, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=0] +@.str7 = internal constant [2 x i8] c"y\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] +@llvm.dbg.derivedtype = internal constant %llvm.dbg.derivedtype.type { i32 393238, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([6 x i8]* @.str8, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 1, i64 0, i64 0, i64 0, i32 0, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype9 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] +@.str8 = internal constant [6 x i8] c"uint1\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@llvm.dbg.basictype9 = internal constant %llvm.dbg.basictype.type { i32 393252, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* null, i32 0, i64 8, i64 8, i64 0, i32 0, i32 7 }, section "llvm.metadata" ; <%llvm.dbg.basictype.type*> [#uses=1] + +define i32 @foo(i32 %x1, i1 zeroext %y2) nounwind { +entry: + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp4 = icmp eq i32 %x1, 0 ; <i1> [#uses=1] + br i1 %tmp4, label %bb, label %bb14 + +bb: ; preds = %entry + call void @llvm.dbg.stoppoint(i32 6, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %y2, label %bb14, label %bb10 + +bb7: ; preds = %bb + call void @llvm.dbg.stoppoint(i32 7, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp9 = call i32 @g1(i32 %x1) nounwind ; <i32> [#uses=1] + ret i32 %tmp9 + +bb10: ; preds = %bb + call void @llvm.dbg.stoppoint(i32 8, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp12 = add i32 %x1, 1 ; <i32> [#uses=1] + %tmp13 = call i32 @g2(i32 %tmp12) nounwind ; <i32> [#uses=1] + ret i32 %tmp13 + +bb14: ; preds = %entry + call void @llvm.dbg.stoppoint(i32 10, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp16 = call i32 @g1(i32 %x1) nounwind ; <i32> [#uses=1] + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) + ret i32 %tmp16 +} + +declare void @llvm.dbg.func.start({ }*) nounwind + +declare void @llvm.dbg.declare({ }*, { }*) nounwind + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +declare i32 @g1(i32) + +declare i32 @g2(i32) + +declare void @llvm.dbg.region.end({ }*) nounwind diff --git a/test/Transforms/SimplifyCFG/branch-cond-merge.ll b/test/Transforms/SimplifyCFG/branch-cond-merge.ll new file mode 100644 index 0000000..f73e01c --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch-cond-merge.ll @@ -0,0 +1,19 @@ +; RUN: opt < %s -simplifycfg -instcombine \ +; RUN: -simplifycfg -S | not grep call + +declare void @bar() + +define void @test(i32 %X, i32 %Y) { +entry: + %tmp.2 = icmp ne i32 %X, %Y ; <i1> [#uses=1] + br i1 %tmp.2, label %shortcirc_next, label %UnifiedReturnBlock +shortcirc_next: ; preds = %entry + %tmp.3 = icmp ne i32 %X, %Y ; <i1> [#uses=1] + br i1 %tmp.3, label %UnifiedReturnBlock, label %then +then: ; preds = %shortcirc_next + call void @bar( ) + ret void +UnifiedReturnBlock: ; preds = %shortcirc_next, %entry + ret void +} + diff --git a/test/Transforms/SimplifyCFG/branch-cond-prop.ll b/test/Transforms/SimplifyCFG/branch-cond-prop.ll new file mode 100644 index 0000000..448934e --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch-cond-prop.ll @@ -0,0 +1,17 @@ +; RUN: opt < %s -simplifycfg -S | not grep call + +declare void @bar() + +define void @test(i32 %X, i32 %Y) { +entry: + %tmp.2 = icmp slt i32 %X, %Y ; <i1> [#uses=2] + br i1 %tmp.2, label %shortcirc_next, label %UnifiedReturnBlock +shortcirc_next: ; preds = %entry + br i1 %tmp.2, label %UnifiedReturnBlock, label %then +then: ; preds = %shortcirc_next + call void @bar( ) + ret void +UnifiedReturnBlock: ; preds = %shortcirc_next, %entry + ret void +} + diff --git a/test/Transforms/SimplifyCFG/branch-fold-test.ll b/test/Transforms/SimplifyCFG/branch-fold-test.ll new file mode 100644 index 0000000..460f245 --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch-fold-test.ll @@ -0,0 +1,17 @@ +; This test ensures that the simplifycfg pass continues to constant fold +; terminator instructions. + +; RUN: opt < %s -simplifycfg -S | not grep br + +define i32 @test(i32 %A, i32 %B) { +J: + %C = add i32 %A, 12 ; <i32> [#uses=2] + br i1 true, label %L, label %K +L: ; preds = %J + %D = add i32 %C, %B ; <i32> [#uses=1] + ret i32 %D +K: ; preds = %J + %E = add i32 %C, %B ; <i32> [#uses=1] + ret i32 %E +} + diff --git a/test/Transforms/SimplifyCFG/branch-fold.ll b/test/Transforms/SimplifyCFG/branch-fold.ll new file mode 100644 index 0000000..266609b5 --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch-fold.ll @@ -0,0 +1,13 @@ +; RUN: opt < %s -simplifycfg -S | grep {br i1} | count 1 + +define void @test(i32* %P, i32* %Q, i1 %A, i1 %B) { + br i1 %A, label %a, label %b +a: ; preds = %0 + br i1 %B, label %b, label %c +b: ; preds = %a, %0 + store i32 123, i32* %P + ret void +c: ; preds = %a + ret void +} + diff --git a/test/Transforms/SimplifyCFG/branch-phi-thread.ll b/test/Transforms/SimplifyCFG/branch-phi-thread.ll new file mode 100644 index 0000000..f52d979 --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch-phi-thread.ll @@ -0,0 +1,66 @@ +; RUN: opt < %s -simplifycfg -adce -S | \ +; RUN: not grep {call void @f1} +; END. + +declare void @f1() + +declare void @f2() + +declare void @f3() + +declare void @f4() + +define i32 @test1(i32 %X, i1 %D) { +E: + %C = icmp eq i32 %X, 0 ; <i1> [#uses=2] + br i1 %C, label %T, label %F +T: ; preds = %A, %E + br i1 %C, label %B, label %A +A: ; preds = %T + call void @f1( ) + br i1 %D, label %T, label %F +B: ; preds = %T + call void @f2( ) + ret i32 345 +F: ; preds = %A, %E + call void @f3( ) + ret i32 123 +} + +define i32 @test2(i32 %X, i1 %D) { +E: + %C = icmp eq i32 %X, 0 ; <i1> [#uses=2] + br i1 %C, label %T, label %F +T: ; preds = %A, %E + %P = phi i1 [ true, %E ], [ %C, %A ] ; <i1> [#uses=1] + br i1 %P, label %B, label %A +A: ; preds = %T + call void @f1( ) + br i1 %D, label %T, label %F +B: ; preds = %T + call void @f2( ) + ret i32 345 +F: ; preds = %A, %E + call void @f3( ) + ret i32 123 +} + +define i32 @test3(i32 %X, i1 %D, i32* %AP, i32* %BP) { +E: + %C = icmp eq i32 %X, 0 ; <i1> [#uses=2] + br i1 %C, label %T, label %F +T: ; preds = %A, %E + call void @f3( ) + %XX = load i32* %AP ; <i32> [#uses=1] + store i32 %XX, i32* %BP + br i1 %C, label %B, label %A +A: ; preds = %T + call void @f1( ) + br i1 %D, label %T, label %F +B: ; preds = %T + call void @f2( ) + ret i32 345 +F: ; preds = %A, %E + call void @f3( ) + ret i32 123 +} diff --git a/test/Transforms/SimplifyCFG/branch_fold_dbg.ll b/test/Transforms/SimplifyCFG/branch_fold_dbg.ll new file mode 100644 index 0000000..6a500de --- /dev/null +++ b/test/Transforms/SimplifyCFG/branch_fold_dbg.ll @@ -0,0 +1,122 @@ +; RUN: opt < %s -simplifycfg -S | not grep br +; END. + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" + +@.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + + +define void @main() { +entry: +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.14.i19 = icmp eq i32 0, 2 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.14.i19, label %endif.1.i20, label %read_min.exit +endif.1.i20: ; preds = %entry +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.9.i.i = icmp eq i8* null, null ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.9.i.i, label %then.i12.i, label %then.i.i +then.i.i: ; preds = %endif.1.i20 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +then.i12.i: ; preds = %endif.1.i20 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.9.i4.i = icmp eq i8* null, null ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.9.i4.i, label %endif.2.i33, label %then.i5.i +then.i5.i: ; preds = %then.i12.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +endif.2.i33: ; preds = %then.i12.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %loopexit.0.i40, label %no_exit.0.i35 +no_exit.0.i35: ; preds = %no_exit.0.i35, %endif.2.i33 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.130.i = icmp slt i32 0, 0 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.130.i, label %loopexit.0.i40.loopexit, label %no_exit.0.i35 +loopexit.0.i40.loopexit: ; preds = %no_exit.0.i35 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %loopexit.0.i40 +loopexit.0.i40: ; preds = %loopexit.0.i40.loopexit, %endif.2.i33 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.341.i = icmp eq i32 0, 0 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.341.i, label %loopentry.1.i, label %read_min.exit +loopentry.1.i: ; preds = %loopexit.0.i40 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.347.i = icmp sgt i32 0, 0 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.347.i, label %no_exit.1.i41, label %loopexit.2.i44 +no_exit.1.i41: ; preds = %endif.5.i, %loopentry.1.i + %indvar.i42 = phi i32 [ %indvar.next.i, %endif.5.i ], [ 0, %loopentry.1.i ] ; <i32> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.355.i = icmp eq i32 0, 3 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.355.i, label %endif.5.i, label %read_min.exit +endif.5.i: ; preds = %no_exit.1.i41 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.34773.i = icmp sgt i32 0, 0 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %indvar.next.i = add i32 %indvar.i42, 1 ; <i32> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.34773.i, label %no_exit.1.i41, label %loopexit.1.i.loopexit +loopexit.1.i.loopexit: ; preds = %endif.5.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +loopexit.2.i44: ; preds = %loopentry.1.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +read_min.exit: ; preds = %no_exit.1.i41, %loopexit.0.i40, %entry +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.23 = icmp eq i32 0, 0 ; <i1> [#uses=1] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 %tmp.23, label %endif.1, label %then.1 +then.1: ; preds = %read_min.exit +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %endif.0.i, label %then.0.i +then.0.i: ; preds = %then.1 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %endif.1.i, label %then.1.i +endif.0.i: ; preds = %then.1 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %endif.1.i, label %then.1.i +then.1.i: ; preds = %endif.0.i, %then.0.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %getfree.exit, label %then.2.i +endif.1.i: ; preds = %endif.0.i, %then.0.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %getfree.exit, label %then.2.i +then.2.i: ; preds = %endif.1.i, %then.1.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +getfree.exit: ; preds = %endif.1.i, %then.1.i +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +endif.1: ; preds = %read_min.exit +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.27.i = getelementptr i32* null, i32 0 ; <i32*> [#uses=0] +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %loopexit.0.i15, label %no_exit.0.i14 +no_exit.0.i14: ; preds = %endif.1 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +loopexit.0.i15: ; preds = %endif.1 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %primal_start_artificial.exit, label %no_exit.1.i16 +no_exit.1.i16: ; preds = %no_exit.1.i16, %loopexit.0.i15 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br i1 false, label %primal_start_artificial.exit, label %no_exit.1.i16 +primal_start_artificial.exit: ; preds = %no_exit.1.i16, %loopexit.0.i15 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void +} diff --git a/test/Transforms/SimplifyCFG/dbginfo.ll b/test/Transforms/SimplifyCFG/dbginfo.ll new file mode 100644 index 0000000..1a9f20a --- /dev/null +++ b/test/Transforms/SimplifyCFG/dbginfo.ll @@ -0,0 +1,71 @@ +; RUN: opt < %s -simplifycfg -S | not grep "br label" + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + %llvm.dbg.composite.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }*, { }* } + %llvm.dbg.derivedtype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }* } + %llvm.dbg.global_variable.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1, { }* } + %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } + %llvm.dbg.subrange.type = type { i32, i64, i64 } + %struct.Group = type { %struct.Scene, %struct.Sphere, %"struct.std::list<Scene*,std::allocator<Scene*> >" } + %struct.Ray = type { %struct.Vec, %struct.Vec } + %struct.Scene = type { i32 (...)** } + %struct.Sphere = type { %struct.Scene, %struct.Vec, double } + %struct.Vec = type { double, double, double } + %struct.__class_type_info_pseudo = type { %struct.__type_info_pseudo } + %struct.__false_type = type <{ i8 }> + %"struct.__gnu_cxx::new_allocator<Scene*>" = type <{ i8 }> + %"struct.__gnu_cxx::new_allocator<std::_List_node<Scene*> >" = type <{ i8 }> + %struct.__si_class_type_info_pseudo = type { %struct.__type_info_pseudo, %"struct.std::type_info"* } + %struct.__type_info_pseudo = type { i8*, i8* } + %"struct.std::Hit" = type { double, %struct.Vec } + %"struct.std::_List_base<Scene*,std::allocator<Scene*> >" = type { %"struct.std::_List_base<Scene*,std::allocator<Scene*> >::_List_impl" } + %"struct.std::_List_base<Scene*,std::allocator<Scene*> >::_List_impl" = type { %"struct.std::_List_node_base" } + %"struct.std::_List_const_iterator<Scene*>" = type { %"struct.std::_List_node_base"* } + %"struct.std::_List_iterator<Scene*>" = type { %"struct.std::_List_node_base"* } + %"struct.std::_List_node<Scene*>" = type { %"struct.std::_List_node_base", %struct.Scene* } + %"struct.std::_List_node_base" = type { %"struct.std::_List_node_base"*, %"struct.std::_List_node_base"* } + %"struct.std::allocator<Scene*>" = type <{ i8 }> + %"struct.std::allocator<std::_List_node<Scene*> >" = type <{ i8 }> + %"struct.std::basic_ios<char,std::char_traits<char> >" = type { %"struct.std::ios_base", %"struct.std::basic_ostream<char,std::char_traits<char> >"*, i8, i8, %"struct.std::basic_streambuf<char,std::char_traits<char> >"*, %"struct.std::ctype<char>"*, %"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >"*, %"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >"* } + %"struct.std::basic_ostream<char,std::char_traits<char> >" = type { i32 (...)**, %"struct.std::basic_ios<char,std::char_traits<char> >" } + %"struct.std::basic_streambuf<char,std::char_traits<char> >" = type { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, %"struct.std::locale" } + %"struct.std::ctype<char>" = type { %"struct.std::locale::facet", i32*, i8, i32*, i32*, i32*, i8, [256 x i8], [256 x i8], i8 } + %"struct.std::ios_base" = type { i32 (...)**, i32, i32, i32, i32, i32, %"struct.std::ios_base::_Callback_list"*, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, %"struct.std::ios_base::_Words"*, %"struct.std::locale" } + %"struct.std::ios_base::Init" = type <{ i8 }> + %"struct.std::ios_base::_Callback_list" = type { %"struct.std::ios_base::_Callback_list"*, void (i32, %"struct.std::ios_base"*, i32)*, i32, i32 } + %"struct.std::ios_base::_Words" = type { i8*, i32 } + %"struct.std::list<Scene*,std::allocator<Scene*> >" = type { %"struct.std::_List_base<Scene*,std::allocator<Scene*> >" } + %"struct.std::locale" = type { %"struct.std::locale::_Impl"* } + %"struct.std::locale::_Impl" = type { i32, %"struct.std::locale::facet"**, i32, %"struct.std::locale::facet"**, i8** } + %"struct.std::locale::facet" = type { i32 (...)**, i32 } + %"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >" = type { %"struct.std::locale::facet" } + %"struct.std::num_put<char,std::ostreambuf_iterator<char, std::char_traits<char> > >" = type { %"struct.std::locale::facet" } + %"struct.std::numeric_limits<double>" = type <{ i8 }> + %"struct.std::type_info" = type { i32 (...)**, i8* } +@llvm.dbg.subprogram947 = external constant %llvm.dbg.subprogram.type ; <%llvm.dbg.subprogram.type*> [#uses=1] + +declare void @llvm.dbg.func.start({ }*) nounwind + +declare void @llvm.dbg.region.end({ }*) nounwind + +declare void @_ZN9__gnu_cxx13new_allocatorIP5SceneED2Ev(%struct.__false_type*) nounwind + +define void @_ZNSaIP5SceneED1Ev(%struct.__false_type* %this) nounwind { +entry: + %this_addr = alloca %struct.__false_type* ; <%struct.__false_type**> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram947 to { }*)) + store %struct.__false_type* %this, %struct.__false_type** %this_addr + %0 = load %struct.__false_type** %this_addr, align 4 ; <%struct.__false_type*> [#uses=1] + call void @_ZN9__gnu_cxx13new_allocatorIP5SceneED2Ev(%struct.__false_type* %0) nounwind + br label %bb + +bb: ; preds = %entry + br label %return + +return: ; preds = %bb + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram947 to { }*)) + ret void +} diff --git a/test/Transforms/SimplifyCFG/dg.exp b/test/Transforms/SimplifyCFG/dg.exp new file mode 100644 index 0000000..f200589 --- /dev/null +++ b/test/Transforms/SimplifyCFG/dg.exp @@ -0,0 +1,3 @@ +load_lib llvm.exp + +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/SimplifyCFG/duplicate-phis.ll b/test/Transforms/SimplifyCFG/duplicate-phis.ll new file mode 100644 index 0000000..5129f9f --- /dev/null +++ b/test/Transforms/SimplifyCFG/duplicate-phis.ll @@ -0,0 +1,21 @@ +; RUN: opt < %s -instcombine -simplifycfg -S | grep { = phi } | count 1 + +; instcombine should sort the PHI operands so that simplifycfg can see the +; duplicate and remove it. + +define i32 @foo(i1 %t) { +entry: + call void @bar() + br i1 %t, label %true, label %false +true: + call void @bar() + br label %false +false: + %a = phi i32 [ 2, %true ], [ 5, %entry ] + %b = phi i32 [ 5, %entry ], [ 2, %true ] + call void @bar() + %c = add i32 %a, %b + ret i32 %c +} + +declare void @bar() diff --git a/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll b/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll new file mode 100644 index 0000000..6fbbb1b --- /dev/null +++ b/test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll @@ -0,0 +1,33 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" + +@.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +declare void @bar(i32) + +define void @test(i1 %P, i32* %Q) { + br i1 %P, label %T, label %F +T: ; preds = %0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + store i32 1, i32* %Q + %A = load i32* %Q ; <i32> [#uses=1] + call void @bar( i32 %A ) + ret void +F: ; preds = %0 + store i32 1, i32* %Q +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %B = load i32* %Q ; <i32> [#uses=1] + call void @bar( i32 %B ) + ret void +} + diff --git a/test/Transforms/SimplifyCFG/hoist-common-code.ll b/test/Transforms/SimplifyCFG/hoist-common-code.ll new file mode 100644 index 0000000..5c83e2a --- /dev/null +++ b/test/Transforms/SimplifyCFG/hoist-common-code.ll @@ -0,0 +1,18 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +declare void @bar(i32) + +define void @test(i1 %P, i32* %Q) { + br i1 %P, label %T, label %F +T: ; preds = %0 + store i32 1, i32* %Q + %A = load i32* %Q ; <i32> [#uses=1] + call void @bar( i32 %A ) + ret void +F: ; preds = %0 + store i32 1, i32* %Q + %B = load i32* %Q ; <i32> [#uses=1] + call void @bar( i32 %B ) + ret void +} + diff --git a/test/Transforms/SimplifyCFG/invoke_unwind.ll b/test/Transforms/SimplifyCFG/invoke_unwind.ll new file mode 100644 index 0000000..bbd779b --- /dev/null +++ b/test/Transforms/SimplifyCFG/invoke_unwind.ll @@ -0,0 +1,33 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s + +declare void @bar() + +; This testcase checks to see if the simplifycfg pass is converting invoke +; instructions to call instructions if the handler just rethrows the exception. +define i32 @test1() { +; CHECK: @test1 +; CHECK-NEXT: call void @bar() +; CHECK-NEXT: ret i32 0 + invoke void @bar( ) + to label %Ok unwind label %Rethrow +Ok: ; preds = %0 + ret i32 0 +Rethrow: ; preds = %0 + unwind +} + + +; Verify that simplifycfg isn't duplicating 'unwind' instructions. Doing this +; is bad because it discourages commoning. +define i32 @test2(i1 %c) { +; CHECK: @test2 +; CHECK: T: +; CHECK-NEXT: call void @bar() +; CHECK-NEXT: br label %F + br i1 %c, label %T, label %F +T: + call void @bar() + br label %F +F: + unwind +} diff --git a/test/Transforms/SimplifyCFG/iterative-simplify.ll b/test/Transforms/SimplifyCFG/iterative-simplify.ll new file mode 100644 index 0000000..a397411 --- /dev/null +++ b/test/Transforms/SimplifyCFG/iterative-simplify.ll @@ -0,0 +1,100 @@ +; RUN: opt < %s -simplifycfg -S | not grep bb17 +; PR1786 + +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; <i32*> [#uses=1] + %i = alloca i32, align 4 ; <i32*> [#uses=7] + %z = alloca i32, align 4 ; <i32*> [#uses=4] + %z16 = alloca i32, align 4 ; <i32*> [#uses=4] + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + store i32 0, i32* %i + %toBool = icmp ne i8 1, 0 ; <i1> [#uses=1] + br i1 %toBool, label %cond_true, label %cond_false + +cond_true: ; preds = %entry + store i32 0, i32* %z + br label %bb + +bb: ; preds = %cond_next, %cond_true + %tmp = load i32* %z ; <i32> [#uses=1] + %tmp1 = sub i32 %tmp, 16384 ; <i32> [#uses=1] + store i32 %tmp1, i32* %z + %tmp2 = load i32* %i ; <i32> [#uses=1] + %tmp3 = add i32 %tmp2, 1 ; <i32> [#uses=1] + store i32 %tmp3, i32* %i + %tmp4 = load i32* %i ; <i32> [#uses=1] + %tmp5 = icmp sgt i32 %tmp4, 262144 ; <i1> [#uses=1] + %tmp56 = zext i1 %tmp5 to i8 ; <i8> [#uses=1] + %toBool7 = icmp ne i8 %tmp56, 0 ; <i1> [#uses=1] + br i1 %toBool7, label %cond_true8, label %cond_next + +cond_true8: ; preds = %bb + call void @abort( ) + unreachable + +cond_next: ; preds = %bb + %tmp9 = load i32* %z ; <i32> [#uses=1] + %tmp10 = icmp ne i32 %tmp9, 0 ; <i1> [#uses=1] + %tmp1011 = zext i1 %tmp10 to i8 ; <i8> [#uses=1] + %toBool12 = icmp ne i8 %tmp1011, 0 ; <i1> [#uses=1] + br i1 %toBool12, label %bb, label %bb13 + +bb13: ; preds = %cond_next + call void @exit( i32 0 ) + unreachable + +cond_false: ; preds = %entry + %toBool14 = icmp ne i8 1, 0 ; <i1> [#uses=1] + br i1 %toBool14, label %cond_true15, label %cond_false33 + +cond_true15: ; preds = %cond_false + store i32 0, i32* %z16 + br label %bb17 + +bb17: ; preds = %cond_next27, %cond_true15 + %tmp18 = load i32* %z16 ; <i32> [#uses=1] + %tmp19 = sub i32 %tmp18, 16384 ; <i32> [#uses=1] + store i32 %tmp19, i32* %z16 + %tmp20 = load i32* %i ; <i32> [#uses=1] + %tmp21 = add i32 %tmp20, 1 ; <i32> [#uses=1] + store i32 %tmp21, i32* %i + %tmp22 = load i32* %i ; <i32> [#uses=1] + %tmp23 = icmp sgt i32 %tmp22, 262144 ; <i1> [#uses=1] + %tmp2324 = zext i1 %tmp23 to i8 ; <i8> [#uses=1] + %toBool25 = icmp ne i8 %tmp2324, 0 ; <i1> [#uses=1] + br i1 %toBool25, label %cond_true26, label %cond_next27 + +cond_true26: ; preds = %bb17 + call void @abort( ) + unreachable + +cond_next27: ; preds = %bb17 + %tmp28 = load i32* %z16 ; <i32> [#uses=1] + %tmp29 = icmp ne i32 %tmp28, 0 ; <i1> [#uses=1] + %tmp2930 = zext i1 %tmp29 to i8 ; <i8> [#uses=1] + %toBool31 = icmp ne i8 %tmp2930, 0 ; <i1> [#uses=1] + br i1 %toBool31, label %bb17, label %bb32 + +bb32: ; preds = %cond_next27 + call void @exit( i32 0 ) + unreachable + +cond_false33: ; preds = %cond_false + call void @exit( i32 0 ) + unreachable + +cond_next34: ; No predecessors! + br label %cond_next35 + +cond_next35: ; preds = %cond_next34 + br label %return + +return: ; preds = %cond_next35 + %retval36 = load i32* %retval ; <i32> [#uses=1] + ret i32 %retval36 +} + +declare void @abort() + +declare void @exit(i32) diff --git a/test/Transforms/SimplifyCFG/noreturn-call.ll b/test/Transforms/SimplifyCFG/noreturn-call.ll new file mode 100644 index 0000000..b454778 --- /dev/null +++ b/test/Transforms/SimplifyCFG/noreturn-call.ll @@ -0,0 +1,11 @@ +; RUN: opt < %s -simplifycfg -S | grep unreachable +; PR1796 + +declare void @Finisher(i32) noreturn + +define void @YYY(i32) { + tail call void @Finisher(i32 %0) noreturn + tail call void @Finisher(i32 %0) noreturn + ret void +} + diff --git a/test/Transforms/SimplifyCFG/return-merge.ll b/test/Transforms/SimplifyCFG/return-merge.ll new file mode 100644 index 0000000..977b6df --- /dev/null +++ b/test/Transforms/SimplifyCFG/return-merge.ll @@ -0,0 +1,19 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +define i32 @test1(i1 %C) { +entry: + br i1 %C, label %T, label %F +T: ; preds = %entry + ret i32 1 +F: ; preds = %entry + ret i32 0 +} + +define void @test2(i1 %C) { + br i1 %C, label %T, label %F +T: ; preds = %0 + ret void +F: ; preds = %0 + ret void +} + diff --git a/test/Transforms/SimplifyCFG/switch-simplify-crash.ll b/test/Transforms/SimplifyCFG/switch-simplify-crash.ll new file mode 100644 index 0000000..bbc0bd7 --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch-simplify-crash.ll @@ -0,0 +1,108 @@ +; RUN: opt < %s -simplifycfg -disable-output + +define void @NewExtractNames() { +entry: + br i1 false, label %endif.0, label %then.0 +then.0: ; preds = %entry + br i1 false, label %shortcirc_next.i, label %shortcirc_done.i +shortcirc_next.i: ; preds = %then.0 + br label %shortcirc_done.i +shortcirc_done.i: ; preds = %shortcirc_next.i, %then.0 + br i1 false, label %then.0.i, label %else.0.i +then.0.i: ; preds = %shortcirc_done.i + br label %NewBase.exit +else.0.i: ; preds = %shortcirc_done.i + br i1 false, label %endif.0.i, label %else.1.i +else.1.i: ; preds = %else.0.i + br i1 false, label %endif.0.i, label %else.2.i +else.2.i: ; preds = %else.1.i + br label %NewBase.exit +endif.0.i: ; preds = %else.1.i, %else.0.i + br label %NewBase.exit +NewBase.exit: ; preds = %endif.0.i, %else.2.i, %then.0.i + br label %endif.0 +endif.0: ; preds = %NewBase.exit, %entry + %tmp.32.mask = and i32 0, 31 ; <i32> [#uses=1] + switch i32 %tmp.32.mask, label %label.9 [ + i32 16, label %loopentry.2 + i32 15, label %loopentry.2 + i32 14, label %loopentry.2 + i32 13, label %loopentry.2 + i32 10, label %loopentry.2 + i32 20, label %loopentry.1 + i32 19, label %loopentry.1 + i32 2, label %loopentry.0 + i32 0, label %switchexit + ] +loopentry.0: ; preds = %endif.1, %endif.0 + br i1 false, label %no_exit.0, label %switchexit +no_exit.0: ; preds = %loopentry.0 + br i1 false, label %then.1, label %else.1 +then.1: ; preds = %no_exit.0 + br label %endif.1 +else.1: ; preds = %no_exit.0 + br i1 false, label %shortcirc_next.0, label %shortcirc_done.0 +shortcirc_next.0: ; preds = %else.1 + br label %shortcirc_done.0 +shortcirc_done.0: ; preds = %shortcirc_next.0, %else.1 + br i1 false, label %then.2, label %endif.2 +then.2: ; preds = %shortcirc_done.0 + br label %endif.2 +endif.2: ; preds = %then.2, %shortcirc_done.0 + br label %endif.1 +endif.1: ; preds = %endif.2, %then.1 + br label %loopentry.0 +loopentry.1: ; preds = %endif.3, %endif.0, %endif.0 + br i1 false, label %no_exit.1, label %switchexit +no_exit.1: ; preds = %loopentry.1 + br i1 false, label %then.3, label %else.2 +then.3: ; preds = %no_exit.1 + br label %endif.3 +else.2: ; preds = %no_exit.1 + br i1 false, label %shortcirc_next.1, label %shortcirc_done.1 +shortcirc_next.1: ; preds = %else.2 + br label %shortcirc_done.1 +shortcirc_done.1: ; preds = %shortcirc_next.1, %else.2 + br i1 false, label %then.4, label %endif.4 +then.4: ; preds = %shortcirc_done.1 + br label %endif.4 +endif.4: ; preds = %then.4, %shortcirc_done.1 + br label %endif.3 +endif.3: ; preds = %endif.4, %then.3 + br label %loopentry.1 +loopentry.2: ; preds = %endif.5, %endif.0, %endif.0, %endif.0, %endif.0, %endif.0 + %i.3 = phi i32 [ 0, %endif.5 ], [ 0, %endif.0 ], [ 0, %endif.0 ], [ 0, %endif.0 ], [ 0, %endif.0 ], [ 0, %endif.0 ] ; <i32> [#uses=1] + %tmp.158 = icmp slt i32 %i.3, 0 ; <i1> [#uses=1] + br i1 %tmp.158, label %no_exit.2, label %switchexit +no_exit.2: ; preds = %loopentry.2 + br i1 false, label %shortcirc_next.2, label %shortcirc_done.2 +shortcirc_next.2: ; preds = %no_exit.2 + br label %shortcirc_done.2 +shortcirc_done.2: ; preds = %shortcirc_next.2, %no_exit.2 + br i1 false, label %then.5, label %endif.5 +then.5: ; preds = %shortcirc_done.2 + br label %endif.5 +endif.5: ; preds = %then.5, %shortcirc_done.2 + br label %loopentry.2 +label.9: ; preds = %endif.0 + br i1 false, label %then.6, label %endif.6 +then.6: ; preds = %label.9 + br label %endif.6 +endif.6: ; preds = %then.6, %label.9 + store i32 0, i32* null + br label %switchexit +switchexit: ; preds = %endif.6, %loopentry.2, %loopentry.1, %loopentry.0, %endif.0 + br i1 false, label %endif.7, label %then.7 +then.7: ; preds = %switchexit + br i1 false, label %shortcirc_next.3, label %shortcirc_done.3 +shortcirc_next.3: ; preds = %then.7 + br label %shortcirc_done.3 +shortcirc_done.3: ; preds = %shortcirc_next.3, %then.7 + br i1 false, label %then.8, label %endif.8 +then.8: ; preds = %shortcirc_done.3 + br label %endif.8 +endif.8: ; preds = %then.8, %shortcirc_done.3 + br label %endif.7 +endif.7: ; preds = %endif.8, %switchexit + ret void +} diff --git a/test/Transforms/SimplifyCFG/switch_create.ll b/test/Transforms/SimplifyCFG/switch_create.ll new file mode 100644 index 0000000..9b3aaf7 --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch_create.ll @@ -0,0 +1,47 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +declare void @foo1() + +declare void @foo2() + +define void @test1(i32 %V) { + %C1 = icmp eq i32 %V, 4 ; <i1> [#uses=1] + %C2 = icmp eq i32 %V, 17 ; <i1> [#uses=1] + %CN = or i1 %C1, %C2 ; <i1> [#uses=1] + br i1 %CN, label %T, label %F +T: ; preds = %0 + call void @foo1( ) + ret void +F: ; preds = %0 + call void @foo2( ) + ret void +} + +define void @test2(i32 %V) { + %C1 = icmp ne i32 %V, 4 ; <i1> [#uses=1] + %C2 = icmp ne i32 %V, 17 ; <i1> [#uses=1] + %CN = and i1 %C1, %C2 ; <i1> [#uses=1] + br i1 %CN, label %T, label %F +T: ; preds = %0 + call void @foo1( ) + ret void +F: ; preds = %0 + call void @foo2( ) + ret void +} + +define void @test3(i32 %V) { + %C1 = icmp eq i32 %V, 4 ; <i1> [#uses=1] + br i1 %C1, label %T, label %N +N: ; preds = %0 + %C2 = icmp eq i32 %V, 17 ; <i1> [#uses=1] + br i1 %C2, label %T, label %F +T: ; preds = %N, %0 + call void @foo1( ) + ret void +F: ; preds = %N + call void @foo2( ) + ret void +} + + diff --git a/test/Transforms/SimplifyCFG/switch_formation.dbg.ll b/test/Transforms/SimplifyCFG/switch_formation.dbg.ll new file mode 100644 index 0000000..f1c820e --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch_formation.dbg.ll @@ -0,0 +1,48 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" + +@.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +define i1 @_ZN4llvm11SetCondInst7classofEPKNS_11InstructionE({ i32, i32 }* %I) { +entry: + %tmp.1.i = getelementptr { i32, i32 }* %I, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp.2.i = load i32* %tmp.1.i ; <i32> [#uses=6] + %tmp.2 = icmp eq i32 %tmp.2.i, 14 ; <i1> [#uses=1] + br i1 %tmp.2, label %shortcirc_done.4, label %shortcirc_next.0 +shortcirc_next.0: ; preds = %entry +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.6 = icmp eq i32 %tmp.2.i, 15 ; <i1> [#uses=1] + br i1 %tmp.6, label %shortcirc_done.4, label %shortcirc_next.1 +shortcirc_next.1: ; preds = %shortcirc_next.0 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.11 = icmp eq i32 %tmp.2.i, 16 ; <i1> [#uses=1] + br i1 %tmp.11, label %shortcirc_done.4, label %shortcirc_next.2 +shortcirc_next.2: ; preds = %shortcirc_next.1 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.16 = icmp eq i32 %tmp.2.i, 17 ; <i1> [#uses=1] + br i1 %tmp.16, label %shortcirc_done.4, label %shortcirc_next.3 +shortcirc_next.3: ; preds = %shortcirc_next.2 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.21 = icmp eq i32 %tmp.2.i, 18 ; <i1> [#uses=1] + br i1 %tmp.21, label %shortcirc_done.4, label %shortcirc_next.4 +shortcirc_next.4: ; preds = %shortcirc_next.3 +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp.26 = icmp eq i32 %tmp.2.i, 19 ; <i1> [#uses=1] + br label %UnifiedReturnBlock +shortcirc_done.4: ; preds = %shortcirc_next.3, %shortcirc_next.2, %shortcirc_next.1, %shortcirc_next.0, %entry + br label %UnifiedReturnBlock +UnifiedReturnBlock: ; preds = %shortcirc_done.4, %shortcirc_next.4 + %UnifiedRetVal = phi i1 [ %tmp.26, %shortcirc_next.4 ], [ true, %shortcirc_done.4 ] ; <i1> [#uses=1] + ret i1 %UnifiedRetVal +} + diff --git a/test/Transforms/SimplifyCFG/switch_formation.ll b/test/Transforms/SimplifyCFG/switch_formation.ll new file mode 100644 index 0000000..787904a --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch_formation.ll @@ -0,0 +1,30 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +define i1 @_ZN4llvm11SetCondInst7classofEPKNS_11InstructionE({ i32, i32 }* %I) { +entry: + %tmp.1.i = getelementptr { i32, i32 }* %I, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp.2.i = load i32* %tmp.1.i ; <i32> [#uses=6] + %tmp.2 = icmp eq i32 %tmp.2.i, 14 ; <i1> [#uses=1] + br i1 %tmp.2, label %shortcirc_done.4, label %shortcirc_next.0 +shortcirc_next.0: ; preds = %entry + %tmp.6 = icmp eq i32 %tmp.2.i, 15 ; <i1> [#uses=1] + br i1 %tmp.6, label %shortcirc_done.4, label %shortcirc_next.1 +shortcirc_next.1: ; preds = %shortcirc_next.0 + %tmp.11 = icmp eq i32 %tmp.2.i, 16 ; <i1> [#uses=1] + br i1 %tmp.11, label %shortcirc_done.4, label %shortcirc_next.2 +shortcirc_next.2: ; preds = %shortcirc_next.1 + %tmp.16 = icmp eq i32 %tmp.2.i, 17 ; <i1> [#uses=1] + br i1 %tmp.16, label %shortcirc_done.4, label %shortcirc_next.3 +shortcirc_next.3: ; preds = %shortcirc_next.2 + %tmp.21 = icmp eq i32 %tmp.2.i, 18 ; <i1> [#uses=1] + br i1 %tmp.21, label %shortcirc_done.4, label %shortcirc_next.4 +shortcirc_next.4: ; preds = %shortcirc_next.3 + %tmp.26 = icmp eq i32 %tmp.2.i, 19 ; <i1> [#uses=1] + br label %UnifiedReturnBlock +shortcirc_done.4: ; preds = %shortcirc_next.3, %shortcirc_next.2, %shortcirc_next.1, %shortcirc_next.0, %entry + br label %UnifiedReturnBlock +UnifiedReturnBlock: ; preds = %shortcirc_done.4, %shortcirc_next.4 + %UnifiedRetVal = phi i1 [ %tmp.26, %shortcirc_next.4 ], [ true, %shortcirc_done.4 ] ; <i1> [#uses=1] + ret i1 %UnifiedRetVal +} + diff --git a/test/Transforms/SimplifyCFG/switch_switch_fold.ll b/test/Transforms/SimplifyCFG/switch_switch_fold.ll new file mode 100644 index 0000000..2e2e310 --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch_switch_fold.ll @@ -0,0 +1,47 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: grep switch | count 1 + +; Test that a switch going to a switch on the same value can be merged. All +; three switches in this example can be merged into one big one. + +declare void @foo1() + +declare void @foo2() + +declare void @foo3() + +declare void @foo4() + +define void @test1(i32 %V) { + switch i32 %V, label %F [ + i32 4, label %T + i32 17, label %T + i32 5, label %T + i32 1234, label %F + ] +T: ; preds = %0, %0, %0 + switch i32 %V, label %F [ + i32 4, label %A + i32 17, label %B + i32 42, label %C + ] +A: ; preds = %T + call void @foo1( ) + ret void +B: ; preds = %F, %F, %T + call void @foo2( ) + ret void +C: ; preds = %T + call void @foo3( ) + ret void +F: ; preds = %F, %T, %0, %0 + switch i32 %V, label %F [ + i32 4, label %B + i32 18, label %B + i32 42, label %D + ] +D: ; preds = %F + call void @foo4( ) + ret void +} + diff --git a/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll b/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll new file mode 100644 index 0000000..7d7391a --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll @@ -0,0 +1,116 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: grep switch | count 1 + +; ModuleID = '<stdin>' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" +target triple = "i386-pc-linux-gnu" + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8*, i32 } + %llvm.dbg.composite.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }*, { }*, i32 } + %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } + %llvm.dbg.variable.type = type { i32, { }*, i8*, { }*, i32, { }* } +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] +@.str = internal constant [10 x i8] c"swithh2.c\00", section "llvm.metadata" ; <[10 x i8]*> [#uses=1] +@.str1 = internal constant [38 x i8] c"/developer/home2/zsth/test/debug/tmp/\00", section "llvm.metadata" ; <[38 x i8]*> [#uses=1] +@.str2 = internal constant [52 x i8] c"4.2.1 (Based on Apple Inc. build 5641) (LLVM build)\00", section "llvm.metadata" ; <[52 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([10 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([38 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([52 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null, i32 -1 }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] +@.str3 = internal constant [4 x i8] c"int\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type { i32 458788, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str3, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, i32 5 }, section "llvm.metadata" ; <%llvm.dbg.basictype.type*> [#uses=1] +@llvm.dbg.array = internal constant [2 x { }*] [{ }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*), { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] +@llvm.dbg.composite = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] +@llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 46 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] +@.str4 = internal constant [4 x i8] c"foo\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str4, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str4, i32 0, i32 0), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 1, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] +@.str5 = internal constant [2 x i8] c"x\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] +@llvm.dbg.variable = internal constant %llvm.dbg.variable.type { i32 459009, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), i8* getelementptr ([2 x i8]* @.str5, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 1, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=0] + +define i32 @foo(i32 %x) nounwind { +entry: + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) + call void @llvm.dbg.stoppoint(i32 2, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + switch i32 %x, label %bb4 [ + i32 1, label %bb + i32 2, label %bb1 + i32 3, label %bb2 + i32 4, label %bb3 + ] + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 2, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb + +bb: ; preds = %0, %entry + call void @llvm.dbg.stoppoint(i32 3, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 3, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb1 + +bb1: ; preds = %1, %entry + call void @llvm.dbg.stoppoint(i32 4, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 4, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb2 + +bb2: ; preds = %2, %entry + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb3 + +bb3: ; preds = %3, %entry + call void @llvm.dbg.stoppoint(i32 6, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 6, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb4 + +bb4: ; preds = %4, %entry + call void @llvm.dbg.stoppoint(i32 10, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + switch i32 %x, label %bb7 [ + i32 5, label %bb5 + i32 6, label %bb6 + ] + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 10, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb5 + +bb5: ; preds = %5, %bb4 + call void @llvm.dbg.stoppoint(i32 11, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 11, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb6 + +bb6: ; preds = %6, %bb4 + call void @llvm.dbg.stoppoint(i32 12, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 12, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb7 + +bb7: ; preds = %7, %bb4 + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb8 + +bb8: ; preds = %bb7, %bb6, %bb5, %bb3, %bb2, %bb1, %bb + %.0 = phi i32 [ 4, %bb3 ], [ 3, %bb2 ], [ 2, %bb1 ], [ 1, %bb ], [ 6, %bb6 ], [ 5, %bb5 ], [ 0, %bb7 ] ; <i32> [#uses=1] + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %return + +return: ; preds = %bb8 + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) + ret i32 %.0 +} + +declare void @llvm.dbg.func.start({ }*) nounwind + +declare void @llvm.dbg.declare({ }*, { }*) nounwind + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +declare void @llvm.dbg.region.end({ }*) nounwind diff --git a/test/Transforms/SimplifyCFG/switch_thread.ll b/test/Transforms/SimplifyCFG/switch_thread.ll new file mode 100644 index 0000000..bd85fcc --- /dev/null +++ b/test/Transforms/SimplifyCFG/switch_thread.ll @@ -0,0 +1,79 @@ +; RUN: opt < %s -simplifycfg -S | \ +; RUN: not grep {call void @DEAD} + +; Test that we can thread a simple known condition through switch statements. + +declare void @foo1() + +declare void @foo2() + +declare void @DEAD() + +define void @test1(i32 %V) { + switch i32 %V, label %A [ + i32 4, label %T + i32 17, label %Done + i32 1234, label %A + ] +;; V == 4 if we get here. +T: ; preds = %0 + call void @foo1( ) + ;; This switch is always statically determined. + switch i32 %V, label %A2 [ + i32 4, label %B + i32 17, label %C + i32 42, label %C + ] +A2: ; preds = %T + call void @DEAD( ) + call void @DEAD( ) + ;; always true + %cond2 = icmp eq i32 %V, 4 ; <i1> [#uses=1] + br i1 %cond2, label %Done, label %C +A: ; preds = %0, %0 + call void @foo1( ) + ;; always true + %cond = icmp ne i32 %V, 4 ; <i1> [#uses=1] + br i1 %cond, label %Done, label %C +Done: ; preds = %B, %A, %A2, %0 + ret void +B: ; preds = %T + call void @foo2( ) + ;; always true + %cond3 = icmp eq i32 %V, 4 ; <i1> [#uses=1] + br i1 %cond3, label %Done, label %C +C: ; preds = %B, %A, %A2, %T, %T + call void @DEAD( ) + ret void +} + +define void @test2(i32 %V) { + switch i32 %V, label %A [ + i32 4, label %T + i32 17, label %D + i32 1234, label %E + ] +;; V != 4, 17, 1234 here. +A: ; preds = %0 + call void @foo1( ) + ;; This switch is always statically determined. + switch i32 %V, label %E [ + i32 4, label %C + i32 17, label %C + i32 42, label %D + ] +;; unreacahble. +C: ; preds = %A, %A + call void @DEAD( ) + ret void +T: ; preds = %0 + call void @foo1( ) + call void @foo1( ) + ret void +D: ; preds = %A, %0 + call void @foo1( ) + ret void +E: ; preds = %A, %0 + ret void +} + diff --git a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll new file mode 100644 index 0000000..0c9cc8b --- /dev/null +++ b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll @@ -0,0 +1,19 @@ +; RUN: opt < %s -simplifycfg -S | grep {volatile load} +; PR2967 + +target datalayout = +"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32" +target triple = "i386-pc-linux-gnu" + +define void @foo(i32 %x) nounwind { +entry: + %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1] + br i1 %0, label %bb, label %return + +bb: ; preds = %entry + %1 = volatile load i32* null ; <i32> [#uses=0] + unreachable + br label %return +return: ; preds = %entry + ret void +} diff --git a/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll b/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll new file mode 100644 index 0000000..01041eb --- /dev/null +++ b/test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll @@ -0,0 +1,28 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } + +@llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" + +@.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] +@.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] +@.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +define i1 @qux(i8* %m, i8* %n, i8* %o, i8* %p) nounwind { +entry: + %tmp7 = icmp eq i8* %m, %n + br i1 %tmp7, label %bb, label %UnifiedReturnBlock + +bb: +call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %tmp15 = icmp eq i8* %o, %p + br label %UnifiedReturnBlock + +UnifiedReturnBlock: + %result = phi i1 [ 0, %entry ], [ %tmp15, %bb ] + ret i1 %result +} diff --git a/test/Transforms/SimplifyCFG/two-entry-phi-return.ll b/test/Transforms/SimplifyCFG/two-entry-phi-return.ll new file mode 100644 index 0000000..fb18624 --- /dev/null +++ b/test/Transforms/SimplifyCFG/two-entry-phi-return.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -simplifycfg -S | not grep br + +define i1 @qux(i8* %m, i8* %n, i8* %o, i8* %p) nounwind { +entry: + %tmp7 = icmp eq i8* %m, %n + br i1 %tmp7, label %bb, label %UnifiedReturnBlock + +bb: + %tmp15 = icmp eq i8* %o, %p + br label %UnifiedReturnBlock + +UnifiedReturnBlock: + %result = phi i1 [ 0, %entry ], [ %tmp15, %bb ] + ret i1 %result +} |