diff options
Diffstat (limited to 'test/Transforms/Util')
-rw-r--r-- | test/Transforms/Util/flattencfg.ll | 26 | ||||
-rw-r--r-- | test/Transforms/Util/lowerswitch.ll | 22 |
2 files changed, 48 insertions, 0 deletions
diff --git a/test/Transforms/Util/flattencfg.ll b/test/Transforms/Util/flattencfg.ll new file mode 100644 index 0000000..4fcb77a --- /dev/null +++ b/test/Transforms/Util/flattencfg.ll @@ -0,0 +1,26 @@ +; RUN: opt -flattencfg -S < %s | FileCheck %s + + +; This test checks whether the pass completes without a crash. +; The code is not transformed in any way +; +; CHECK-LABEL: @test_not_crash +define void @test_not_crash(i32 %in_a) #0 { +entry: + %cmp0 = icmp eq i32 %in_a, -1 + %cmp1 = icmp ne i32 %in_a, 0 + %cond0 = and i1 %cmp0, %cmp1 + br i1 %cond0, label %b0, label %b1 + +b0: ; preds = %entry + %cmp2 = icmp eq i32 %in_a, 0 + %cmp3 = icmp ne i32 %in_a, 1 + %cond1 = or i1 %cmp2, %cmp3 + br i1 %cond1, label %exit, label %b1 + +b1: ; preds = %entry, %b0 + br label %exit + +exit: ; preds = %entry, %b0, %b1 + ret void +} diff --git a/test/Transforms/Util/lowerswitch.ll b/test/Transforms/Util/lowerswitch.ll new file mode 100644 index 0000000..06bd4cc --- /dev/null +++ b/test/Transforms/Util/lowerswitch.ll @@ -0,0 +1,22 @@ +; RUN: opt -lowerswitch -S < %s | FileCheck %s + +; Test that we don't crash and have a different basic block for each incoming edge. +define void @test_lower_switch() { +; CHECK-LABEL: @test_lower_switch +; CHECK: %merge = phi i64 [ 1, %BB3 ], [ 0, %NewDefault ], [ 0, %NodeBlock5 ], [ 0, %LeafBlock1 ] +BB1: + switch i32 undef, label %BB2 [ + i32 3, label %BB2 + i32 5, label %BB2 + i32 0, label %BB3 + i32 2, label %BB3 + i32 4, label %BB3 + ] + +BB2: + %merge = phi i64 [ 1, %BB3 ], [ 0, %BB1 ], [ 0, %BB1 ], [ 0, %BB1 ] + ret void + +BB3: + br label %BB2 +} |