| Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -functionattrs -S | FileCheck %s |
| Duncan Sands | b193a37 | 2009-01-02 11:54:37 +0000 | [diff] [blame] | 2 | |
| Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 3 | ; CHECK: define i32* @a(i32** nocapture readonly %p) |
| Duncan Sands | 289f59f | 2009-01-07 19:39:06 +0000 | [diff] [blame] | 4 | define i32* @a(i32** %p) { |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 5 | %tmp = load i32*, i32** %p |
| Duncan Sands | 289f59f | 2009-01-07 19:39:06 +0000 | [diff] [blame] | 6 | ret i32* %tmp |
| 7 | } |
| Duncan Sands | b193a37 | 2009-01-02 11:54:37 +0000 | [diff] [blame] | 8 | |
| Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 9 | ; CHECK: define i32* @b(i32* %q) |
| Duncan Sands | 289f59f | 2009-01-07 19:39:06 +0000 | [diff] [blame] | 10 | define 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 Sands | b193a37 | 2009-01-02 11:54:37 +0000 | [diff] [blame] | 15 | } |
| Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 16 | |
| David Majnemer | 5246e0b | 2016-07-19 18:50:26 +0000 | [diff] [blame^] | 17 | ; CHECK: define i32* @c(i32* readnone returned %r) |
| Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 18 | @g = global i32 0 |
| 19 | define i32* @c(i32 *%r) { |
| 20 | %a = icmp eq i32* %r, null |
| 21 | store i32 1, i32* @g |
| 22 | ret i32* %r |
| 23 | } |