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