|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -S -passes=infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck %s |
| 3 | + |
| 4 | +declare void @llvm.fake.use(...) |
| 5 | + |
| 6 | +@gv = internal addrspace(3) global float 0.0, align 4 |
| 7 | + |
| 8 | +define void @one_fake_use(ptr addrspace(1) %global.ptr) { |
| 9 | +; CHECK-LABEL: define void @one_fake_use( |
| 10 | +; CHECK-SAME: ptr addrspace(1) [[GLOBAL_PTR:%.*]]) { |
| 11 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(1) [[GLOBAL_PTR]]) |
| 12 | +; CHECK-NEXT: ret void |
| 13 | +; |
| 14 | + %cast0 = addrspacecast ptr addrspace(1) %global.ptr to ptr |
| 15 | + call void (...) @llvm.fake.use(ptr %cast0) |
| 16 | + ret void |
| 17 | +} |
| 18 | + |
| 19 | +define void @one_fake_use_repeat_operands(ptr addrspace(1) %global.ptr) { |
| 20 | +; CHECK-LABEL: define void @one_fake_use_repeat_operands( |
| 21 | +; CHECK-SAME: ptr addrspace(1) [[GLOBAL_PTR:%.*]]) { |
| 22 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(1) [[GLOBAL_PTR]], ptr addrspace(1) [[GLOBAL_PTR]]) |
| 23 | +; CHECK-NEXT: ret void |
| 24 | +; |
| 25 | + %cast0 = addrspacecast ptr addrspace(1) %global.ptr to ptr |
| 26 | + call void (...) @llvm.fake.use(ptr %cast0, ptr %cast0) |
| 27 | + ret void |
| 28 | +} |
| 29 | + |
| 30 | +define void @one_fake_use_refers_original_ptr(ptr addrspace(1) %global.ptr) { |
| 31 | +; CHECK-LABEL: define void @one_fake_use_refers_original_ptr( |
| 32 | +; CHECK-SAME: ptr addrspace(1) [[GLOBAL_PTR:%.*]]) { |
| 33 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(1) [[GLOBAL_PTR]], ptr addrspace(1) [[GLOBAL_PTR]]) |
| 34 | +; CHECK-NEXT: ret void |
| 35 | +; |
| 36 | + %cast0 = addrspacecast ptr addrspace(1) %global.ptr to ptr |
| 37 | + call void (...) @llvm.fake.use(ptr %cast0, ptr addrspace(1) %global.ptr) |
| 38 | + ret void |
| 39 | +} |
| 40 | + |
| 41 | +define void @multiple_inferrable_fake_use(ptr addrspace(1) %global.ptr0, ptr addrspace(1) %global.ptr1) { |
| 42 | +; CHECK-LABEL: define void @multiple_inferrable_fake_use( |
| 43 | +; CHECK-SAME: ptr addrspace(1) [[GLOBAL_PTR0:%.*]], ptr addrspace(1) [[GLOBAL_PTR1:%.*]]) { |
| 44 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(1) [[GLOBAL_PTR0]], ptr addrspace(1) [[GLOBAL_PTR1]]) |
| 45 | +; CHECK-NEXT: ret void |
| 46 | +; |
| 47 | + %cast0 = addrspacecast ptr addrspace(1) %global.ptr0 to ptr |
| 48 | + %cast1 = addrspacecast ptr addrspace(1) %global.ptr1 to ptr |
| 49 | + call void (...) @llvm.fake.use(ptr %cast0, ptr %cast1) |
| 50 | + ret void |
| 51 | +} |
| 52 | + |
| 53 | +define void @multiple_fake_use_one_inferrable(ptr %flat.ptr0, ptr addrspace(1) %global.ptr1) { |
| 54 | +; CHECK-LABEL: define void @multiple_fake_use_one_inferrable( |
| 55 | +; CHECK-SAME: ptr [[FLAT_PTR0:%.*]], ptr addrspace(1) [[GLOBAL_PTR1:%.*]]) { |
| 56 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr [[FLAT_PTR0]], ptr addrspace(1) [[GLOBAL_PTR1]]) |
| 57 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(1) [[GLOBAL_PTR1]], ptr [[FLAT_PTR0]]) |
| 58 | +; CHECK-NEXT: ret void |
| 59 | +; |
| 60 | + %cast1 = addrspacecast ptr addrspace(1) %global.ptr1 to ptr |
| 61 | + call void (...) @llvm.fake.use(ptr %flat.ptr0, ptr %cast1) |
| 62 | + call void (...) @llvm.fake.use(ptr %cast1, ptr %flat.ptr0) |
| 63 | + ret void |
| 64 | +} |
| 65 | + |
| 66 | +define void @vector_of_pointers(<2 x ptr addrspace(1)> %global.ptr) { |
| 67 | +; CHECK-LABEL: define void @vector_of_pointers( |
| 68 | +; CHECK-SAME: <2 x ptr addrspace(1)> [[GLOBAL_PTR:%.*]]) { |
| 69 | +; CHECK-NEXT: call void (...) @llvm.fake.use(<2 x ptr addrspace(1)> [[GLOBAL_PTR]]) |
| 70 | +; CHECK-NEXT: ret void |
| 71 | +; |
| 72 | + %cast0 = addrspacecast <2 x ptr addrspace(1)> %global.ptr to <2 x ptr> |
| 73 | + call void (...) @llvm.fake.use(<2 x ptr> %cast0) |
| 74 | + ret void |
| 75 | +} |
| 76 | + |
| 77 | +define void @use_global_var() { |
| 78 | +; CHECK-LABEL: define void @use_global_var() { |
| 79 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(3) @gv) |
| 80 | +; CHECK-NEXT: ret void |
| 81 | +; |
| 82 | + call void (...) @llvm.fake.use(ptr addrspacecast (ptr addrspace(3) @gv to ptr)) |
| 83 | + ret void |
| 84 | +} |
| 85 | + |
| 86 | +define void @use_gep_cast(ptr addrspace(1) %global.ptr) { |
| 87 | +; CHECK-LABEL: define void @use_gep_cast( |
| 88 | +; CHECK-SAME: ptr addrspace(1) [[GLOBAL_PTR:%.*]]) { |
| 89 | +; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr addrspace(1) [[GLOBAL_PTR]], i64 16 |
| 90 | +; CHECK-NEXT: call void (...) @llvm.fake.use(ptr addrspace(1) [[GEP]], ptr addrspace(1) [[GLOBAL_PTR]]) |
| 91 | +; CHECK-NEXT: ret void |
| 92 | +; |
| 93 | + %cast0 = addrspacecast ptr addrspace(1) %global.ptr to ptr |
| 94 | + %gep = getelementptr i8, ptr %cast0, i64 16 |
| 95 | + call void (...) @llvm.fake.use(ptr %gep, ptr %cast0) |
| 96 | + ret void |
| 97 | +} |
0 commit comments