| 1 |
// RUN: cir-opt %s -cir-goto-solver --verify-roundtrip -o - | FileCheck %s |
| 2 |
|
| 3 |
!void = !cir.void |
| 4 |
|
| 5 |
cir.func @a(){ |
| 6 |
%0 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>, ["ptr", init] {alignment = 8 : i64} |
| 7 |
%1 = cir.block_address <@a, "label1"> : !cir.ptr<!void> |
| 8 |
cir.store align(8) %1, %0 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> |
| 9 |
cir.br ^bb1 |
| 10 |
^bb1: |
| 11 |
cir.label "label1" |
| 12 |
cir.br ^bb2 |
| 13 |
^bb2: |
| 14 |
// This label is not referenced by any blockaddressOp, so it should be removed |
| 15 |
cir.label "label2" |
| 16 |
cir.return |
| 17 |
} |
| 18 |
|
| 19 |
// CHECK: cir.func @a() |
| 20 |
// CHECK: %1 = cir.block_address <@a, "label1"> : !cir.ptr<!void> |
| 21 |
// CHECK: ^bb1: |
| 22 |
// CHECK: cir.label "label1" |
| 23 |
// CHECK: cir.br ^bb2 |
| 24 |
// CHECK: ^bb2: |
| 25 |
// CHECK-NOT: cir.label "label2" |
| 26 |
|
| 27 |
cir.func @b(){ |
| 28 |
%0 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>, ["ptr", init] {alignment = 8 : i64} |
| 29 |
%1 = cir.block_address <@b, "label1"> : !cir.ptr<!void> |
| 30 |
cir.store align(8) %1, %0 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> |
| 31 |
cir.goto "label2" |
| 32 |
^bb1: |
| 33 |
cir.label "label1" |
| 34 |
cir.br ^bb2 |
| 35 |
^bb2: |
| 36 |
// This label is not referenced by any blockaddressOp, so it should be removed |
| 37 |
cir.label "label2" |
| 38 |
cir.return |
| 39 |
} |
| 40 |
|
| 41 |
// CHECK: cir.func @b() { |
| 42 |
// CHECK: %1 = cir.block_address <@b, "label1"> : !cir.ptr<!void> |
| 43 |
// CHECK: cir.store align(8) %1, {{.*}} : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> |
| 44 |
// CHECK: cir.br ^bb2 |
| 45 |
// CHECK: ^bb1: |
| 46 |
// CHECK: cir.label "label1" |
| 47 |
// CHECK: cir.br ^bb2 |
| 48 |
// CHECK: ^bb2: |
| 49 |
// CHECK-NOT: cir.label "label2" |
| 50 |
|
| 51 |
cir.func @c() { |
| 52 |
cir.label "label1" |
| 53 |
%0 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>, ["ptr", init] {alignment = 8 : i64} |
| 54 |
%1 = cir.block_address <@c, "label1"> : !cir.ptr<!void> |
| 55 |
cir.store align(8) %1, %0 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> |
| 56 |
cir.return |
| 57 |
} |
| 58 |
|
| 59 |
// CHECK: cir.func @c |
| 60 |
// CHECK: cir.label "label1" |
| 61 |
// CHECK: %1 = cir.block_address <@c, "label1"> : !cir.ptr<!void> |
| 62 |
// CHECK: cir.store align(8) %1, {{.*}} : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> |