Duncan P. N. Exon Smith | 56cc990 | 2014-03-10 23:42:28 +0000 | [diff] [blame] | 1 | ; RUN: llvm-as <%s >%t1 |
| 2 | ; RUN: llvm-lto -exported-symbol=_uses_puts -exported-symbol=_uses_printf -o - %t1 | \ |
Kevin Enderby | 4fc2edb | 2014-06-23 20:27:53 +0000 | [diff] [blame] | 3 | ; RUN: llvm-nm - | \ |
Duncan P. N. Exon Smith | 56cc990 | 2014-03-10 23:42:28 +0000 | [diff] [blame] | 4 | ; RUN: FileCheck %s |
| 5 | ; rdar://problem/16165191 |
| 6 | ; runtime library implementations should not be renamed |
| 7 | |
| 8 | target triple = "x86_64-apple-darwin11" |
| 9 | |
| 10 | @str = private unnamed_addr constant [13 x i8] c"hello world\0A\00" |
| 11 | |
| 12 | ; CHECK-NOT: U _puts |
| 13 | ; CHECK: T _uses_printf |
| 14 | ; CHECK: T _uses_puts |
| 15 | define i32 @uses_puts(i32 %i) { |
| 16 | entry: |
| 17 | %s = call i8* @foo(i32 %i) |
| 18 | %ret = call i32 @puts(i8* %s) |
| 19 | ret i32 %ret |
| 20 | } |
| 21 | define i32 @uses_printf(i32 %i) { |
| 22 | entry: |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 23 | %s = getelementptr [13 x i8], [13 x i8]* @str, i64 0, i64 0 |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 24 | call i32 (i8*, ...) @printf(i8* %s) |
Duncan P. N. Exon Smith | 56cc990 | 2014-03-10 23:42:28 +0000 | [diff] [blame] | 25 | ret i32 0 |
| 26 | } |
| 27 | |
| 28 | define hidden i32 @printf(i8* readonly nocapture %fmt, ...) { |
| 29 | entry: |
| 30 | %ret = call i32 @bar(i8* %fmt) |
| 31 | ret i32 %ret |
| 32 | } |
| 33 | define hidden i32 @puts(i8* %s) { |
| 34 | entry: |
| 35 | %ret = call i32 @bar(i8* %s) |
| 36 | ret i32 %ret |
| 37 | } |
| 38 | |
| 39 | declare i8* @foo(i32) |
| 40 | declare i32 @bar(i8*) |