diff options
Diffstat (limited to 'llvm/test')
6 files changed, 147 insertions, 0 deletions
diff --git a/llvm/test/Transforms/BlockExtractor/extract-blocks.ll b/llvm/test/Transforms/BlockExtractor/extract-blocks.ll new file mode 100644 index 00000000000..daf9a0923ce --- /dev/null +++ b/llvm/test/Transforms/BlockExtractor/extract-blocks.ll @@ -0,0 +1,43 @@ +; RUN: echo 'foo bb9' > %t +; RUN: echo 'foo bb20' >> %t +; RUN: opt -S -extract-blocks -extract-blocks-file=%t %s | FileCheck %s --check-prefix=CHECK-NO-ERASE +; RUN: opt -S -extract-blocks -extract-blocks-file=%t -extract-blocks-erase-funcs %s | FileCheck %s --check-prefix=CHECK-ERASE + +; CHECK-NO-ERASE: @foo( +; CHECK-NO-ERASE: @foo_bb9( +; CHECK-NO-ERASE: @foo_bb20( +; CHECK-ERASE-NOT: @foo( +; CHECK-ERASE: @foo_bb9( +; CHECK-ERASE: @foo_bb20( +define i32 @foo(i32 %arg, i32 %arg1) { +bb: + %tmp5 = icmp sgt i32 %arg, 0 + %tmp8 = icmp sgt i32 %arg1, 0 + %or.cond = and i1 %tmp5, %tmp8 + br i1 %or.cond, label %bb9, label %bb14 + +bb9: ; preds = %bb + %tmp12 = shl i32 %arg1, 2 + %tmp13 = add nsw i32 %tmp12, %arg + br label %bb30 + +bb14: ; preds = %bb + %0 = and i32 %arg1, %arg + %1 = icmp slt i32 %0, 0 + br i1 %1, label %bb20, label %bb26 + +bb20: ; preds = %bb14 + %tmp22 = mul nsw i32 %arg, 3 + %tmp24 = sdiv i32 %arg1, 6 + %tmp25 = add nsw i32 %tmp24, %tmp22 + br label %bb30 + +bb26: ; preds = %bb14 + %tmp29 = sub nsw i32 %arg, %arg1 + br label %bb30 + +bb30: ; preds = %bb26, %bb20, %bb9 + %tmp.0 = phi i32 [ %tmp13, %bb9 ], [ %tmp25, %bb20 ], [ %tmp29, %bb26 ] + ret i32 %tmp.0 +} + diff --git a/llvm/test/Transforms/BlockExtractor/invalid-block.ll b/llvm/test/Transforms/BlockExtractor/invalid-block.ll new file mode 100644 index 00000000000..f444764e991 --- /dev/null +++ b/llvm/test/Transforms/BlockExtractor/invalid-block.ll @@ -0,0 +1,9 @@ +; RUN: echo 'bar invalidbb' > %t +; RUN: not opt -S -extract-blocks -extract-blocks-file=%t %s 2>&1 | FileCheck %s + +; CHECK: Invalid block +define void @bar() { +bb: + ret void +} + diff --git a/llvm/test/Transforms/BlockExtractor/invalid-function.ll b/llvm/test/Transforms/BlockExtractor/invalid-function.ll new file mode 100644 index 00000000000..4044815893e --- /dev/null +++ b/llvm/test/Transforms/BlockExtractor/invalid-function.ll @@ -0,0 +1,9 @@ +; RUN: echo 'foo bb' > %t +; RUN: not opt -S -extract-blocks -extract-blocks-file=%t %s 2>&1 | FileCheck %s + +; CHECK: Invalid function +define void @bar() { +bb: + ret void +} + diff --git a/llvm/test/tools/llvm-extract/extract-block.ll b/llvm/test/tools/llvm-extract/extract-block.ll new file mode 100644 index 00000000000..761ed3268aa --- /dev/null +++ b/llvm/test/tools/llvm-extract/extract-block.ll @@ -0,0 +1,29 @@ +; RUN: llvm-extract -S -bb foo:bb4 %s | FileCheck %s + +; CHECK: @foo_bb4 +; CHECK: %tmp5 +define i32 @foo(i32 %arg) { +bb: + %tmp = alloca i32, align 4 + %tmp1 = alloca i32, align 4 + store i32 %arg, i32* %tmp1, align 4 + %tmp2 = load i32, i32* %tmp1, align 4 + %tmp3 = icmp sgt i32 %tmp2, 0 + br i1 %tmp3, label %bb4, label %bb7 + +bb4: ; preds = %bb + %tmp5 = load i32, i32* %tmp1, align 4 + %tmp6 = add nsw i32 %tmp5, 1 + store i32 %tmp6, i32* %tmp1, align 4 + store i32 %tmp6, i32* %tmp, align 4 + br label %bb8 + +bb7: ; preds = %bb + store i32 0, i32* %tmp, align 4 + br label %bb8 + +bb8: ; preds = %bb7, %bb4 + %tmp9 = load i32, i32* %tmp, align 4 + ret i32 %tmp9 +} + diff --git a/llvm/test/tools/llvm-extract/extract-invalid-block.ll b/llvm/test/tools/llvm-extract/extract-invalid-block.ll new file mode 100644 index 00000000000..04b40ca2b84 --- /dev/null +++ b/llvm/test/tools/llvm-extract/extract-invalid-block.ll @@ -0,0 +1,28 @@ +; RUN: not llvm-extract -S -bb foo:invalidbb %s 2>&1 | FileCheck %s + +; CHECK: function foo doesn't contain a basic block named 'invalidbb'! +define i32 @foo(i32 %arg) { +bb: + %tmp = alloca i32, align 4 + %tmp1 = alloca i32, align 4 + store i32 %arg, i32* %tmp1, align 4 + %tmp2 = load i32, i32* %tmp1, align 4 + %tmp3 = icmp sgt i32 %tmp2, 0 + br i1 %tmp3, label %bb4, label %bb7 + +bb4: ; preds = %bb + %tmp5 = load i32, i32* %tmp1, align 4 + %tmp6 = add nsw i32 %tmp5, 1 + store i32 %tmp6, i32* %tmp1, align 4 + store i32 %tmp6, i32* %tmp, align 4 + br label %bb8 + +bb7: ; preds = %bb + store i32 0, i32* %tmp, align 4 + br label %bb8 + +bb8: ; preds = %bb7, %bb4 + %tmp9 = load i32, i32* %tmp, align 4 + ret i32 %tmp9 +} + diff --git a/llvm/test/tools/llvm-extract/extract-multiple-blocks.ll b/llvm/test/tools/llvm-extract/extract-multiple-blocks.ll new file mode 100644 index 00000000000..a7f270bdcd6 --- /dev/null +++ b/llvm/test/tools/llvm-extract/extract-multiple-blocks.ll @@ -0,0 +1,29 @@ +; RUN: llvm-extract -S -bb foo:bb4 -bb foo:bb7 %s | FileCheck %s + +; CHECK: @foo_bb4 +; CHECK: @foo_bb7 +define i32 @foo(i32 %arg) { +bb: + %tmp = alloca i32, align 4 + %tmp1 = alloca i32, align 4 + store i32 %arg, i32* %tmp1, align 4 + %tmp2 = load i32, i32* %tmp1, align 4 + %tmp3 = icmp sgt i32 %tmp2, 0 + br i1 %tmp3, label %bb4, label %bb7 + +bb4: ; preds = %bb + %tmp5 = load i32, i32* %tmp1, align 4 + %tmp6 = add nsw i32 %tmp5, 1 + store i32 %tmp6, i32* %tmp1, align 4 + store i32 %tmp6, i32* %tmp, align 4 + br label %bb8 + +bb7: ; preds = %bb + store i32 0, i32* %tmp, align 4 + br label %bb8 + +bb8: ; preds = %bb7, %bb4 + %tmp9 = load i32, i32* %tmp, align 4 + ret i32 %tmp9 +} + |