blob: 0d0231b42ae5fa27a85f4f9b8a2da6f5c26d1157 [file] [log] [blame]
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00001; RUN: opt < %s -functionattrs -S | FileCheck %s
Duncan Sandsb193a372009-01-02 11:54:37 +00002
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00003; CHECK: define i32* @a(i32** nocapture readonly %p)
Duncan Sands289f59f2009-01-07 19:39:06 +00004define i32* @a(i32** %p) {
David Blaikiea79ac142015-02-27 21:17:42 +00005 %tmp = load i32*, i32** %p
Duncan Sands289f59f2009-01-07 19:39:06 +00006 ret i32* %tmp
7}
Duncan Sandsb193a372009-01-02 11:54:37 +00008
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00009; CHECK: define i32* @b(i32* %q)
Duncan Sands289f59f2009-01-07 19:39:06 +000010define i32* @b(i32 *%q) {
11 %mem = alloca i32*
12 store i32* %q, i32** %mem
13 %tmp = call i32* @a(i32** %mem)
14 ret i32* %tmp
Duncan Sandsb193a372009-01-02 11:54:37 +000015}
Nick Lewyckyc2ec0722013-07-06 00:29:58 +000016
David Majnemer5246e0b2016-07-19 18:50:26 +000017; CHECK: define i32* @c(i32* readnone returned %r)
Nick Lewyckyc2ec0722013-07-06 00:29:58 +000018@g = global i32 0
19define i32* @c(i32 *%r) {
20 %a = icmp eq i32* %r, null
21 store i32 1, i32* @g
22 ret i32* %r
23}