It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
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..7f0a57c
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2002-05-05-EmptyBlockMerge.ll
@@ -0,0 +1,24 @@
+; Basic block #2 should not be merged into BB #3!
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: grep {br label}
+;
+declare void %foo()
+implementation
+
+void "cprop_test12"(int* %data) {
+bb0:
+ %reg108 = load int* %data
+ %cond218 = setne int %reg108, 5
+ br bool %cond218, label %bb3, label %bb2
+
+bb2:
+ call void %foo()
+ br label %bb3
+
+bb3:
+ %reg117 = phi int [ 110, %bb2 ], [ %reg108, %bb0 ]
+ store int %reg117, int* %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..1ef6593
--- /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: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis
+
+void "test"() {
+ br bool true, label %end, label %Loop
+
+Loop:
+ %V = phi int [0, %0], [%V1, %Loop]
+ %V1 = add int %V, 1
+
+ br label %Loop
+end:
+ 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..a669a3f
--- /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: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+
+int %main(int %argc) {
+ br label %InlinedFunctionReturnNode
+
+InlinedFunctionReturnNode: ;[#uses=1]
+ %X = phi int [ 7, %0 ] ; <int> [#uses=1]
+ %Y = add int %X, %argc ; <int> [#uses=1]
+ ret int %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..f1674b7
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2002-09-24-PHIAssertion.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg
+
+int %test(int %A, int %B, bool %cond) {
+J:
+ %C = add int %A, 12
+ br bool %cond, label %L, label %L
+L:
+ %Q = phi int [%C, %J], [%C, %J] ; PHI node is obviously redundant
+ %D = add int %C, %B
+ %E = add int %Q, %D
+ ret int %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..312e514
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2003-03-07-DominateProblem.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+implementation ; Functions:
+
+void %test(int* %ldo, bool %c, bool %d) {
+bb9:
+ br bool %c, label %bb11, label %bb10
+
+bb10: ; preds = %bb9
+ br label %bb11
+
+bb11: ; preds = %bb10, %bb9
+ %reg330 = phi int* [ null, %bb10 ], [ %ldo, %bb9 ]
+ br label %bb20
+
+bb20: ; preds = %bb23, %bb25, %bb27, %bb11
+ store int* %reg330, int** null
+ br bool %d, label %bb20, label %done
+
+done:
+ 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..811fe50
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll
@@ -0,0 +1,11 @@
+; Do not remove the invoke!
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+int %test() {
+ %A = invoke int %test() to label %Ret except label %Ret2
+Ret:
+ ret int %A
+Ret2:
+ ret int 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..ff549ad
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll
@@ -0,0 +1,10 @@
+; Do not remove the invoke!
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | grep invoke
+
+int %test() {
+ invoke int %test() to label %Ret except label %Ret
+Ret:
+ %A = add int 0, 1
+ ret int %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..fcefac1
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll
@@ -0,0 +1,21 @@
+; This test checks to make sure that 'br X, Dest, Dest' is folded into
+; 'br Dest'
+
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep {br bool %c2}
+
+declare void %noop()
+
+int %test(bool %c1, bool %c2) {
+ call void %noop()
+ br bool %c1, label %A, label %Y
+A:
+ call void %noop()
+ br bool %c2, label %X, label %X ; Can be converted to unconditional br
+X:
+ call void %noop()
+ ret int 0
+Y:
+ 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..08ff290
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
@@ -0,0 +1,25 @@
+; 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: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep {br bool %c2}
+
+declare void %noop()
+
+int %test(bool %c1, bool %c2) {
+ call void %noop()
+ br bool %c1, label %A, label %Y
+A:
+ call void %noop()
+ br bool %c2, label %Z, label %X ; Can be converted to unconditional br
+Z:
+ br label %X
+X:
+ call void %noop()
+ ret int 0
+Y:
+ call void %noop()
+ br label %X
+}
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..ac9ba18
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch.ll
@@ -0,0 +1,61 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep switch
+
+int %test1() { ; Test normal folding
+ switch uint 5, label %Default [
+ uint 0, label %Foo
+ uint 1, label %Bar
+ uint 2, label %Baz
+ uint 5, label %TheDest
+ ]
+Default:ret int -1
+Foo: ret int -2
+Bar: ret int -3
+Baz: ret int -4
+TheDest:ret int 1234
+}
+
+int %test2() { ; Test folding to default dest
+ switch uint 3, label %Default [
+ uint 0, label %Foo
+ uint 1, label %Bar
+ uint 2, label %Baz
+ uint 5, label %TheDest
+ ]
+Default:ret int 1234
+Foo: ret int -2
+Bar: ret int -5
+Baz: ret int -6
+TheDest:ret int -8
+}
+
+int %test3(bool %C) { ; Test folding all to same dest
+ br bool %C, label %Start, label %TheDest
+Start:
+ switch uint 3, label %TheDest [
+ uint 0, label %TheDest
+ uint 1, label %TheDest
+ uint 2, label %TheDest
+ uint 5, label %TheDest
+ ]
+TheDest: ret int 1234
+}
+
+int %test4(uint %C) { ; Test folding switch -> branch
+ switch uint %C, label %L1 [
+ uint 0, label %L2
+ ]
+L1: ret int 0
+L2: ret int 1
+}
+
+int %test5(uint %C) {
+ switch uint %C, label %L1 [ ; Can fold into a cond branch!
+ uint 0, label %L2
+ uint 123, label %L1
+ ]
+L1: ret int 0
+L2: ret int 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..44c89d6
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
@@ -0,0 +1,59 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+implementation ; Functions:
+
+void %symhash_add() {
+entry:
+ br bool undef, label %then.0, label %UnifiedReturnBlock
+
+then.0: ; preds = %entry
+ br bool undef, label %loopentry.2, label %loopentry.1.preheader
+
+loopentry.1.preheader: ; preds = %then.0
+ br label %loopentry.1.outer
+
+loopentry.1.outer: ; preds = %loopentry.1.preheader, %loopexit.1
+ br label %loopentry.1
+
+loopentry.1: ; preds = %loopentry.1.outer, %then.1, %then.3, %then.4, %endif.1
+ br bool undef, label %loopexit.1, label %no_exit.1
+
+no_exit.1: ; preds = %loopentry.1
+ br bool undef, label %then.1, label %else.0
+
+then.1: ; preds = %no_exit.1
+ br label %loopentry.1
+
+else.0: ; preds = %no_exit.1
+ br bool undef, label %then.2, label %else.1
+
+then.2: ; preds = %else.0
+ br bool undef, label %then.3, label %endif.1
+
+then.3: ; preds = %then.2
+ br label %loopentry.1
+
+else.1: ; preds = %else.0
+ br bool undef, label %endif.1, label %then.4
+
+then.4: ; preds = %else.1
+ br label %loopentry.1
+
+endif.1: ; preds = %then.2, %else.1
+ br label %loopentry.1
+
+loopexit.1: ; preds = %loopentry.1
+ br bool undef, label %loopentry.1.outer, label %loopentry.2
+
+loopentry.2: ; preds = %then.0, %loopexit.1, %no_exit.2
+ br bool 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..6c53029
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll
@@ -0,0 +1,125 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+; PR584
+
+%g_38098584 = external global uint ; <uint*> [#uses=1]
+%g_60187400 = external global uint ; <uint*> [#uses=1]
+%g_59182229 = external global uint ; <uint*> [#uses=2]
+
+implementation ; Functions:
+
+int %_Z13func_26556482h(ubyte %l_88173906) {
+entry:
+ %tmp.1 = cast ubyte %l_88173906 to sbyte ; <sbyte> [#uses=2]
+ %tmp.3 = seteq ubyte %l_88173906, 0 ; <bool> [#uses=1]
+ br bool %tmp.3, label %else.0, label %then.0
+
+then.0: ; preds = %entry
+ %tmp.5 = seteq ubyte %l_88173906, 0 ; <bool> [#uses=1]
+ br bool %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 int [ 0, %else.1 ], [ %inc.0, %no_exit.0 ] ; <int> [#uses=2]
+ %tmp.9 = setgt int %i.0.1, 99 ; <bool> [#uses=1]
+ br bool %tmp.9, label %endif.0, label %no_exit.0
+
+no_exit.0: ; preds = %loopentry.0
+ %inc.0 = add int %i.0.1, 1 ; <int> [#uses=1]
+ br label %loopentry.0
+
+else.0: ; preds = %entry
+ %tmp.12 = cast sbyte %tmp.1 to int ; <int> [#uses=1]
+ br label %return
+
+endif.0: ; preds = %loopentry.0
+ %tmp.14 = cast sbyte %tmp.1 to int ; <int> [#uses=1]
+ %tmp.16 = cast ubyte %l_88173906 to int ; <int> [#uses=1]
+ %tmp.17 = setgt int %tmp.14, %tmp.16 ; <bool> [#uses=1]
+ %tmp.19 = load uint* %g_59182229 ; <uint> [#uses=2]
+ br bool %tmp.17, label %cond_true, label %cond_false
+
+cond_true: ; preds = %endif.0
+ %tmp.20 = setne uint %tmp.19, 1 ; <bool> [#uses=1]
+ br label %cond_continue
+
+cond_false: ; preds = %endif.0
+ %tmp.22 = setne uint %tmp.19, 0 ; <bool> [#uses=1]
+ br label %cond_continue
+
+cond_continue: ; preds = %cond_false, %cond_true
+ %mem_tmp.0 = phi bool [ %tmp.20, %cond_true ], [ %tmp.22, %cond_false ] ; <bool> [#uses=1]
+ br bool %mem_tmp.0, label %then.2, label %else.2
+
+then.2: ; preds = %cond_continue
+ %tmp.25 = cast ubyte %l_88173906 to int ; <int> [#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 int [ 0, %else.2 ], [ %inc.3, %endif.3 ] ; <int> [#uses=2]
+ %i.3.2 = phi int [ undef, %else.2 ], [ %i.3.0, %endif.3 ] ; <int> [#uses=2]
+ %l_88173906_addr.1 = phi ubyte [ %l_88173906, %else.2 ], [ %l_88173906_addr.0, %endif.3 ] ; <ubyte> [#uses=3]
+ %tmp.29 = setgt int %i.1.1, 99 ; <bool> [#uses=1]
+ br bool %tmp.29, label %endif.2, label %no_exit.1
+
+no_exit.1: ; preds = %loopentry.1
+ %tmp.30 = load uint* %g_38098584 ; <uint> [#uses=1]
+ %tmp.31 = seteq uint %tmp.30, 0 ; <bool> [#uses=1]
+ br bool %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 bool false, label %else.4, label %then.4
+
+then.4: ; preds = %else.3
+ br label %endif.3
+
+else.4: ; preds = %else.3
+ br bool false, label %else.5, label %then.5
+
+then.5: ; preds = %else.4
+ store uint 3290648471, uint* %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 int [ 0, %else.5 ], [ %inc.2, %then.7 ] ; <int> [#uses=3]
+ %tmp.55 = setgt int %i.3.3, 99 ; <bool> [#uses=1]
+ br bool %tmp.55, label %endif.3, label %no_exit.3
+
+no_exit.3: ; preds = %loopentry.3
+ %tmp.57 = seteq ubyte %l_88173906_addr.1, 0 ; <bool> [#uses=1]
+ br bool %tmp.57, label %else.7, label %then.7
+
+then.7: ; preds = %no_exit.3
+ store uint 16239, uint* %g_60187400
+ %inc.2 = add int %i.3.3, 1 ; <int> [#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 int [ %i.3.2, %then.3 ], [ %i.3.2, %then.4 ], [ %i.3.3, %loopentry.3 ] ; <int> [#uses=1]
+ %l_88173906_addr.0 = phi ubyte [ 100, %then.3 ], [ %l_88173906_addr.1, %then.4 ], [ %l_88173906_addr.1, %loopentry.3 ] ; <ubyte> [#uses=1]
+ %inc.3 = add int %i.1.1, 1 ; <int> [#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 int [ 1624650671, %then.1 ], [ %tmp.25, %then.2 ], [ 3379, %then.5 ], [ 52410, %else.7 ], [ -1526438411, %endif.2 ], [ %tmp.12, %else.0 ] ; <int> [#uses=1]
+ ret int %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..9271ac2
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll
@@ -0,0 +1,96 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+void %main() {
+entry:
+ %tmp.14.i19 = seteq int 0, 2 ; <bool> [#uses=1]
+ br bool %tmp.14.i19, label %endif.1.i20, label %read_min.exit
+
+endif.1.i20: ; preds = %entry
+ %tmp.9.i.i = seteq sbyte* null, null ; <bool> [#uses=1]
+ br bool %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 = seteq sbyte* null, null ; <bool> [#uses=1]
+ br bool %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 bool 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 = setlt int 0, 0 ; <bool> [#uses=1]
+ br bool %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 = seteq int 0, 0 ; <bool> [#uses=1]
+ br bool %tmp.341.i, label %loopentry.1.i, label %read_min.exit
+
+loopentry.1.i: ; preds = %loopexit.0.i40
+ %tmp.347.i = setgt int 0, 0 ; <bool> [#uses=1]
+ br bool %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 uint [ %indvar.next.i, %endif.5.i ], [ 0, %loopentry.1.i ] ; <uint> [#uses=1]
+ %tmp.355.i = seteq int 0, 3 ; <bool> [#uses=1]
+ br bool %tmp.355.i, label %endif.5.i, label %read_min.exit
+
+endif.5.i: ; preds = %no_exit.1.i41
+ %tmp.34773.i = setgt int 0, 0 ; <bool> [#uses=1]
+ %indvar.next.i = add uint %indvar.i42, 1 ; <uint> [#uses=1]
+ br bool %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 = seteq int 0, 0 ; <bool> [#uses=1]
+ br bool %tmp.23, label %endif.1, label %then.1
+
+then.1: ; preds = %read_min.exit
+ br bool false, label %endif.0.i, label %then.0.i
+
+then.0.i: ; preds = %then.1
+ br bool false, label %endif.1.i, label %then.1.i
+
+endif.0.i: ; preds = %then.1
+ br bool false, label %endif.1.i, label %then.1.i
+
+then.1.i: ; preds = %endif.0.i, %then.0.i
+ br bool false, label %getfree.exit, label %then.2.i
+
+endif.1.i: ; preds = %endif.0.i, %then.0.i
+ br bool 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 int* null, int 0
+ br bool 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 bool false, label %primal_start_artificial.exit, label %no_exit.1.i16
+
+no_exit.1.i16: ; preds = %no_exit.1.i16, %loopexit.0.i15
+ br bool 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..4ac692e
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll
@@ -0,0 +1,95 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+; END.
+
+ %arraytype.1.Char = type { int, [0 x sbyte] }
+ %arraytype.4.Signed = type { int, [0 x int] }
+ %functiontype.23 = type %structtype.Task* (%structtype.Task*, %structtype.Packet*, %structtype.FailedRun*)
+ %functiontype.27 = type %structtype.object* ()
+ %functiontype.28 = type bool (%structtype.object*, %structtype.object_vtable*)
+ %functiontype.39 = type int (%structtype.listiter*)
+ %opaquetype.RuntimeTypeInfo = type sbyte* (sbyte*)
+ %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*, int, int, int, %structtype.Packet* }
+ %structtype.Task = type { %structtype.TaskState, %structtype.FailedRun*, int, %structtype.Packet*, %structtype.Task*, int }
+ %structtype.TaskState = type { %structtype.object, bool, bool, bool }
+ %structtype.list.1 = type { %arraytype.4.Signed* }
+ %structtype.listiter = type { %structtype.list.1*, int }
+ %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]
+
+implementation ; Functions:
+
+declare fastcc bool %ll_isinstance__objectPtr_object_vtablePtr()
+
+declare fastcc void %ll_listnext__listiterPtr()
+
+fastcc void %WorkTask.fn() {
+block0:
+ br label %block1
+
+block1: ; preds = %block0
+ %v2542 = call fastcc bool %ll_isinstance__objectPtr_object_vtablePtr( ) ; <bool> [#uses=1]
+ br bool %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 = seteq %structtype.Packet* null, null ; <bool> [#uses=1]
+ br bool %v2565, label %block15, label %block6
+
+block6: ; preds = %block5
+ %self_2575 = phi %structtype.DeviceTask* [ null, %block5 ] ; <%structtype.DeviceTask*> [#uses=1]
+ br bool 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, int 0, uint 2 ; <int*> [#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 bool 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 bool 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..c3b4194
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+bool %foo() {
+ %X = invoke bool %foo() to label %N unwind label %F
+F:
+ ret bool false
+N:
+ br bool %X, label %A, label %B
+A:
+ ret bool true
+B:
+ ret bool 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..ca69970
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll
@@ -0,0 +1,140 @@
+; Make sure this doesn't turn into an infinite loop
+
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -constprop -simplifycfg |\
+; RUN: llvm-dis | grep bb86
+; END.
+
+ %struct.anon = type { uint, int, int, int, [1024 x sbyte] }
+%_zero_ = external global %struct.anon* ; <%struct.anon**> [#uses=2]
+%_one_ = external global %struct.anon* ; <%struct.anon**> [#uses=4]
+%str = internal constant [4 x sbyte] c"%d\0A\00" ; <[4 x sbyte]*> [#uses=1]
+
+implementation ; Functions:
+
+
+declare int %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(int, int)
+
+declare void %int2num(%struct.anon**, int)
+
+declare void %bc_multiply(%struct.anon*, %struct.anon*, %struct.anon**, int)
+
+declare void %bc_raise(%struct.anon*, %struct.anon*, %struct.anon**, int)
+
+declare int %bc_divide(%struct.anon*, %struct.anon*, %struct.anon**, int)
+
+declare void %bc_add(%struct.anon*, %struct.anon*, %struct.anon**)
+
+declare int %_do_compare(%struct.anon*, %struct.anon*, int, int)
+
+declare int %printf(sbyte*, ...)
+
+int %bc_sqrt(%struct.anon** %num, int %scale) {
+entry:
+ %guess = alloca %struct.anon* ; <%struct.anon**> [#uses=15]
+ %guess1 = alloca %struct.anon* ; <%struct.anon**> [#uses=12]
+ %point5 = alloca %struct.anon* ; <%struct.anon**> [#uses=4]
+ %tmp = load %struct.anon** %num ; <%struct.anon*> [#uses=1]
+ %tmp1 = load %struct.anon** %_zero_ ; <%struct.anon*> [#uses=1]
+ %tmp = call int %bc_compare( %struct.anon* %tmp, %struct.anon* %tmp1 ) ; <int> [#uses=2]
+ %tmp = setlt int %tmp, 0 ; <bool> [#uses=1]
+ br bool %tmp, label %cond_true, label %cond_false
+
+cond_true: ; preds = %entry
+ ret int 0
+
+cond_false: ; preds = %entry
+ %tmp5 = seteq int %tmp, 0 ; <bool> [#uses=1]
+ br bool %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 int 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 int %bc_compare( %struct.anon* %tmp15, %struct.anon* %tmp16 ) ; <int> [#uses=2]
+ %tmp19 = seteq int %tmp17, 0 ; <bool> [#uses=1]
+ br bool %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 int 1
+
+cond_next27: ; preds = %cond_next13
+ %tmp29 = load %struct.anon** %num ; <%struct.anon*> [#uses=1]
+ %tmp30 = getelementptr %struct.anon* %tmp29, int 0, uint 2 ; <int*> [#uses=1]
+ %tmp31 = load int* %tmp30 ; <int> [#uses=2]
+ %tmp33 = setge int %tmp31, %scale ; <bool> [#uses=1]
+ %max = select bool %tmp33, int %tmp31, int %scale ; <int> [#uses=4]
+ %tmp35 = add int %max, 2 ; <int> [#uses=2]
+ call void %init_num( %struct.anon** %guess )
+ call void %init_num( %struct.anon** %guess1 )
+ %tmp36 = call %struct.anon* %new_num( int 1, int 1 ) ; <%struct.anon*> [#uses=2]
+ store %struct.anon* %tmp36, %struct.anon** %point5
+ %tmp = getelementptr %struct.anon* %tmp36, int 0, uint 4, int 1 ; <sbyte*> [#uses=1]
+ store sbyte 5, sbyte* %tmp
+ %tmp39 = setlt int %tmp17, 0 ; <bool> [#uses=1]
+ br bool %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, int 10 )
+ %tmp45 = load %struct.anon** %num ; <%struct.anon*> [#uses=1]
+ %tmp46 = getelementptr %struct.anon* %tmp45, int 0, uint 1 ; <int*> [#uses=1]
+ %tmp47 = load int* %tmp46 ; <int> [#uses=1]
+ call void %int2num( %struct.anon** %guess1, int %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, int %max )
+ %tmp51 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1]
+ %tmp52 = getelementptr %struct.anon* %tmp51, int 0, uint 2 ; <int*> [#uses=1]
+ store int 0, int* %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, int %max )
+ br label %bb80.outer
+
+bb80.outer: ; preds = %cond_true77, %cond_next56
+ %done.1.ph = phi int [ 1, %cond_true83 ], [0, %cond_true40], [0, %cond_false43] ; <int> [#uses=1]
+ br label %bb80
+
+bb80: ; preds = %bb80.outer, %cond_true83
+ %tmp82 = seteq int %done.1.ph, 0 ; <bool> [#uses=1]
+ br bool %tmp82, label %cond_true83, label %bb86
+
+cond_true83: ; preds = %bb80
+ %tmp71 = call int %_do_compare( %struct.anon* null, %struct.anon* null, int 0, int 1 ) ; <int> [#uses=2]
+ %tmp76 = seteq int %tmp71, 0 ; <bool> [#uses=1]
+ br bool %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 int %bc_divide( %struct.anon* %tmp88, %struct.anon* %tmp89, %struct.anon** %num, int %max ) ; <int> [#uses=0]
+ call void %free_num( %struct.anon** %guess )
+ call void %free_num( %struct.anon** %guess1 )
+ call void %free_num( %struct.anon** %point5 )
+ ret int 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..8b443da
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll
@@ -0,0 +1,35 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+void %polnel_() {
+entry:
+ %tmp595 = setlt int 0, 0 ; <bool> [#uses=4]
+ br bool %tmp595, label %bb148.critedge, label %cond_true40
+
+bb36: ; preds = %bb43
+ br bool %tmp595, label %bb43, label %cond_true40
+
+cond_true40: ; preds = %bb46, %cond_true40, %bb36, %entry
+ %tmp397 = setgt int 0, 0 ; <bool> [#uses=1]
+ br bool %tmp397, label %bb43, label %cond_true40
+
+bb43: ; preds = %cond_true40, %bb36
+ br bool false, label %bb53, label %bb36
+
+bb46: ; preds = %bb53
+ br bool %tmp595, label %bb53, label %cond_true40
+
+bb53: ; preds = %bb46, %bb43
+ br bool false, label %bb102, label %bb46
+
+bb92.preheader: ; preds = %bb102
+ ret void
+
+bb102: ; preds = %bb53
+ br bool %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..c9b1858
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2006-06-12-InfLoop.ll
@@ -0,0 +1,613 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+void %main(int %c) {
+entry:
+ %tmp.9 = seteq int %c, 2 ; <bool> [#uses=1]
+ br bool %tmp.9, label %endif.0, label %then.0
+
+then.0: ; preds = %entry
+ ret void
+
+endif.0: ; preds = %entry
+ br bool false, label %then.1, label %endif.1
+
+then.1: ; preds = %endif.0
+ ret void
+
+endif.1: ; preds = %endif.0
+ br bool false, label %then.2, label %endif.2
+
+then.2: ; preds = %endif.1
+ ret void
+
+endif.2: ; preds = %endif.1
+ br bool false, label %then.3, label %loopentry.0
+
+then.3: ; preds = %endif.2
+ ret void
+
+loopentry.0: ; preds = %endif.2
+ br bool 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 bool false, label %then.4, label %endif.4
+
+then.4: ; preds = %no_exit.0
+ ret void
+
+endif.4: ; preds = %no_exit.0
+ br bool 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 bool false, label %then.5, label %loopentry.1
+
+then.5: ; preds = %loopexit.0
+ ret void
+
+loopentry.1: ; preds = %loopexit.0
+ %tmp.143 = setgt int 0, 0 ; <bool> [#uses=4]
+ br bool %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 bool false, label %then.6, label %shortcirc_next.3
+
+shortcirc_next.3: ; preds = %no_exit.1
+ br bool false, label %then.6, label %shortcirc_next.4
+
+shortcirc_next.4: ; preds = %shortcirc_next.3
+ br bool 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 bool 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 bool false, label %then.i, label %loopentry.0.i
+
+then.i: ; preds = %loopexit.1
+ ret void
+
+loopentry.0.i: ; preds = %loopexit.1
+ br bool %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 bool 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 bool 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 bool 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 bool 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 bool 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 bool %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 bool 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 bool 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 bool 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 bool 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 bool 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 bool false, label %loopentry.1.i85.loopexit, label %then.1.i107
+
+then.1.i107: ; preds = %hamming.exit16.i
+ br bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool false, label %endif.0.i, label %else.i
+
+else.i: ; preds = %no_exit.4.i
+ br bool 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 bool 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 bool 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 = seteq uint 0, 10 ; <bool> [#uses=1]
+ br bool %exitcond, label %generateT.exit, label %loopentry.3.i
+
+generateT.exit: ; preds = %endif.1.i
+ br bool 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 bool %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 bool false, label %then.1.i, label %else.0.i
+
+then.1.i: ; preds = %no_exit.0.i31
+ br bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool undef, label %loopentry.3.i40, label %loopentry.4.i52
+
+loopentry.4.i52: ; preds = %loopexit.3.i51
+ br bool 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 bool undef, label %then.1.i55, label %endif.1.i56
+
+then.1.i55: ; preds = %no_exit.4.i54
+ br bool 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 bool undef, label %no_exit.4.backedge.i, label %loopexit.4.i57
+
+loopexit.4.i57: ; preds = %endif.1.i56, %then.1.i55
+ br bool 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 bool 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 bool undef, label %endif.2.i, label %loopentry.5.i72
+
+loopentry.5.i72: ; preds = %hamming.exit.i71
+ br bool 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 bool undef, label %no_exit.5.i76, label %loopexit.5.i77.loopexit
+
+no_exit.5.i76: ; preds = %shortcirc_next.i74
+ br bool 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 bool 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 bool undef, label %then.3.i, label %loopentry.6.i80
+
+then.3.i: ; preds = %loopexit.1.i79
+ br bool false, label %no_exit.6.i82.preheader, label %run.exit
+
+loopentry.6.i80: ; preds = %loopexit.1.i79
+ br bool 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 bool 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 bool false, label %no_exit.1.i36.preheader, label %loopentry.3.i37
+
+else.0.i: ; preds = %no_exit.0.i31
+ br bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool 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 bool false, label %loopentry.6.i, label %endif.1.i18
+
+loopentry.6.i: ; preds = %no_exit.5.i
+ br bool 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 bool 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 bool false, label %then.2.i, label %endif.1.i18
+
+then.2.i: ; preds = %loopexit.6.i
+ br bool 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 bool 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 bool 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 bool false, label %no_exit.7.i, label %loopexit.7.i
+
+loopexit.7.i: ; preds = %no_exit.7.i
+ br bool 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 bool 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 bool false, label %endif.3.i19, label %loopentry.8.i
+
+loopentry.8.i: ; preds = %hamming.exit.i
+ br bool 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 bool false, label %no_exit.8.i, label %loopexit.8.i.loopexit
+
+no_exit.8.i: ; preds = %shortcirc_next.i
+ br bool 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 bool 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 bool 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 bool false, label %loopentry.2.i, label %loopexit.1.i20
+
+loopexit.1.i20: ; preds = %endif.3.i19
+ br bool 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 bool 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 bool 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 bool 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 bool 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 bool false, label %endif.3.i, label %else.1.i
+
+else.1.i: ; preds = %no_exit.3.i
+ br bool 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 bool 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 bool 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 = setlt int 0, 0 ; <bool> [#uses=1]
+ br bool %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..a224a2f
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll
@@ -0,0 +1,104 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -simplifycfg \
+; RUN: -disable-output
+; PR867
+
+target endian = big
+target pointersize = 32
+target triple = "powerpc-apple-darwin8"
+ %struct.CUMULATIVE_ARGS = type { int, int, int, int, int, int, int, int, int, int, int, int }
+ %struct.eh_status = type opaque
+ %struct.emit_status = type { int, int, %struct.rtx_def*, %struct.rtx_def*, %struct.sequence_stack*, int, %struct.location_t, int, ubyte*, %struct.rtx_def** }
+ %struct.expr_status = type { int, int, int, %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*, int, int, int, int, %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*, ubyte, int, long, %struct.tree_node*, %struct.tree_node*, %struct.rtx_def*, %struct.varray_head_tag*, %struct.temp_slot*, int, %struct.var_refs_queue*, int, int, %struct.rtvec_def*, %struct.tree_node*, int, int, int, %struct.machine_function*, uint, uint, ubyte, ubyte, %struct.language_function*, %struct.rtx_def*, uint, int, int, int, %struct.location_t, %struct.varray_head_tag*, %struct.tree_node*, ubyte, ubyte, ubyte }
+ %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 { sbyte*, int }
+ %struct.machine_function = type { int, uint, sbyte*, int, int }
+ %struct.rtunion = type { int }
+ %struct.rtvec_def = type { int, [1 x %struct.rtx_def*] }
+ %struct.rtx_def = type { ushort, ubyte, ubyte, %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*, ubyte, ubyte, ubyte, ubyte, ubyte }
+ %struct.tree_decl = type { %struct.tree_common, %struct.location_t, uint, %struct.tree_node*, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, uint, %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*, long, %struct.lang_decl* }
+ %struct.tree_decl_u1 = type { long }
+ %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*, uint, ushort, ubyte, ubyte, uint, %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*, long, %struct.lang_type* }
+ %struct.u = type { [1 x long] }
+ %struct.var_refs_queue = type { %struct.rtx_def*, uint, int, %struct.var_refs_queue* }
+ %struct.varasm_status = type opaque
+ %struct.varray_head_tag = type { uint, uint, uint, sbyte*, %struct.u }
+ %union.tree_ann_d = type opaque
+%mode_class = external global [35 x ubyte] ; <[35 x ubyte]*> [#uses=3]
+
+implementation ; Functions:
+
+void %fold_builtin_classify() {
+entry:
+ %tmp63 = load int* null ; <int> [#uses=1]
+ switch int %tmp63, label %bb276 [
+ int 414, label %bb145
+ int 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, int 0, uint 0, uint 0, uint 1 ; <%struct.tree_node**> [#uses=1]
+ %tmp149 = load %struct.tree_node** %tmp148 ; <%struct.tree_node*> [#uses=1]
+ %tmp150 = cast %struct.tree_node* %tmp149 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1]
+ %tmp151 = getelementptr %struct.tree_type* %tmp150, int 0, uint 6 ; <ushort*> [#uses=1]
+ %tmp151 = cast ushort* %tmp151 to uint* ; <uint*> [#uses=1]
+ %tmp152 = load uint* %tmp151 ; <uint> [#uses=1]
+ %tmp154 = shr uint %tmp152, ubyte 16 ; <uint> [#uses=1]
+ %tmp154.mask = and uint %tmp154, 127 ; <uint> [#uses=1]
+ %tmp155 = getelementptr [35 x ubyte]* %mode_class, int 0, uint %tmp154.mask ; <ubyte*> [#uses=1]
+ %tmp156 = load ubyte* %tmp155 ; <ubyte> [#uses=1]
+ %tmp157 = seteq ubyte %tmp156, 4 ; <bool> [#uses=1]
+ br bool %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, int 0, uint 0, uint 0, uint 1 ; <%struct.tree_node**> [#uses=1]
+ %tmp175 = load %struct.tree_node** %tmp174 ; <%struct.tree_node*> [#uses=1]
+ %tmp176 = cast %struct.tree_node* %tmp175 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1]
+ %tmp177 = getelementptr %struct.tree_type* %tmp176, int 0, uint 6 ; <ushort*> [#uses=1]
+ %tmp177 = cast ushort* %tmp177 to uint* ; <uint*> [#uses=1]
+ %tmp178 = load uint* %tmp177 ; <uint> [#uses=1]
+ %tmp180 = shr uint %tmp178, ubyte 16 ; <uint> [#uses=1]
+ %tmp180.mask = and uint %tmp180, 127 ; <uint> [#uses=1]
+ %tmp181 = getelementptr [35 x ubyte]* %mode_class, int 0, uint %tmp180.mask ; <ubyte*> [#uses=1]
+ %tmp182 = load ubyte* %tmp181 ; <ubyte> [#uses=1]
+ %tmp183 = seteq ubyte %tmp182, 8 ; <bool> [#uses=1]
+ br bool %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, int 0, uint 0, uint 0, uint 1 ; <%struct.tree_node**> [#uses=1]
+ %tmp188 = load %struct.tree_node** %tmp187 ; <%struct.tree_node*> [#uses=1]
+ %tmp189 = cast %struct.tree_node* %tmp188 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1]
+ %tmp190 = getelementptr %struct.tree_type* %tmp189, int 0, uint 6 ; <ushort*> [#uses=1]
+ %tmp190 = cast ushort* %tmp190 to uint* ; <uint*> [#uses=1]
+ %tmp191 = load uint* %tmp190 ; <uint> [#uses=1]
+ %tmp193 = shr uint %tmp191, ubyte 16 ; <uint> [#uses=1]
+ %tmp193.mask = and uint %tmp193, 127 ; <uint> [#uses=1]
+ %tmp194 = getelementptr [35 x ubyte]* %mode_class, int 0, uint %tmp193.mask ; <ubyte*> [#uses=1]
+ %tmp195 = load ubyte* %tmp194 ; <ubyte> [#uses=1]
+ %tmp196 = seteq ubyte %tmp195, 4 ; <bool> [#uses=1]
+ br bool %tmp196, label %cond_next241, label %cond_true197
+
+cond_true197: ; preds = %cond_true184
+ ret void
+
+cond_next241: ; preds = %cond_true184, %cond_true158, %bb145
+ %tmp245 = load uint* null ; <uint> [#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..26fce45
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2006-10-19-UncondDiv.ll
@@ -0,0 +1,34 @@
+; PR957
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep select
+
+uint %test(uint %tmp) {
+cond_false179: ; preds = %cond_true
+ %tmp181 = seteq uint %tmp, 0 ; <bool> [#uses=1]
+ br bool %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 uint [ div (uint 1, uint 0), %cond_true182 ], [ %tmp,
+%cond_false179 ] ; <uint> [#uses=7]
+
+ ret uint %d0.3
+}
+
+uint %test2(uint %tmp) {
+cond_false179: ; preds = %cond_true
+ %tmp181 = seteq uint %tmp, 0 ; <bool> [#uses=1]
+ br bool %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 uint [ div (uint 1, uint 0), %cond_true182 ], [ %tmp,
+%cond_false179 ] ; <uint> [#uses=7]
+ call uint %test(uint 4)
+ ret uint %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..48a1458
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll
@@ -0,0 +1,654 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+; XFAIL: *
+; Un-XFAIL this when PR1146 is finished.
+
+ %struct..4._102 = type { %struct.QVectorData* }
+ %struct..5._125 = type { %struct.QMapData* }
+ %struct.QAbstractTextDocumentLayout = type { %struct.QObject }
+ %struct.QBasicAtomic = type { int }
+ %struct.QFont = type { %struct.QFontPrivate*, uint }
+ %struct.QFontMetrics = type { %struct.QFontPrivate* }
+ %struct.QFontPrivate = type opaque
+ "struct.QFragmentMap<QTextBlockData>" = type { %struct.QFragmentMapData }
+ %struct.QFragmentMapData = type { "struct.QFragmentMapData::._154", int }
+ "struct.QFragmentMapData::._154" = type { "struct.QFragmentMapData::Header"* }
+ "struct.QFragmentMapData::Header" = type { uint, uint, uint, uint, uint, uint, uint, uint }
+ "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, int, int, short, short, int, ubyte }
+ "struct.QHashData::Node" = type { "struct.QHashData::Node"*, uint }
+ "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, int, int, int, ubyte, [1 x sbyte*] }
+ "struct.QMap<QUrl,QVariant>" = type { %struct..5._125 }
+ %struct.QMapData = type { "struct.QMapData::Node"*, [12 x "struct.QMapData::Node"*], %struct.QBasicAtomic, int, int, uint, ubyte }
+ "struct.QMapData::Node" = type { "struct.QMapData::Node"*, [1 x "struct.QMapData::Node"*] }
+ %struct.QObject = type { int (...)**, %struct.QObjectData* }
+ %struct.QObjectData = type { int (...)**, %struct.QObject*, %struct.QObject*, "struct.QList<QPointer<QObject> >", ubyte, [3 x ubyte], int, int }
+ %struct.QObjectPrivate = type { %struct.QObjectData, int, %struct.QObject*, "struct.QList<QPointer<QObject> >", "struct.QVector<QAbstractTextDocumentLayout::Selection>", %struct.QString }
+ %struct.QPaintDevice = type { int (...)**, ushort }
+ %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, int, int, ushort*, ubyte, ubyte, [1 x ushort] }
+ %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>", bool, int, int, bool, int, int, int, int, bool, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, "struct.QFragmentMap<QTextBlockData>", "struct.QFragmentMap<QTextBlockData>", int, "struct.QList<QPointer<QObject> >", "struct.QList<QPointer<QObject> >", "struct.QMap<QUrl,QVariant>", "struct.QMap<QUrl,QVariant>", "struct.QMap<QUrl,QVariant>", %struct.QTextDocumentConfig, bool, bool, %struct.QPointF }
+ %struct.QTextFormat = type { "struct.QSharedDataPointer<QTextFormatPrivate>", int }
+ %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, int, int, ubyte }
+
+implementation ; Functions:
+
+void %_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) {
+entry:
+ %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2]
+ %tmp = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5]
+ %tmp2 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3]
+ %tmp = alloca %struct.QFontMetrics, align 16 ; <%struct.QFontMetrics*> [#uses=4]
+ %tmp = 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 = call %struct.QTextDocumentPrivate* %_ZNK13QTextDocument6d_funcEv( %struct.QAbstractTextDocumentLayout* %this ) ; <%struct.QTextDocumentPrivate*> [#uses=5]
+ %tmp = getelementptr %struct.QPrinter* %printer, int 0, uint 0 ; <%struct.QPaintDevice*> [#uses=1]
+ call void %_ZN8QPainterC1EP12QPaintDevice( %struct.QPainter* %p, %struct.QPaintDevice* %tmp )
+ %tmp = invoke bool %_ZNK8QPainter8isActiveEv( %struct.QPainter* %p )
+ to label %invcont unwind label %cleanup329 ; <bool> [#uses=1]
+
+invcont: ; preds = %entry
+ br bool %tmp, 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, int 0, uint 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, int 0, uint 26 ; <%struct.QPointF*> [#uses=1]
+ %tmp13 = call bool %_ZNK6QSizeF7isValidEv( %struct.QPointF* %tmp12 ) ; <bool> [#uses=1]
+ br bool %tmp13, label %cond_next15, label %bb
+
+cond_next15: ; preds = %invcont7
+ %tmp17 = getelementptr %struct.QTextDocumentPrivate* %tmp, int 0, uint 26 ; <%struct.QPointF*> [#uses=1]
+ %tmp = call double %_ZNK6QSizeF6heightEv( %struct.QPointF* %tmp17 ) ; <double> [#uses=1]
+ %tmp18 = seteq double %tmp, 0x41DFFFFFFFC00000 ; <bool> [#uses=1]
+ br bool %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 bool [ false, %bb ], [ true, %cond_next20 ] ; <bool> [#uses=1]
+ br bool %iftmp.406.0, label %cond_true24, label %cond_false
+
+cond_true24: ; preds = %bb21
+ %tmp = invoke int %_Z13qt_defaultDpiv( )
+ to label %invcont25 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont25: ; preds = %cond_true24
+ %tmp26 = cast int %tmp 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 = seteq %struct.QPaintDevice* %tmp32, null ; <bool> [#uses=1]
+ br bool %tmp34, label %cond_next42, label %cond_true35
+
+cond_true35: ; preds = %invcont31
+ %tmp38 = invoke int %_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp32 )
+ to label %invcont37 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont37: ; preds = %cond_true35
+ %tmp38 = cast int %tmp38 to double ; <double> [#uses=1]
+ %tmp41 = invoke int %_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp32 )
+ to label %invcont40 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont40: ; preds = %invcont37
+ %tmp41 = cast int %tmp41 to double ; <double> [#uses=1]
+ br label %cond_next42
+
+cond_next42: ; preds = %invcont40, %invcont31
+ %sourceDpiY.2 = phi double [ %tmp41, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1]
+ %sourceDpiX.2 = phi double [ %tmp38, %invcont40 ], [ %tmp26, %invcont31 ] ; <double> [#uses=1]
+ %tmp44 = getelementptr %struct.QPrinter* %printer, int 0, uint 0 ; <%struct.QPaintDevice*> [#uses=1]
+ %tmp46 = invoke int %_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp44 )
+ to label %invcont45 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont45: ; preds = %cond_next42
+ %tmp46 = cast int %tmp46 to double ; <double> [#uses=1]
+ %tmp48 = fdiv double %tmp46, %sourceDpiX.2 ; <double> [#uses=2]
+ %tmp50 = getelementptr %struct.QPrinter* %printer, int 0, uint 0 ; <%struct.QPaintDevice*> [#uses=1]
+ %tmp52 = invoke int %_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp50 )
+ to label %invcont51 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont51: ; preds = %invcont45
+ %tmp52 = cast int %tmp52 to double ; <double> [#uses=1]
+ %tmp54 = fdiv double %tmp52, %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 = getelementptr %struct.QPointF* %scaledPageSize, int 0, uint 0 ; <double*> [#uses=1]
+ %tmp60 = getelementptr %struct.QTextDocumentPrivate* %tmp, int 0, uint 26, uint 0 ; <double*> [#uses=1]
+ %tmp61 = load double* %tmp60 ; <double> [#uses=1]
+ store double %tmp61, double* %tmp
+ %tmp62 = getelementptr %struct.QPointF* %scaledPageSize, int 0, uint 1 ; <double*> [#uses=1]
+ %tmp63 = getelementptr %struct.QTextDocumentPrivate* %tmp, int 0, uint 26, uint 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, int 0, uint 0 ; <%struct.QPaintDevice*> [#uses=1]
+ %tmp80 = invoke int %_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 )
+ to label %invcont79 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont79: ; preds = %invcont57
+ %tmp82 = getelementptr %struct.QPrinter* %printer, int 0, uint 0 ; <%struct.QPaintDevice*> [#uses=1]
+ %tmp84 = invoke int %_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp82 )
+ to label %invcont83 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont83: ; preds = %invcont79
+ %tmp80 = cast int %tmp80 to double ; <double> [#uses=1]
+ %tmp84 = cast int %tmp84 to double ; <double> [#uses=1]
+ call void %_ZN6QSizeFC1Edd( %struct.QPointF* %printerPageSize, double %tmp84, double %tmp80 )
+ %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 = getelementptr %struct.QAbstractTextDocumentLayout* %this, int 0, uint 0 ; <%struct.QObject*> [#uses=1]
+ %tmp95 = invoke %struct.QAbstractTextDocumentLayout* %_ZNK13QTextDocument5cloneEP7QObject( %struct.QAbstractTextDocumentLayout* %this, %struct.QObject* %tmp )
+ 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 int %_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp105 )
+ to label %invcont106 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont106: ; preds = %invcont104
+ %tmp108 = cast int %tmp107 to double ; <double> [#uses=1]
+ %tmp109 = mul double %tmp108, 0x3FE93264C993264C ; <double> [#uses=1]
+ %tmp109 = cast double %tmp109 to int ; <int> [#uses=3]
+ %tmp = call %struct.QTextBlockGroup* %_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1]
+ invoke csretcc void %_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* %fmt, %struct.QTextBlockGroup* %tmp )
+ to label %invcont111 unwind label %cleanup329
+
+invcont111: ; preds = %invcont106
+ %tmp112 = cast int %tmp109 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 int %_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp119 )
+ to label %invcont120 unwind label %cleanup192 ; <int> [#uses=1]
+
+invcont120: ; preds = %invcont118
+ %tmp121 = cast int %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 int %_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp123 )
+ to label %invcont124 unwind label %cleanup192 ; <int> [#uses=1]
+
+invcont124: ; preds = %invcont122
+ %tmp125 = cast int %tmp125 to double ; <double> [#uses=1]
+ call void %_ZN6QRectFC1Edddd( %struct.QRectF* %tmp, double 0.000000e+00, double 0.000000e+00, double %tmp125, double %tmp121 )
+ %tmp126 = getelementptr %struct.QRectF* %body, int 0, uint 0 ; <double*> [#uses=1]
+ %tmp127 = getelementptr %struct.QRectF* %tmp, int 0, uint 0 ; <double*> [#uses=1]
+ %tmp128 = load double* %tmp127 ; <double> [#uses=1]
+ store double %tmp128, double* %tmp126
+ %tmp129 = getelementptr %struct.QRectF* %body, int 0, uint 1 ; <double*> [#uses=1]
+ %tmp130 = getelementptr %struct.QRectF* %tmp, int 0, uint 1 ; <double*> [#uses=1]
+ %tmp131 = load double* %tmp130 ; <double> [#uses=1]
+ store double %tmp131, double* %tmp129
+ %tmp132 = getelementptr %struct.QRectF* %body, int 0, uint 2 ; <double*> [#uses=1]
+ %tmp133 = getelementptr %struct.QRectF* %tmp, int 0, uint 2 ; <double*> [#uses=1]
+ %tmp134 = load double* %tmp133 ; <double> [#uses=1]
+ store double %tmp134, double* %tmp132
+ %tmp135 = getelementptr %struct.QRectF* %body, int 0, uint 3 ; <double*> [#uses=1]
+ %tmp136 = getelementptr %struct.QRectF* %tmp, int 0, uint 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 = cast int %tmp109 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 csretcc void %_ZNK13QTextDocument11defaultFontEv( %struct.QFont* %tmp, %struct.QAbstractTextDocumentLayout* %tmp95 )
+ to label %invcont144 unwind label %cleanup192
+
+invcont144: ; preds = %invcont141
+ invoke void %_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice( %struct.QFontMetrics* %tmp, %struct.QFont* %tmp, %struct.QPaintDevice* %tmp142 )
+ to label %invcont146 unwind label %cleanup173
+
+invcont146: ; preds = %invcont144
+ %tmp149 = invoke int %_ZNK12QFontMetrics6ascentEv( %struct.QFontMetrics* %tmp )
+ to label %invcont148 unwind label %cleanup168 ; <int> [#uses=1]
+
+invcont148: ; preds = %invcont146
+ %tmp149 = cast int %tmp149 to double ; <double> [#uses=1]
+ %tmp150 = add double %tmp140, %tmp149 ; <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 int %_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp152 )
+ to label %invcont153 unwind label %cleanup168 ; <int> [#uses=1]
+
+invcont153: ; preds = %invcont151
+ %tmp155 = mul int %tmp154, 5 ; <int> [#uses=1]
+ %tmp156 = sdiv int %tmp155, 72 ; <int> [#uses=1]
+ %tmp156 = cast int %tmp156 to double ; <double> [#uses=1]
+ %tmp157 = add double %tmp150, %tmp156 ; <double> [#uses=1]
+ %tmp158 = call double %_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; <double> [#uses=1]
+ %tmp159 = cast int %tmp109 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, int 0, uint 0 ; <double*> [#uses=1]
+ %tmp162 = getelementptr %struct.QPointF* %tmp2, int 0, uint 0 ; <double*> [#uses=1]
+ %tmp163 = load double* %tmp162 ; <double> [#uses=1]
+ store double %tmp163, double* %tmp161
+ %tmp164 = getelementptr %struct.QPointF* %pageNumberPos, int 0, uint 1 ; <double*> [#uses=1]
+ %tmp165 = getelementptr %struct.QPointF* %tmp2, int 0, uint 1 ; <double*> [#uses=1]
+ %tmp166 = load double* %tmp165 ; <double> [#uses=1]
+ store double %tmp166, double* %tmp164
+ invoke void %_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp )
+ to label %cleanup171 unwind label %cleanup173
+
+cleanup168: ; preds = %invcont151, %invcont148, %invcont146
+ invoke void %_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp )
+ to label %cleanup173 unwind label %cleanup173
+
+cleanup171: ; preds = %invcont153
+ invoke void %_ZN5QFontD1Ev( %struct.QFont* %tmp )
+ to label %finally170 unwind label %cleanup192
+
+cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144
+ invoke void %_ZN5QFontD1Ev( %struct.QFont* %tmp )
+ to label %cleanup192 unwind label %cleanup192
+
+finally170: ; preds = %cleanup171
+ invoke csretcc void %_ZNK13QTextDocument11defaultFontEv( %struct.QFont* %font, %struct.QAbstractTextDocumentLayout* %tmp95 )
+ to label %invcont177 unwind label %cleanup192
+
+invcont177: ; preds = %finally170
+ invoke void %_ZN5QFont12setPointSizeEi( %struct.QFont* %font, int 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 csretcc void %_ZNK6QRectF4sizeEv( %struct.QPointF* %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 bool %_ZNK8QPrinter13collateCopiesEv( %struct.QPrinter* %printer )
+ to label %invcont196 unwind label %cleanup329 ; <bool> [#uses=1]
+
+invcont196: ; preds = %cond_next194
+ br bool %tmp197, label %cond_true200, label %cond_false204
+
+cond_true200: ; preds = %invcont196
+ %tmp203 = invoke int %_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer )
+ to label %invcont202 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont202: ; preds = %cond_true200
+ br label %cond_next208
+
+cond_false204: ; preds = %invcont196
+ %tmp207 = invoke int %_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer )
+ to label %invcont206 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont206: ; preds = %cond_false204
+ br label %cond_next208
+
+cond_next208: ; preds = %invcont206, %invcont202
+ %pageCopies.0 = phi int [ %tmp203, %invcont202 ], [ 1, %invcont206 ] ; <int> [#uses=2]
+ %docCopies.0 = phi int [ 1, %invcont202 ], [ %tmp207, %invcont206 ] ; <int> [#uses=2]
+ %tmp211 = invoke int %_ZNK8QPrinter8fromPageEv( %struct.QPrinter* %printer )
+ to label %invcont210 unwind label %cleanup329 ; <int> [#uses=3]
+
+invcont210: ; preds = %cond_next208
+ %tmp214 = invoke int %_ZNK8QPrinter6toPageEv( %struct.QPrinter* %printer )
+ to label %invcont213 unwind label %cleanup329 ; <int> [#uses=3]
+
+invcont213: ; preds = %invcont210
+ %tmp216 = seteq int %tmp211, 0 ; <bool> [#uses=1]
+ br bool %tmp216, label %cond_true217, label %cond_next225
+
+cond_true217: ; preds = %invcont213
+ %tmp219 = seteq int %tmp214, 0 ; <bool> [#uses=1]
+ br bool %tmp219, label %cond_true220, label %cond_next225
+
+cond_true220: ; preds = %cond_true217
+ %tmp223 = invoke int %_ZNK13QTextDocument9pageCountEv( %struct.QAbstractTextDocumentLayout* %doc.1 )
+ to label %invcont222 unwind label %cleanup329 ; <int> [#uses=1]
+
+invcont222: ; preds = %cond_true220
+ br label %cond_next225
+
+cond_next225: ; preds = %invcont222, %cond_true217, %invcont213
+ %toPage.1 = phi int [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; <int> [#uses=2]
+ %fromPage.1 = phi int [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; <int> [#uses=2]
+ %tmp.page = invoke uint %_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer )
+ to label %invcont227 unwind label %cleanup329 ; <uint> [#uses=1]
+
+invcont227: ; preds = %cond_next225
+ %tmp228 = seteq uint %tmp.page, 1 ; <bool> [#uses=1]
+ br bool %tmp228, label %cond_true230, label %cond_next234
+
+cond_true230: ; preds = %invcont227
+ br label %cond_next234
+
+cond_next234: ; preds = %cond_true230, %invcont227
+ %ascending.1 = phi bool [ false, %cond_true230 ], [ true, %invcont227 ] ; <bool> [#uses=1]
+ %toPage.2 = phi int [ %fromPage.1, %cond_true230 ], [ %toPage.1, %invcont227 ] ; <int> [#uses=1]
+ %fromPage.2 = phi int [ %toPage.1, %cond_true230 ], [ %fromPage.1, %invcont227 ] ; <int> [#uses=1]
+ br label %bb309
+
+bb237: ; preds = %cond_true313, %cond_next293
+ %iftmp.410.4 = phi bool [ %iftmp.410.5, %cond_true313 ], [ %iftmp.410.1, %cond_next293 ] ; <bool> [#uses=1]
+ %page.4 = phi int [ %fromPage.2, %cond_true313 ], [ %page.3, %cond_next293 ] ; <int> [#uses=4]
+ br label %bb273
+
+invcont240: ; preds = %cond_true277
+ %tmp242 = seteq uint %tmp241, 2 ; <bool> [#uses=1]
+ br bool %tmp242, label %bb252, label %cond_next244
+
+cond_next244: ; preds = %invcont240
+ %tmp247 = invoke uint %_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer )
+ to label %invcont246 unwind label %cleanup329 ; <uint> [#uses=1]
+
+invcont246: ; preds = %cond_next244
+ %tmp248 = seteq uint %tmp247, 3 ; <bool> [#uses=1]
+ br bool %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 bool [ true, %bb252 ], [ false, %bb253 ] ; <bool> [#uses=2]
+ br bool %iftmp.410.0, label %UserCanceled, label %cond_next258
+
+cond_next258: ; preds = %bb254
+ invoke fastcc void %_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF( int %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 int %pageCopies.0, -1 ; <int> [#uses=1]
+ %tmp265 = setgt int %tmp263, %j.4 ; <bool> [#uses=1]
+ br bool %tmp265, label %cond_true266, label %cond_next270
+
+cond_true266: ; preds = %invcont261
+ %tmp269 = invoke bool %_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer )
+ to label %cond_next270 unwind label %cleanup329 ; <bool> [#uses=0]
+
+cond_next270: ; preds = %cond_true266, %invcont261
+ %tmp272 = add int %j.4, 1 ; <int> [#uses=1]
+ br label %bb273
+
+bb273: ; preds = %cond_next270, %bb237
+ %iftmp.410.1 = phi bool [ %iftmp.410.4, %bb237 ], [ %iftmp.410.0, %cond_next270 ] ; <bool> [#uses=2]
+ %j.4 = phi int [ 0, %bb237 ], [ %tmp272, %cond_next270 ] ; <int> [#uses=3]
+ %tmp276 = setlt int %j.4, %pageCopies.0 ; <bool> [#uses=1]
+ br bool %tmp276, label %cond_true277, label %bb280
+
+cond_true277: ; preds = %bb273
+ %tmp241 = invoke uint %_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer )
+ to label %invcont240 unwind label %cleanup329 ; <uint> [#uses=1]
+
+bb280: ; preds = %bb273
+ %tmp283 = seteq int %page.4, %toPage.2 ; <bool> [#uses=1]
+ br bool %tmp283, label %bb297, label %cond_next285
+
+cond_next285: ; preds = %bb280
+ br bool %ascending.1, label %cond_true287, label %cond_false290
+
+cond_true287: ; preds = %cond_next285
+ %tmp289 = add int %page.4, 1 ; <int> [#uses=1]
+ br label %cond_next293
+
+cond_false290: ; preds = %cond_next285
+ %tmp292 = add int %page.4, -1 ; <int> [#uses=1]
+ br label %cond_next293
+
+cond_next293: ; preds = %cond_false290, %cond_true287
+ %page.3 = phi int [ %tmp289, %cond_true287 ], [ %tmp292, %cond_false290 ] ; <int> [#uses=1]
+ %tmp296 = invoke bool %_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer )
+ to label %bb237 unwind label %cleanup329 ; <bool> [#uses=0]
+
+bb297: ; preds = %bb280
+ %tmp299 = add int %docCopies.0, -1 ; <int> [#uses=1]
+ %tmp301 = setgt int %tmp299, %i.1 ; <bool> [#uses=1]
+ br bool %tmp301, label %cond_true302, label %cond_next306
+
+cond_true302: ; preds = %bb297
+ %tmp305 = invoke bool %_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer )
+ to label %cond_next306 unwind label %cleanup329 ; <bool> [#uses=0]
+
+cond_next306: ; preds = %cond_true302, %bb297
+ %tmp308 = add int %i.1, 1 ; <int> [#uses=1]
+ br label %bb309
+
+bb309: ; preds = %cond_next306, %cond_next234
+ %iftmp.410.5 = phi bool [ undef, %cond_next234 ], [ %iftmp.410.1, %cond_next306 ] ; <bool> [#uses=1]
+ %i.1 = phi int [ 0, %cond_next234 ], [ %tmp308, %cond_next306 ] ; <int> [#uses=3]
+ %tmp312 = setlt int %i.1, %docCopies.0 ; <bool> [#uses=1]
+ br bool %tmp312, label %cond_true313, label %UserCanceled
+
+cond_true313: ; preds = %bb309
+ br label %bb237
+
+UserCanceled: ; preds = %bb309, %bb254
+ %tmp318 = seteq %struct.QAbstractTextDocumentLayout* %clonedDoc.1, null ; <bool> [#uses=1]
+ br bool %tmp318, label %cleanup327, label %cond_true319
+
+cond_true319: ; preds = %UserCanceled
+ %tmp = getelementptr %struct.QAbstractTextDocumentLayout* %clonedDoc.1, int 0, uint 0, uint 0 ; <int (...)***> [#uses=1]
+ %tmp = load int (...)*** %tmp ; <int (...)**> [#uses=1]
+ %tmp322 = getelementptr int (...)** %tmp, int 4 ; <int (...)**> [#uses=1]
+ %tmp = load int (...)** %tmp322 ; <int (...)*> [#uses=1]
+ %tmp = cast int (...)* %tmp to void (%struct.QAbstractTextDocumentLayout*)* ; <void (%struct.QAbstractTextDocumentLayout*)*> [#uses=1]
+ invoke void %tmp( %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 bool %_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 int %_ZNK12QPaintDevice5widthEv(%struct.QPaintDevice*)
+
+declare int %_ZNK12QPaintDevice6heightEv(%struct.QPaintDevice*)
+
+declare int %_ZNK12QPaintDevice11logicalDpiXEv(%struct.QPaintDevice*)
+
+declare int %_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 int %_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(int, %struct.QPainter*, %struct.QAbstractTextDocumentLayout*, %struct.QRectF*, %struct.QPointF*)
+
+declare void %_ZN12QFontMetricsD1Ev(%struct.QFontMetrics*)
+
+declare void %_ZN8QPainterC1EP12QPaintDevice(%struct.QPainter*, %struct.QPaintDevice*)
+
+declare bool %_ZNK8QPainter8isActiveEv(%struct.QPainter*)
+
+declare int %_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 int %_ZNK12QFontMetrics6ascentEv(%struct.QFontMetrics*)
+
+declare void %_ZN5QFont12setPointSizeEi(%struct.QFont*, int)
+
+declare bool %_ZNK8QPrinter13collateCopiesEv(%struct.QPrinter*)
+
+declare int %_ZNK8QPrinter9numCopiesEv(%struct.QPrinter*)
+
+declare int %_ZNK8QPrinter8fromPageEv(%struct.QPrinter*)
+
+declare int %_ZNK8QPrinter6toPageEv(%struct.QPrinter*)
+
+declare uint %_ZNK8QPrinter9pageOrderEv(%struct.QPrinter*)
+
+declare uint %_ZNK8QPrinter12printerStateEv(%struct.QPrinter*)
+
+declare bool %_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..3756fcb
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll
@@ -0,0 +1,145 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis
+; END.
+; ModuleID = 'bugpoint-tooptimize.bc'
+target datalayout = "e-p:32:32"
+target endian = little
+target pointersize = 32
+target triple = "i686-pc-linux-gnu"
+ %struct.FILE = type { int, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct._IO_marker*, %struct.FILE*, int, int, int, ushort, sbyte, [1 x sbyte], sbyte*, long, sbyte*, sbyte*, sbyte*, sbyte*, uint, int, [40 x sbyte] }
+ %struct._IO_FILE = type { int, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct._IO_marker*, %struct.FILE*, int, int, int, ushort, sbyte, [1 x sbyte], sbyte*, long, sbyte*, sbyte*, sbyte*, sbyte*, uint, int, [40 x sbyte] }
+ %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, int }
+ %struct.charsequence = type { sbyte*, uint, uint }
+ %struct.trie_s = type { [26 x %struct.trie_s*], int }
+%str = external global [14 x sbyte] ; <[14 x sbyte]*> [#uses=0]
+%str = external global [32 x sbyte] ; <[32 x sbyte]*> [#uses=0]
+%str = external global [12 x sbyte] ; <[12 x sbyte]*> [#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 = external global [3 x sbyte] ; <[3 x sbyte]*> [#uses=0]
+%str = external global [26 x sbyte] ; <[26 x sbyte]*> [#uses=0]
+
+implementation ; Functions:
+
+declare void %charsequence_reset(%struct.charsequence*)
+declare void %free(sbyte*)
+declare void %charsequence_push(%struct.charsequence*, sbyte)
+declare sbyte* %charsequence_val(%struct.charsequence*)
+declare int %_IO_getc(%struct.FILE*)
+declare int %tolower(int)
+declare %struct.trie_s* %trie_insert(%struct.trie_s*, sbyte*)
+declare int %feof(%struct.FILE*)
+
+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 sbyte, align 1 ; <sbyte*> [#uses=7]
+ %wstate = alloca int, align 4 ; <int*> [#uses=4]
+ %cs = alloca %struct.charsequence, align 16 ; <%struct.charsequence*> [#uses=7]
+ %str = alloca sbyte*, align 4 ; <sbyte**> [#uses=3]
+ "alloca point" = bitcast int 0 to int ; <int> [#uses=0]
+ store %struct.trie_s* %t, %struct.trie_s** %t_addr
+ store %struct.FILE* %f, %struct.FILE** %f_addr
+ store int 0, int* %wstate
+ %tmp = getelementptr %struct.charsequence* %cs, uint 0, uint 0 ; <sbyte**> [#uses=1]
+ %tmp1 = getelementptr %struct.charsequence* %C.0.2294, uint 0, uint 0 ; <sbyte**> [#uses=1]
+ %tmp = load sbyte** %tmp1 ; <sbyte*> [#uses=1]
+ store sbyte* %tmp, sbyte** %tmp
+ %tmp = getelementptr %struct.charsequence* %cs, uint 0, uint 1 ; <uint*> [#uses=1]
+ %tmp2 = getelementptr %struct.charsequence* %C.0.2294, uint 0, uint 1 ; <uint*> [#uses=1]
+ %tmp = load uint* %tmp2 ; <uint> [#uses=1]
+ store uint %tmp, uint* %tmp
+ %tmp3 = getelementptr %struct.charsequence* %cs, uint 0, uint 2 ; <uint*> [#uses=1]
+ %tmp4 = getelementptr %struct.charsequence* %C.0.2294, uint 0, uint 2 ; <uint*> [#uses=1]
+ %tmp5 = load uint* %tmp4 ; <uint> [#uses=1]
+ store uint %tmp5, uint* %tmp3
+ br label %bb33
+
+bb: ; preds = %bb33
+ %tmp = load %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1]
+ %tmp = call int %_IO_getc( %struct.FILE* %tmp ) ; <int> [#uses=1]
+ %tmp6 = call int %tolower( int %tmp ) ; <int> [#uses=1]
+ %tmp6 = trunc int %tmp6 to sbyte ; <sbyte> [#uses=1]
+ store sbyte %tmp6, sbyte* %c
+ %tmp7 = load int* %wstate ; <int> [#uses=1]
+ %tmp = icmp ne int %tmp7, 0 ; <bool> [#uses=1]
+ br bool %tmp, label %cond_true, label %cond_false
+
+cond_true: ; preds = %bb
+ %tmp = load sbyte* %c ; <sbyte> [#uses=1]
+ %tmp8 = icmp sle sbyte %tmp, 96 ; <bool> [#uses=1]
+ br bool %tmp8, label %cond_true9, label %cond_next
+
+cond_true9: ; preds = %cond_true
+ br label %bb16
+
+cond_next: ; preds = %cond_true
+ %tmp10 = load sbyte* %c ; <sbyte> [#uses=1]
+ %tmp11 = icmp sgt sbyte %tmp10, 122 ; <bool> [#uses=1]
+ br bool %tmp11, label %cond_true12, label %cond_next13
+
+cond_true12: ; preds = %cond_next
+ br label %bb16
+
+cond_next13: ; preds = %cond_next
+ %tmp14 = load sbyte* %c ; <sbyte> [#uses=1]
+ %tmp14 = sext sbyte %tmp14 to int ; <int> [#uses=1]
+ %tmp1415 = trunc int %tmp14 to sbyte ; <sbyte> [#uses=1]
+ call void %charsequence_push( %struct.charsequence* %cs, sbyte %tmp1415 )
+ br label %bb21
+
+bb16: ; preds = %cond_true12, %cond_true9
+ %tmp17 = call sbyte* %charsequence_val( %struct.charsequence* %cs ) ; <sbyte*> [#uses=1]
+ store sbyte* %tmp17, sbyte** %str
+ %tmp = load %struct.trie_s** %t_addr ; <%struct.trie_s*> [#uses=1]
+ %tmp18 = load sbyte** %str ; <sbyte*> [#uses=1]
+ %tmp19 = call %struct.trie_s* %trie_insert( %struct.trie_s* %tmp, sbyte* %tmp18 ) ; <%struct.trie_s*> [#uses=0]
+ %tmp20 = load sbyte** %str ; <sbyte*> [#uses=1]
+ call void %free( sbyte* %tmp20 )
+ store int 0, int* %wstate
+ br label %bb21
+
+bb21: ; preds = %bb16, %cond_next13
+ br label %cond_next32
+
+cond_false: ; preds = %bb
+ %tmp22 = load sbyte* %c ; <sbyte> [#uses=1]
+ %tmp23 = icmp sgt sbyte %tmp22, 96 ; <bool> [#uses=1]
+ br bool %tmp23, label %cond_true24, label %cond_next31
+
+cond_true24: ; preds = %cond_false
+ %tmp25 = load sbyte* %c ; <sbyte> [#uses=1]
+ %tmp26 = icmp sle sbyte %tmp25, 122 ; <bool> [#uses=1]
+ br bool %tmp26, label %cond_true27, label %cond_next30
+
+cond_true27: ; preds = %cond_true24
+ call void %charsequence_reset( %struct.charsequence* %cs )
+ %tmp28 = load sbyte* %c ; <sbyte> [#uses=1]
+ %tmp28 = sext sbyte %tmp28 to int ; <int> [#uses=1]
+ %tmp2829 = trunc int %tmp28 to sbyte ; <sbyte> [#uses=1]
+ call void %charsequence_push( %struct.charsequence* %cs, sbyte %tmp2829 )
+ store int 1, int* %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 int %feof( %struct.FILE* %tmp34 ) ; <int> [#uses=1]
+ %tmp36 = icmp eq int %tmp35, 0 ; <bool> [#uses=1]
+ br bool %tmp36, label %bb, label %bb37
+
+bb37: ; preds = %bb33
+ br label %return
+
+return: ; preds = %bb37
+ ret void
+}
+
diff --git a/test/Transforms/SimplifyCFG/BrUnwind.ll b/test/Transforms/SimplifyCFG/BrUnwind.ll
new file mode 100644
index 0000000..73bd975
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/BrUnwind.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep {br label}
+
+void %test(bool %C) {
+ br bool %C, label %A, label %B
+A:
+ call void %test(bool %C)
+ br label %X
+B:
+ call void %test(bool %C)
+ br label %X
+X:
+ unwind
+}
diff --git a/test/Transforms/SimplifyCFG/DeadSetCC.ll b/test/Transforms/SimplifyCFG/DeadSetCC.ll
new file mode 100644
index 0000000..ea215e3
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/DeadSetCC.ll
@@ -0,0 +1,27 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; 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()
+
+void %testcfg(uint %V) {
+ %C = seteq uint %V, 18
+ %D = seteq uint %V, 180
+ %E = or bool %C, %D
+ br bool %E, label %L1, label %Sw
+Sw:
+ switch uint %V, label %L1 [
+ uint 15, label %L2
+ uint 16, label %L2
+ ]
+L1:
+ call void %foo()
+ ret void
+L2:
+ 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..3c1f141
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/EqualPHIEdgeBlockMerge.ll
@@ -0,0 +1,18 @@
+; Test merging of blocks with phi nodes.
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep N:
+;
+
+int %test(bool %a) {
+Q:
+ br bool %a, label %N, label %M
+N:
+ br label %M
+M:
+ ; It's ok to merge N and M because the incoming values for W are the
+ ; same for both cases...
+ %W = phi int [2, %N], [2, %Q]
+ %R = add int %W, 1
+ ret int %R
+}
+
diff --git a/test/Transforms/SimplifyCFG/HoistCode.ll b/test/Transforms/SimplifyCFG/HoistCode.ll
new file mode 100644
index 0000000..b817477
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/HoistCode.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+
+void %foo(bool %C, int* %P) {
+ br bool %C, label %T, label %F
+T:
+ store int 7, int* %P
+ ret void
+F:
+ store int 7, int* %P
+ ret void
+}
diff --git a/test/Transforms/SimplifyCFG/InvokeEliminate.ll b/test/Transforms/SimplifyCFG/InvokeEliminate.ll
new file mode 100644
index 0000000..89d76a8
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/InvokeEliminate.ll
@@ -0,0 +1,18 @@
+; This testcase checks to see if the simplifycfg pass is converting invoke
+; instructions to call instructions if the handler just rethrows the exception.
+
+; If this test is successful, the function should be reduced to 'call; ret'
+
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not egrep {\\(invoke\\)|\\(br\\)}
+
+declare void %bar()
+
+int %test() {
+ invoke void %bar() to label %Ok except label %Rethrow
+Ok:
+ ret int 0
+Rethrow:
+ unwind
+}
+
diff --git a/test/Transforms/SimplifyCFG/PhiBlockMerge.ll b/test/Transforms/SimplifyCFG/PhiBlockMerge.ll
new file mode 100644
index 0000000..7b24426
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/PhiBlockMerge.ll
@@ -0,0 +1,23 @@
+; Test merging of blocks that only have PHI nodes in them
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep N:
+;
+
+int %test(bool %a, bool %b) {
+ br bool %a, label %M, label %O
+
+O:
+ br bool %b, label %N, label %Q
+Q:
+ br label %N
+N:
+ %Wp = phi int [0, %O], [1, %Q]
+ ; This block should be foldable into M
+ br label %M
+
+M:
+ %W = phi int [%Wp, %N], [2, %0]
+ %R = add int %W, 1
+ ret int %R
+}
+
diff --git a/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll b/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll
new file mode 100644
index 0000000..01060ed
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/PhiBlockMerge2.ll
@@ -0,0 +1,21 @@
+; 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: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep N:
+;
+
+int %test(bool %a, bool %b) {
+ br bool %b, label %N, label %Q
+Q:
+ br label %N
+N:
+ %W = phi int [0, %0], [1, %Q]
+ ; This block should be foldable into M
+ br label %M
+
+M:
+ %R = add int %W, 1
+ ret int %R
+}
+
diff --git a/test/Transforms/SimplifyCFG/PhiEliminate.ll b/test/Transforms/SimplifyCFG/PhiEliminate.ll
new file mode 100644
index 0000000..ef2433c
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/PhiEliminate.ll
@@ -0,0 +1,38 @@
+; 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: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis > %t.xform
+; RUN: not grep phi %t.xform
+; RUN: grep ret %t.xform
+
+declare void %use(bool)
+declare void %use(int)
+
+
+void %test2(bool %c, bool %d, int %V, int %V2) {
+ br bool %d, label %X, label %F
+X:
+ br bool %c, label %T, label %F
+T:
+ br label %F
+F:
+ %B1 = phi bool [true, %0], [false, %T], [false, %X]
+ %I7 = phi int [%V, %0], [%V2, %T], [%V2, %X]
+ call void %use(bool %B1)
+ call void %use(int %I7)
+ ret void
+}
+
+void %test(bool %c, int %V, int %V2) {
+ br bool %c, label %T, label %F
+T:
+ br label %F
+F:
+ %B1 = phi bool [true, %0], [false, %T]
+ %I6 = phi int [%V, %0], [0, %T]
+ call void %use(bool %B1)
+ call void %use(int %I6)
+ ret void
+}
diff --git a/test/Transforms/SimplifyCFG/PhiEliminate2.ll b/test/Transforms/SimplifyCFG/PhiEliminate2.ll
new file mode 100644
index 0000000..fb00a13
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/PhiEliminate2.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+
+int %test(bool %C, int %V1, int %V2) {
+entry:
+ br bool %C, label %then, label %Cont
+
+then:
+ %V3 = or int %V2, %V1
+ br label %Cont
+Cont:
+ %V4 = phi int [%V1, %entry], [%V3, %then]
+ call int %test(bool false, int 0, int 0) ;; don't fold into preds
+ ret int %V1
+}
+
diff --git a/test/Transforms/SimplifyCFG/PhiNoEliminate.ll b/test/Transforms/SimplifyCFG/PhiNoEliminate.ll
new file mode 100644
index 0000000..4535541
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/PhiNoEliminate.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; 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.
+
+int %bar(bool %C) {
+entry:
+ br bool %C, label %then, label %endif
+
+then:
+ %tmp.3 = call int %qux()
+ br label %endif
+
+endif:
+ %R = phi int [123, %entry], [12312, %then]
+ ;; stuff to disable tail duplication
+ call int %qux()
+ call int %qux()
+ call int %qux()
+ call int %qux()
+ call int %qux()
+ call int %qux()
+ call int %qux()
+ ret int %R
+}
+
+declare int %qux()
+
diff --git a/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll b/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll
new file mode 100644
index 0000000..6ab1621
--- /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: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep {br label}
+
+int %test(bool %B, int %A, int %B) {
+ br bool %B, label %T, label %F
+T:
+ br label %ret
+F:
+ br label %ret
+ret:
+ %X = phi int [%A, %F], [%B, %T]
+ ret int %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.
+int %test2(bool %B, int %A, int %B) {
+ br bool %B, label %T, label %F
+T:
+ call int %test(bool true, int 5, int 8)
+ br label %ret
+F:
+ call int %test(bool true, int 5, int 8)
+ br label %ret
+ret:
+ ret int %A
+}
+
diff --git a/test/Transforms/SimplifyCFG/UnreachableEliminate.ll b/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
new file mode 100644
index 0000000..22cd3d4
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
@@ -0,0 +1,29 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep unreachable
+
+void %test1(bool %C, bool* %BP) {
+ br bool %C, label %T, label %F
+T:
+ store bool %C, bool* %BP ;; dead
+ unreachable
+F:
+ ret void
+}
+
+void %test2() {
+ invoke void %test2() to label %N unwind label %U
+U:
+ unreachable
+N:
+ ret void
+}
+
+int %test3(int %v) {
+ switch int %v, label %default [ int 1, label %U
+ int 2, label %T]
+default:
+ ret int 1
+U:
+ unreachable
+T:
+ ret int 2
+}
diff --git a/test/Transforms/SimplifyCFG/basictest.ll b/test/Transforms/SimplifyCFG/basictest.ll
new file mode 100644
index 0000000..18fa897
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/basictest.ll
@@ -0,0 +1,24 @@
+; Test CFG simplify removal of branch instructions...
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+
+
+void "test1"() {
+ br label %BB1
+BB1:
+ ret void
+}
+
+void "test2"() {
+ ret void
+BB1:
+ ret void
+}
+
+void "test3"(bool %T) {
+ br bool %T, label %BB1, label %BB1
+BB1:
+ ret void
+}
+
+
diff --git a/test/Transforms/SimplifyCFG/branch-cond-merge.ll b/test/Transforms/SimplifyCFG/branch-cond-merge.ll
new file mode 100644
index 0000000..2a93057
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/branch-cond-merge.ll
@@ -0,0 +1,22 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -instcombine \
+; RUN: -simplifycfg | llvm-dis | not grep call
+
+declare void %bar()
+
+void %test(int %X, int %Y) {
+entry:
+ %tmp.2 = setne int %X, %Y
+ br bool %tmp.2, label %shortcirc_next, label %UnifiedReturnBlock
+
+shortcirc_next:
+ %tmp.3 = setne int %X, %Y
+ br bool %tmp.3, label %UnifiedReturnBlock, label %then
+
+then:
+ call void %bar( )
+ ret void
+
+UnifiedReturnBlock: ; preds = %entry, %shortcirc_next
+ 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..10270c2
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/branch-cond-prop.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep call
+
+declare void %bar()
+
+void %test(int %X, int %Y) {
+entry:
+ %tmp.2 = setlt int %X, %Y ; <bool> [#uses=2]
+ br bool %tmp.2, label %shortcirc_next, label %UnifiedReturnBlock
+
+shortcirc_next: ; preds = %entry
+ br bool %tmp.2, label %UnifiedReturnBlock, label %then
+
+then: ; preds = %shortcirc_next
+ call void %bar( )
+ ret void
+
+UnifiedReturnBlock: ; preds = %entry, %shortcirc_next
+ 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..3bbb101
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/branch-fold-test.ll
@@ -0,0 +1,16 @@
+; This test ensures that the simplifycfg pass continues to constant fold
+; terminator instructions.
+
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | not grep br
+
+int %test(int %A, int %B) {
+J:
+ %C = add int %A, 12
+ br bool true, label %L, label %K ; K is dead!
+L:
+ %D = add int %C, %B
+ ret int %D
+K:
+ %E = add int %C, %B
+ ret int %E
+}
diff --git a/test/Transforms/SimplifyCFG/branch-fold.ll b/test/Transforms/SimplifyCFG/branch-fold.ll
new file mode 100644
index 0000000..f13f826
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/branch-fold.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | grep {br i1} | wc -l | grep 1
+
+void %test(int* %P, int* %Q, bool %A, bool %B) {
+ br bool %A, label %a, label %b ;; fold the two branches into one
+a:
+ br bool %B, label %b, label %c
+b:
+ store int 123, int* %P
+ ret void
+c:
+ 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..e370978
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/branch-phi-thread.ll
@@ -0,0 +1,65 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -adce | llvm-dis | \
+; RUN: not grep {call void %f1}
+; END.
+
+declare void %f1()
+declare void %f2()
+declare void %f3()
+declare void %f4()
+
+implementation
+
+int %test1(int %X, bool %D) {
+E:
+ %C = seteq int %X, 0
+ br bool %C, label %T, label %F
+T:
+ br bool %C, label %B, label %A
+A:
+ call void %f1()
+ br bool %D, label %T, label %F
+B:
+ call void %f2()
+ ret int 345
+F:
+ call void %f3()
+ ret int 123
+}
+
+int %test2(int %X, bool %D) {
+E:
+ %C = seteq int %X, 0
+ br bool %C, label %T, label %F
+T:
+ %P = phi bool [true, %E], [%C, %A]
+ br bool %P, label %B, label %A
+A:
+ call void %f1()
+ br bool %D, label %T, label %F
+B:
+ call void %f2()
+ ret int 345
+F:
+ call void %f3()
+ ret int 123
+}
+
+int %test3(int %X, bool %D, int* %AP, int* %BP) {
+E:
+ %C = seteq int %X, 0
+ br bool %C, label %T, label %F
+T:
+ call void %f3() ;; Inst in block.
+ %XX = load int* %AP
+ store int %XX, int* %BP
+ br bool %C, label %B, label %A
+A:
+ call void %f1()
+ br bool %D, label %T, label %F
+B:
+ call void %f2()
+ ret int 345
+F:
+ call void %f3()
+ ret int 123
+}
diff --git a/test/Transforms/SimplifyCFG/dg.exp b/test/Transforms/SimplifyCFG/dg.exp
new file mode 100644
index 0000000..879685c
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]]
diff --git a/test/Transforms/SimplifyCFG/hoist-common-code.ll b/test/Transforms/SimplifyCFG/hoist-common-code.ll
new file mode 100644
index 0000000..482c5aa
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/hoist-common-code.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+declare void %bar(int)
+
+void %test(bool %P, int* %Q) {
+ br bool %P, label %T, label %F
+T:
+ store int 1, int* %Q
+ %A = load int* %Q
+ call void %bar(int %A)
+ ret void
+F:
+ store int 1, int* %Q
+ %B = load int* %Q
+ call void %bar(int %B)
+ ret void
+}
+
diff --git a/test/Transforms/SimplifyCFG/return-merge.ll b/test/Transforms/SimplifyCFG/return-merge.ll
new file mode 100644
index 0000000..cbcfddb
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/return-merge.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+
+int %test1(bool %C) {
+entry:
+ br bool %C, label %T, label %F
+T:
+ ret int 1
+F:
+ ret int 0
+}
+
+void %test2(bool %C) {
+ br bool %C, label %T, label %F
+T:
+ ret void
+F:
+ 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..096f2ae
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch-simplify-crash.ll
@@ -0,0 +1,153 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -disable-output
+
+
+void %NewExtractNames() {
+entry:
+ br bool false, label %endif.0, label %then.0
+
+then.0: ; preds = %entry
+ br bool 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 bool 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 bool false, label %endif.0.i, label %else.1.i
+
+else.1.i: ; preds = %else.0.i
+ br bool 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 uint 0, 31 ; <uint> [#uses=1]
+ switch uint %tmp.32.mask, label %label.9 [
+ uint 16, label %loopentry.2
+ uint 15, label %loopentry.2
+ uint 14, label %loopentry.2
+ uint 13, label %loopentry.2
+ uint 10, label %loopentry.2
+ uint 20, label %loopentry.1
+ uint 19, label %loopentry.1
+ uint 2, label %loopentry.0
+ uint 0, label %switchexit
+ ]
+
+loopentry.0: ; preds = %endif.1, %endif.0
+ br bool false, label %no_exit.0, label %switchexit
+
+no_exit.0: ; preds = %loopentry.0
+ br bool false, label %then.1, label %else.1
+
+then.1: ; preds = %no_exit.0
+ br label %endif.1
+
+else.1: ; preds = %no_exit.0
+ br bool 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 bool 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 bool false, label %no_exit.1, label %switchexit
+
+no_exit.1: ; preds = %loopentry.1
+ br bool false, label %then.3, label %else.2
+
+then.3: ; preds = %no_exit.1
+ br label %endif.3
+
+else.2: ; preds = %no_exit.1
+ br bool 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 bool 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 int [ 0, %endif.5 ], [ 0, %endif.0 ], [ 0, %endif.0 ], [ 0, %endif.0 ], [ 0, %endif.0 ], [ 0, %endif.0 ] ; <int> [#uses=1]
+ %tmp.158 = setlt int %i.3, 0 ; <bool> [#uses=1]
+ br bool %tmp.158, label %no_exit.2, label %switchexit
+
+no_exit.2: ; preds = %loopentry.2
+ br bool 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 bool 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 bool false, label %then.6, label %endif.6
+
+then.6: ; preds = %label.9
+ br label %endif.6
+
+endif.6: ; preds = %then.6, %label.9
+ store int 0, int* null
+ br label %switchexit
+
+switchexit: ; preds = %endif.6, %loopentry.2, %loopentry.1, %loopentry.0, %endif.0
+ br bool false, label %endif.7, label %then.7
+
+then.7: ; preds = %switchexit
+ br bool 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 bool 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..2d72291
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch_create.ll
@@ -0,0 +1,48 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+
+declare void %foo1()
+declare void %foo2()
+
+void %test1(uint %V) {
+ %C1 = seteq uint %V, 4
+ %C2 = seteq uint %V, 17
+ %CN = or bool %C1, %C2
+ br bool %CN, label %T, label %F
+T:
+ call void %foo1()
+ ret void
+F:
+ call void %foo2()
+ ret void
+}
+
+
+void %test2(int %V) {
+ %C1 = setne int %V, 4
+ %C2 = setne int %V, 17
+ %CN = and bool %C1, %C2
+ br bool %CN, label %T, label %F
+T:
+ call void %foo1()
+ ret void
+F:
+ call void %foo2()
+ ret void
+}
+
+
+void %test3(int %V) {
+ %C1 = seteq int %V, 4
+ br bool %C1, label %T, label %N
+N:
+ %C2 = seteq int %V, 17
+ br bool %C2, label %T, label %F
+T:
+ call void %foo1()
+ ret void
+F:
+ call void %foo2()
+ ret void
+}
+
+
diff --git a/test/Transforms/SimplifyCFG/switch_formation.ll b/test/Transforms/SimplifyCFG/switch_formation.ll
new file mode 100644
index 0000000..b372ca4b
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch_formation.ll
@@ -0,0 +1,37 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | not grep br
+; END.
+
+bool %_ZN4llvm11SetCondInst7classofEPKNS_11InstructionE({uint, uint}* %I) {
+entry:
+ %tmp.1.i = getelementptr {uint, uint}* %I, long 0, uint 1
+ %tmp.2.i = load uint* %tmp.1.i
+ %tmp.2 = seteq uint %tmp.2.i, 14
+ br bool %tmp.2, label %shortcirc_done.4, label %shortcirc_next.0
+
+shortcirc_next.0: ; preds = %entry
+ %tmp.6 = seteq uint %tmp.2.i, 15 ; <bool> [#uses=1]
+ br bool %tmp.6, label %shortcirc_done.4, label %shortcirc_next.1
+
+shortcirc_next.1: ; preds = %shortcirc_next.0
+ %tmp.11 = seteq uint %tmp.2.i, 16 ; <bool> [#uses=1]
+ br bool %tmp.11, label %shortcirc_done.4, label %shortcirc_next.2
+
+shortcirc_next.2: ; preds = %shortcirc_next.1
+ %tmp.16 = seteq uint %tmp.2.i, 17 ; <bool> [#uses=1]
+ br bool %tmp.16, label %shortcirc_done.4, label %shortcirc_next.3
+
+shortcirc_next.3: ; preds = %shortcirc_next.2
+ %tmp.21 = seteq uint %tmp.2.i, 18 ; <bool> [#uses=1]
+ br bool %tmp.21, label %shortcirc_done.4, label %shortcirc_next.4
+
+shortcirc_next.4: ; preds = %shortcirc_next.3
+ %tmp.26 = seteq uint %tmp.2.i, 19 ; <bool> [#uses=1]
+ br label %UnifiedReturnBlock
+
+shortcirc_done.4: ; preds = %entry, %shortcirc_next.0, %shortcirc_next.1, %shortcirc_next.2, %shortcirc_next.3
+ br label %UnifiedReturnBlock
+
+UnifiedReturnBlock: ; preds = %shortcirc_next.4, %shortcirc_done.4
+ %UnifiedRetVal = phi bool [ %tmp.26, %shortcirc_next.4 ], [ true, %shortcirc_done.4 ] ; <bool> [#uses=1]
+ ret bool %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..5403955
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch_switch_fold.ll
@@ -0,0 +1,47 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: grep switch | wc -l | grep 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()
+
+void %test1(uint %V) {
+ switch uint %V, label %F [
+ uint 4, label %T
+ uint 17, label %T
+ uint 5, label %T
+ uint 1234, label %F
+ ]
+
+T:
+ switch uint %V, label %F [
+ uint 4, label %A
+ uint 17, label %B
+ uint 42, label %C
+ ]
+A:
+ call void %foo1()
+ ret void
+
+B:
+ call void %foo2()
+ ret void
+C:
+ call void %foo3()
+ ret void
+
+F:
+ switch uint %V, label %F [
+ uint 4, label %B
+ uint 18, label %B
+ uint 42, label %D
+ ]
+D:
+ call void %foo4()
+ ret void
+}
+
diff --git a/test/Transforms/SimplifyCFG/switch_thread.ll b/test/Transforms/SimplifyCFG/switch_thread.ll
new file mode 100644
index 0000000..f120851
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch_thread.ll
@@ -0,0 +1,79 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; 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()
+
+void %test1(uint %V) {
+ switch uint %V, label %A [
+ uint 4, label %T
+ uint 17, label %Done
+ uint 1234, label %A
+ ]
+
+T: ;; V == 4 if we get here.
+ call void %foo1()
+ ;; This switch is always statically determined.
+ switch uint %V, label %A2 [
+ uint 4, label %B
+ uint 17, label %C
+ uint 42, label %C
+ ]
+A2:
+ call void %DEAD()
+ call void %DEAD()
+ %cond2 = seteq uint %V, 4 ;; always false
+ br bool %cond2, label %Done, label %C
+
+A:
+ call void %foo1()
+ %cond = setne uint %V, 4 ;; always true
+ br bool %cond, label %Done, label %C
+
+
+Done:
+ ret void
+
+B:
+ call void %foo2()
+ %cond3 = seteq uint %V, 4 ;; always true
+ br bool %cond3, label %Done, label %C
+C:
+ call void %DEAD()
+ ret void
+}
+
+void %test2(uint %V) {
+ switch uint %V, label %A [
+ uint 4, label %T
+ uint 17, label %D
+ uint 1234, label %E
+ ]
+
+A: ;; V != 4, 17, 1234 here.
+ call void %foo1()
+ ;; This switch is always statically determined.
+ switch uint %V, label %E [
+ uint 4, label %C
+ uint 17, label %C
+ uint 42, label %D
+ ]
+C:
+ call void %DEAD() ;; unreacahble.
+ ret void
+T:
+ call void %foo1()
+ call void %foo1()
+ ret void
+
+D:
+ call void %foo1()
+ ret void
+
+E:
+ ret void
+}
+