Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -functionattrs -S | FileCheck %s |
Chandler Carruth | 9c4ed17 | 2016-02-18 11:03:11 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -aa-pipeline=basic-aa -passes='require<targetlibinfo>,cgscc(function-attrs)' -S | FileCheck %s |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 3 | @x = global i32 0 |
| 4 | |
| 5 | declare void @test1_1(i8* %x1_1, i8* readonly %y1_1, ...) |
| 6 | |
| 7 | ; CHECK: define void @test1_2(i8* %x1_2, i8* readonly %y1_2, i8* %z1_2) |
| 8 | define void @test1_2(i8* %x1_2, i8* %y1_2, i8* %z1_2) { |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 9 | call void (i8*, i8*, ...) @test1_1(i8* %x1_2, i8* %y1_2, i8* %z1_2) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 10 | store i32 0, i32* @x |
| 11 | ret void |
| 12 | } |
| 13 | |
| 14 | ; CHECK: define i8* @test2(i8* readnone %p) |
| 15 | define i8* @test2(i8* %p) { |
| 16 | store i32 0, i32* @x |
| 17 | ret i8* %p |
| 18 | } |
| 19 | |
| 20 | ; CHECK: define i1 @test3(i8* readnone %p, i8* readnone %q) |
| 21 | define i1 @test3(i8* %p, i8* %q) { |
| 22 | %A = icmp ult i8* %p, %q |
| 23 | ret i1 %A |
| 24 | } |
| 25 | |
| 26 | declare void @test4_1(i8* nocapture) readonly |
| 27 | |
| 28 | ; CHECK: define void @test4_2(i8* nocapture readonly %p) |
| 29 | define void @test4_2(i8* %p) { |
| 30 | call void @test4_1(i8* %p) |
| 31 | ret void |
| 32 | } |
| 33 | |
| 34 | ; CHECK: define void @test5(i8** nocapture %p, i8* %q) |
| 35 | ; Missed optz'n: we could make %q readnone, but don't break test6! |
| 36 | define void @test5(i8** %p, i8* %q) { |
| 37 | store i8* %q, i8** %p |
| 38 | ret void |
| 39 | } |
| 40 | |
| 41 | declare void @test6_1() |
| 42 | ; CHECK: define void @test6_2(i8** nocapture %p, i8* %q) |
| 43 | ; This is not a missed optz'n. |
| 44 | define void @test6_2(i8** %p, i8* %q) { |
| 45 | store i8* %q, i8** %p |
| 46 | call void @test6_1() |
| 47 | ret void |
| 48 | } |
Reid Kleckner | 26af2ca | 2014-01-28 02:38:36 +0000 | [diff] [blame] | 49 | |
| 50 | ; CHECK: define void @test7_1(i32* inalloca nocapture %a) |
| 51 | ; inalloca parameters are always considered written |
| 52 | define void @test7_1(i32* inalloca %a) { |
| 53 | ret void |
| 54 | } |
Nick Lewycky | 59633cb | 2014-05-30 02:31:27 +0000 | [diff] [blame] | 55 | |
| 56 | ; CHECK: define i32* @test8_1(i32* readnone %p) |
| 57 | define i32* @test8_1(i32* %p) { |
| 58 | entry: |
| 59 | ret i32* %p |
| 60 | } |
| 61 | |
| 62 | ; CHECK: define void @test8_2(i32* %p) |
| 63 | define void @test8_2(i32* %p) { |
| 64 | entry: |
| 65 | %call = call i32* @test8_1(i32* %p) |
| 66 | store i32 10, i32* %call, align 4 |
| 67 | ret void |
| 68 | } |
Elena Demikhovsky | 3ec9e15 | 2015-11-17 19:30:51 +0000 | [diff] [blame] | 69 | |
| 70 | ; CHECK: declare void @llvm.masked.scatter |
| 71 | declare void @llvm.masked.scatter.v4i32(<4 x i32>%val, <4 x i32*>, i32, <4 x i1>) |
| 72 | |
| 73 | ; CHECK-NOT: readnone |
| 74 | ; CHECK-NOT: readonly |
| 75 | ; CHECK: define void @test9 |
| 76 | define void @test9(<4 x i32*> %ptrs, <4 x i32>%val) { |
| 77 | call void @llvm.masked.scatter.v4i32(<4 x i32>%val, <4 x i32*> %ptrs, i32 4, <4 x i1><i1 true, i1 false, i1 true, i1 false>) |
| 78 | ret void |
| 79 | } |
| 80 | |
| 81 | ; CHECK: declare <4 x i32> @llvm.masked.gather |
| 82 | declare <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*>, i32, <4 x i1>, <4 x i32>) |
| 83 | ; CHECK: readonly |
| 84 | ; CHECK: define <4 x i32> @test10 |
| 85 | define <4 x i32> @test10(<4 x i32*> %ptrs) { |
| 86 | %res = call <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> %ptrs, i32 4, <4 x i1><i1 true, i1 false, i1 true, i1 false>, <4 x i32>undef) |
| 87 | ret <4 x i32> %res |
| 88 | } |
| 89 | |
| 90 | ; CHECK: declare <4 x i32> @test11_1 |
| 91 | declare <4 x i32> @test11_1(<4 x i32*>) argmemonly nounwind readonly |
| 92 | ; CHECK: readonly |
| 93 | ; CHECK-NOT: readnone |
| 94 | ; CHECK: define <4 x i32> @test11_2 |
| 95 | define <4 x i32> @test11_2(<4 x i32*> %ptrs) { |
| 96 | %res = call <4 x i32> @test11_1(<4 x i32*> %ptrs) |
| 97 | ret <4 x i32> %res |
| 98 | } |
| 99 | |
| 100 | declare <4 x i32> @test12_1(<4 x i32*>) argmemonly nounwind |
| 101 | ; CHECK-NOT: readnone |
| 102 | ; CHECK: define <4 x i32> @test12_2 |
| 103 | define <4 x i32> @test12_2(<4 x i32*> %ptrs) { |
| 104 | %res = call <4 x i32> @test12_1(<4 x i32*> %ptrs) |
| 105 | ret <4 x i32> %res |
| 106 | } |