xref: /llvm-project/llvm/test/Transforms/BlockExtractor/extract-blocks.ll (revision 3528e63d89305907b3d6e0f59f7b03b94a12dacc)
1cee313d2SEric Christopher; RUN: echo 'foo bb9' > %t
2cee313d2SEric Christopher; RUN: echo 'foo bb20' >> %t
3*da02ecb3SRoman Lebedev; RUN: opt -S -passes=extract-blocks -extract-blocks-file=%t %s | FileCheck %s --check-prefix=CHECK-NO-ERASE
4*da02ecb3SRoman Lebedev; RUN: opt -S -passes=extract-blocks -extract-blocks-file=%t -extract-blocks-erase-funcs %s | FileCheck %s --check-prefix=CHECK-ERASE
5cee313d2SEric Christopher
6cee313d2SEric Christopher; CHECK-NO-ERASE: @foo(
7cee313d2SEric Christopher; CHECK-NO-ERASE: @foo.bb9(
8cee313d2SEric Christopher; CHECK-NO-ERASE: @foo.bb20(
9cee313d2SEric Christopher; CHECK-ERASE: declare i32 @foo(
10cee313d2SEric Christopher; CHECK-ERASE: @foo.bb9(
11cee313d2SEric Christopher; CHECK-ERASE: @foo.bb20(
12cee313d2SEric Christopherdefine i32 @foo(i32 %arg, i32 %arg1) {
13cee313d2SEric Christopherbb:
14cee313d2SEric Christopher  %tmp5 = icmp sgt i32 %arg, 0
15cee313d2SEric Christopher  %tmp8 = icmp sgt i32 %arg1, 0
16cee313d2SEric Christopher  %or.cond = and i1 %tmp5, %tmp8
17cee313d2SEric Christopher  br i1 %or.cond, label %bb9, label %bb14
18cee313d2SEric Christopher
19cee313d2SEric Christopherbb9:                                              ; preds = %bb
20cee313d2SEric Christopher  %tmp12 = shl i32 %arg1, 2
21cee313d2SEric Christopher  %tmp13 = add nsw i32 %tmp12, %arg
22cee313d2SEric Christopher  br label %bb30
23cee313d2SEric Christopher
24cee313d2SEric Christopherbb14:                                             ; preds = %bb
25cee313d2SEric Christopher  %0 = and i32 %arg1, %arg
26cee313d2SEric Christopher  %1 = icmp slt i32 %0, 0
27cee313d2SEric Christopher  br i1 %1, label %bb20, label %bb26
28cee313d2SEric Christopher
29cee313d2SEric Christopherbb20:                                             ; preds = %bb14
30cee313d2SEric Christopher  %tmp22 = mul nsw i32 %arg, 3
31cee313d2SEric Christopher  %tmp24 = sdiv i32 %arg1, 6
32cee313d2SEric Christopher  %tmp25 = add nsw i32 %tmp24, %tmp22
33cee313d2SEric Christopher  br label %bb30
34cee313d2SEric Christopher
35cee313d2SEric Christopherbb26:                                             ; preds = %bb14
36cee313d2SEric Christopher  %tmp29 = sub nsw i32 %arg, %arg1
37cee313d2SEric Christopher  br label %bb30
38cee313d2SEric Christopher
39cee313d2SEric Christopherbb30:                                             ; preds = %bb26, %bb20, %bb9
40cee313d2SEric Christopher  %tmp.0 = phi i32 [ %tmp13, %bb9 ], [ %tmp25, %bb20 ], [ %tmp29, %bb26 ]
41cee313d2SEric Christopher  ret i32 %tmp.0
42cee313d2SEric Christopher}
43cee313d2SEric Christopher
44