diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:10:27 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:10:27 +0000 |
commit | 30815c536baacc07e925f0aef23a5395883173dc (patch) | |
tree | 2cbcf22585e99f8a87d12d5ff94f392c0d266819 /test/Transforms/SimplifyCFG | |
parent | 411bd29eea3c360d5b48a18a17b5e87f5671af0e (diff) |
Diffstat (limited to 'test/Transforms/SimplifyCFG')
12 files changed, 203 insertions, 26 deletions
diff --git a/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll index c019931c07e75..7551e8fb747c7 100644 --- a/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll +++ b/test/Transforms/SimplifyCFG/2003-08-05-InvokeCrash.ll @@ -8,6 +8,9 @@ define i32 @test() { Ret: ; preds = %0 ret i32 %A Ret2: ; preds = %0 + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null ret i32 undef } +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll b/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll index 15cd7730449ee..bc61a75561d36 100644 --- a/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll +++ b/test/Transforms/SimplifyCFG/2003-08-05-MishandleInvoke.ll @@ -6,7 +6,10 @@ define i32 @test() { invoke i32 @test( ) to label %Ret unwind label %Ret ; <i32>:1 [#uses=0] Ret: ; preds = %0, %0 + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null %A = add i32 0, 1 ; <i32> [#uses=1] ret i32 %A } +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll b/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll index 778aa3b1f7b43..2ecdc95259cc7 100644 --- a/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll +++ b/test/Transforms/SimplifyCFG/2005-10-02-InvokeSimplify.ll @@ -4,6 +4,8 @@ define i1 @foo() { %X = invoke i1 @foo( ) to label %N unwind label %F ; <i1> [#uses=1] F: ; preds = %0 + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + catch i8* null ret i1 false N: ; preds = %0 br i1 %X, label %A, label %B @@ -13,3 +15,4 @@ B: ; preds = %N ret i1 true } +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll index dba41c9b111fd..27d9d8f674181 100644 --- a/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll +++ b/test/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll @@ -275,12 +275,16 @@ invcont153: ; preds = %invcont151 invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) to label %cleanup171 unwind label %cleanup173 cleanup168: ; preds = %invcont151, %invcont148, %invcont146 + %val168 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) to label %cleanup173 unwind label %cleanup173 cleanup171: ; preds = %invcont153 invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) to label %finally170 unwind label %cleanup192 cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 + %val173 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) to label %cleanup192 unwind label %cleanup192 finally170: ; preds = %cleanup171 @@ -300,12 +304,16 @@ cleanup185: ; preds = %invcont181 invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) to label %cleanup190 unwind label %cleanup192 cleanup187: ; preds = %invcont181, %invcont179, %invcont177 + %val187 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup 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 + %val192 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) to label %cleanup329 unwind label %cleanup329 cond_next194: ; preds = %cleanup190, %invcont83 @@ -450,8 +458,10 @@ 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 + %val = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - unwind + resume { i8*, i32 } %val } declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) @@ -553,3 +563,5 @@ declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) declare void @_ZN8QPainterD1Ev(%struct.QPainter*) + +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll b/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll index 33167bd5c661d..568e61c6ac6de 100644 --- a/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll +++ b/test/Transforms/SimplifyCFG/2009-01-19-UnconditionalTrappingConstantExpr.ll @@ -15,7 +15,7 @@ bb2: ret i32 42 bb6: - unwind + ret i32 927 } define i32 @test2(i32 %tmp21, i32 %tmp24, i1 %tmp34) { @@ -26,6 +26,6 @@ bb5: ; preds = %bb4 bb6: ret i32 42 bb7: - unwind + ret i32 927 } diff --git a/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll index f99cbe1c8b83d..abf4455d780ba 100644 --- a/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll +++ b/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll @@ -277,12 +277,16 @@ invcont153: ; preds = %invcont151 invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) to label %cleanup171 unwind label %cleanup173 cleanup168: ; preds = %invcont151, %invcont148, %invcont146 + %val168 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) to label %cleanup173 unwind label %cleanup173 cleanup171: ; preds = %invcont153 invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) to label %finally170 unwind label %cleanup192 cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 + %val173 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) to label %cleanup192 unwind label %cleanup192 finally170: ; preds = %cleanup171 @@ -302,12 +306,16 @@ cleanup185: ; preds = %invcont181 invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) to label %cleanup190 unwind label %cleanup192 cleanup187: ; preds = %invcont181, %invcont179, %invcont177 + %val187 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup 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 + %val192 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) to label %cleanup329 unwind label %cleanup329 cond_next194: ; preds = %cleanup190, %invcont83 @@ -452,8 +460,10 @@ 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 + %val329 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + cleanup call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) - unwind + resume { i8*, i32 } %val329 } declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) @@ -555,3 +565,5 @@ declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) declare void @_ZN8QPainterD1Ev(%struct.QPainter*) + +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll b/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll index ced89cf4c2b31..7bffa1a8e0e2f 100644 --- a/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll +++ b/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll @@ -14,5 +14,9 @@ r: ; preds = %entry ret void u: ; preds = %entry - unwind + %val = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 + cleanup + resume { i8*, i32 } %val } + +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll b/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll new file mode 100644 index 0000000000000..7558419a2ebda --- /dev/null +++ b/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll @@ -0,0 +1,22 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s + +; CHECK-NOT: invoke +; CHECK-NOT: landingpad + +declare void @bar() + +define i32 @foo() { +entry: + invoke void @bar() + to label %return unwind label %lpad + +return: + ret i32 0 + +lpad: + %lp = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 + cleanup + resume { i8*, i32 } %lp +} + +declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*) diff --git a/test/Transforms/SimplifyCFG/BrUnwind.ll b/test/Transforms/SimplifyCFG/BrUnwind.ll index b19a27dea048d..7ab8faa2cea98 100644 --- a/test/Transforms/SimplifyCFG/BrUnwind.ll +++ b/test/Transforms/SimplifyCFG/BrUnwind.ll @@ -10,6 +10,6 @@ B: ; preds = %0 call void @test( i1 %C ) br label %X X: ; preds = %B, %A - unwind + ret void } diff --git a/test/Transforms/SimplifyCFG/invoke_unwind.ll b/test/Transforms/SimplifyCFG/invoke_unwind.ll index 73faa952fba93..ed7ff8287f20d 100644 --- a/test/Transforms/SimplifyCFG/invoke_unwind.ll +++ b/test/Transforms/SimplifyCFG/invoke_unwind.ll @@ -12,21 +12,9 @@ define i32 @test1() { to label %1 unwind label %Rethrow ret i32 0 Rethrow: - unwind + %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + catch i8* null + resume { i8*, i32 } %exn } - -; Verify that simplifycfg isn't duplicating 'unwind' instructions. Doing this -; is bad because it discourages commoning. -define i32 @test2(i1 %c) { -; CHECK: @test2 -; CHECK: T: -; CHECK-NEXT: call void @bar() -; CHECK-NEXT: br label %F - br i1 %c, label %T, label %F -T: - call void @bar() - br label %F -F: - unwind -} +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll b/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll new file mode 100644 index 0000000000000..65d888ea01e10 --- /dev/null +++ b/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll @@ -0,0 +1,87 @@ +; RUN: opt -simplifycfg -S < %s | FileCheck %s + +declare void @bar() nounwind + +define i32 @test1(i32* %a, i32 %b, i32* %c, i32 %d) nounwind { +entry: + %tobool = icmp eq i32 %b, 0 + br i1 %tobool, label %if.else, label %if.then + +if.then: ; preds = %entry + tail call void @bar() nounwind + br label %if.end7 + +if.else: ; preds = %entry + %tobool3 = icmp eq i32 %d, 0 + br i1 %tobool3, label %if.end7, label %if.then4 + +if.then4: ; preds = %if.else + tail call void @bar() nounwind + br label %if.end7 + +if.end7: ; preds = %if.else, %if.then4, %if.then + %x.0 = phi i32* [ %a, %if.then ], [ %c, %if.then4 ], [ null, %if.else ] + %tmp9 = load i32* %x.0 + ret i32 %tmp9 + +; CHECK: @test1 +; CHECK: if.else: +; CHECK: br label %if.end7 + +; CHECK: phi i32* [ %a, %if.then ], [ %c, %if.else ] +} + +define i32 @test2(i32* %a, i32 %b, i32* %c, i32 %d) nounwind { +entry: + %tobool = icmp eq i32 %b, 0 + br i1 %tobool, label %if.else, label %if.then + +if.then: ; preds = %entry + tail call void @bar() nounwind + br label %if.end7 + +if.else: ; preds = %entry + %tobool3 = icmp eq i32 %d, 0 + br i1 %tobool3, label %if.end7, label %if.then4 + +if.then4: ; preds = %if.else + tail call void @bar() nounwind + br label %if.end7 + +if.end7: ; preds = %if.else, %if.then4, %if.then + %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] + %tmp9 = load i32* %x.0 + ret i32 %tmp9 +; CHECK: @test2 +; CHECK: if.else: +; CHECK: unreachable + +; CHECK-NOT: phi +} + +define i32 @test3(i32* %a, i32 %b, i32* %c, i32 %d) nounwind { +entry: + %tobool = icmp eq i32 %b, 0 + br i1 %tobool, label %if.else, label %if.then + +if.then: ; preds = %entry + tail call void @bar() nounwind + br label %if.end7 + +if.else: ; preds = %entry + %tobool3 = icmp eq i32 %d, 0 + br i1 %tobool3, label %if.end7, label %if.then4 + +if.then4: ; preds = %if.else + tail call void @bar() nounwind + br label %if.end7 + +if.end7: ; preds = %if.else, %if.then4, %if.then + %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] + tail call void @bar() nounwind + %tmp9 = load i32* %x.0 + ret i32 %tmp9 +; CHECK: @test3 +; CHECK: if.end7: +; CHECK: phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] +} diff --git a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll index 7bca5f5afa0d6..10d6981af0e67 100644 --- a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll +++ b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll @@ -11,14 +11,14 @@ entry: br i1 %0, label %bb, label %return bb: ; preds = %entry - %1 = volatile load i32* null + %1 = load volatile i32* null unreachable br label %return return: ; preds = %entry ret void ; CHECK: @test1 -; CHECK: volatile load +; CHECK: load volatile } ; rdar://7958343 @@ -35,10 +35,53 @@ entry: ; PR7369 define void @test3() nounwind { entry: - volatile store i32 4, i32* null + store volatile i32 4, i32* null ret void ; CHECK: @test3 -; CHECK: volatile store i32 4, i32* null +; CHECK: store volatile i32 4, i32* null ; CHECK: ret } + +; Check store before unreachable. +define void @test4(i1 %C, i32* %P) { +; CHECK: @test4 +; CHECK: entry: +; CHECK-NEXT: br i1 %C +entry: + br i1 %C, label %T, label %F +T: + store volatile i32 0, i32* %P + unreachable +F: + ret void +} + +; Check cmpxchg before unreachable. +define void @test5(i1 %C, i32* %P) { +; CHECK: @test5 +; CHECK: entry: +; CHECK-NEXT: br i1 %C +entry: + br i1 %C, label %T, label %F +T: + cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst + unreachable +F: + ret void +} + +; Check atomicrmw before unreachable. +define void @test6(i1 %C, i32* %P) { +; CHECK: @test6 +; CHECK: entry: +; CHECK-NEXT: br i1 %C +entry: + br i1 %C, label %T, label %F +T: + atomicrmw volatile xchg i32* %P, i32 0 seq_cst + unreachable +F: + ret void +} + |