|
4 | 4 | target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
5 | 5 | target triple = "x86_64-grtev4-linux-gnu" |
6 | 6 |
|
7 | | -; Test a scenario when the address cannot be recreated in the current basic block |
8 | | - |
| 7 | +@globalptr = external global ptr |
9 | 8 | declare ptr @get_ptr(i64) |
| 9 | + |
| 10 | +; Can't recreate invoke instruction |
| 11 | + |
10 | 12 | define void @addr_from_invoke() personality ptr null { |
11 | 13 | ; CHECK-LABEL: define void @addr_from_invoke() personality ptr null { |
12 | 14 | ; CHECK-NEXT: [[ENTRY:.*:]] |
@@ -40,3 +42,65 @@ body.1: |
40 | 42 | store <4 x i32> zeroinitializer, ptr %gep, align 4 |
41 | 43 | br label %body.2 |
42 | 44 | } |
| 45 | + |
| 46 | +define void @addr_from_arg(ptr %ptr, i1 %p) { |
| 47 | +; CHECK-LABEL: define void @addr_from_arg( |
| 48 | +; CHECK-SAME: ptr [[PTR:%.*]], i1 [[P:%.*]]) { |
| 49 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 50 | +; CHECK-NEXT: br i1 [[P]], label %[[BODY_1:.*]], label %[[EXIT:.*]] |
| 51 | +; CHECK: [[EXIT]]: |
| 52 | +; CHECK-NEXT: ret void |
| 53 | +; CHECK: [[BODY_1]]: |
| 54 | +; CHECK-NEXT: [[SUNKADDR:%.*]] = bitcast ptr [[PTR]] to ptr |
| 55 | +; CHECK-NEXT: store <4 x i32> zeroinitializer, ptr [[SUNKADDR]], align 4 |
| 56 | +; CHECK-NEXT: [[UNUSED:%.*]] = load <4 x i32>, ptr [[PTR]], align 4 |
| 57 | +; CHECK-NEXT: store <4 x i32> zeroinitializer, ptr [[PTR]], align 4 |
| 58 | +; CHECK-NEXT: ret void |
| 59 | +; |
| 60 | +entry: |
| 61 | + br i1 %p, label %body.1, label %exit |
| 62 | + |
| 63 | +body.2: |
| 64 | + %unused = load <4 x i32>, ptr %gep, align 4 |
| 65 | + store <4 x i32> zeroinitializer, ptr %gep, align 4 |
| 66 | + ret void |
| 67 | + |
| 68 | +exit: |
| 69 | + ret void |
| 70 | + |
| 71 | +body.1: |
| 72 | + %gep = getelementptr { i32 }, ptr %ptr, i64 0, i32 0 |
| 73 | + store <4 x i32> zeroinitializer, ptr %gep, align 4 |
| 74 | + br label %body.2 |
| 75 | +} |
| 76 | + |
| 77 | +define void @addr_from_global(i1 %p) { |
| 78 | +; CHECK-LABEL: define void @addr_from_global( |
| 79 | +; CHECK-SAME: i1 [[P:%.*]]) { |
| 80 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 81 | +; CHECK-NEXT: br i1 [[P]], label %[[BODY_1:.*]], label %[[EXIT:.*]] |
| 82 | +; CHECK: [[EXIT]]: |
| 83 | +; CHECK-NEXT: ret void |
| 84 | +; CHECK: [[BODY_1]]: |
| 85 | +; CHECK-NEXT: [[GEP1:%.*]] = bitcast ptr @globalptr to ptr |
| 86 | +; CHECK-NEXT: store <4 x i32> zeroinitializer, ptr [[GEP1]], align 4 |
| 87 | +; CHECK-NEXT: [[UNUSED:%.*]] = load <4 x i32>, ptr @globalptr, align 4 |
| 88 | +; CHECK-NEXT: store <4 x i32> zeroinitializer, ptr @globalptr, align 4 |
| 89 | +; CHECK-NEXT: ret void |
| 90 | +; |
| 91 | +entry: |
| 92 | + br i1 %p, label %body.1, label %exit |
| 93 | + |
| 94 | +body.2: |
| 95 | + %unused = load <4 x i32>, ptr %gep, align 4 |
| 96 | + store <4 x i32> zeroinitializer, ptr %gep, align 4 |
| 97 | + ret void |
| 98 | + |
| 99 | +exit: |
| 100 | + ret void |
| 101 | + |
| 102 | +body.1: |
| 103 | + %gep = getelementptr { i32 }, ptr @globalptr, i64 0, i32 0 |
| 104 | + store <4 x i32> zeroinitializer, ptr %gep, align 4 |
| 105 | + br label %body.2 |
| 106 | +} |
0 commit comments