| Alex Rosenberg | c857ce8 | 2012-10-05 23:12:53 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s |
| 2 | // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s |
| Alex Rosenberg | 26994a1 | 2012-10-05 23:12:48 +0000 | [diff] [blame] | 3 | |
| 4 | int g0; |
| Alex Rosenberg | c857ce8 | 2012-10-05 23:12:53 +0000 | [diff] [blame] | 5 | // CHECKBASIC: @g0 = common global i32 0 |
| Alex Rosenberg | 26994a1 | 2012-10-05 23:12:48 +0000 | [diff] [blame] | 6 | static int bar1 = 42; |
| Alex Rosenberg | c857ce8 | 2012-10-05 23:12:53 +0000 | [diff] [blame] | 7 | // CHECKBASIC: @bar1 = internal global i32 42 |
| Alex Rosenberg | 26994a1 | 2012-10-05 23:12:48 +0000 | [diff] [blame] | 8 | |
| 9 | extern int g1; |
| 10 | extern int g1 __attribute((alias("g0"))); |
| Rafael Espindola | 03954b3 | 2013-10-14 16:18:39 +0000 | [diff] [blame] | 11 | // CHECKBASIC-DAG: @g1 = alias i32* @g0 |
| Daniel Dunbar | 5e1e1f9 | 2009-03-19 08:27:24 +0000 | [diff] [blame] | 12 | |
| 13 | void f0(void) { } |
| 14 | extern void f1(void); |
| 15 | extern void f1(void) __attribute((alias("f0"))); |
| Rafael Espindola | 03954b3 | 2013-10-14 16:18:39 +0000 | [diff] [blame] | 16 | // CHECKBASIC-DAG: @f1 = alias void ()* @f0 |
| Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame^] | 17 | // CHECKBASIC-DAG: @test8_foo = alias weak bitcast (void ()* @test8_bar to void (...)*) |
| 18 | // CHECKBASIC-DAG: @test8_zed = alias bitcast (void ()* @test8_bar to void (...)*) |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 19 | // CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] { |
| Chris Lattner | 82227ff | 2009-03-22 21:21:57 +0000 | [diff] [blame] | 20 | |
| 21 | // Make sure that aliases cause referenced values to be emitted. |
| 22 | // PR3200 |
| Chris Lattner | 82227ff | 2009-03-22 21:21:57 +0000 | [diff] [blame] | 23 | static inline int foo1() { return 0; } |
| Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 24 | // CHECKBASIC-LABEL: define internal i32 @foo1() |
| Chris Lattner | 82227ff | 2009-03-22 21:21:57 +0000 | [diff] [blame] | 25 | int foo() __attribute__((alias("foo1"))); |
| Chris Lattner | 82227ff | 2009-03-22 21:21:57 +0000 | [diff] [blame] | 26 | int bar() __attribute__((alias("bar1"))); |
| 27 | |
| Chris Lattner | 35f6c13 | 2009-03-22 21:39:12 +0000 | [diff] [blame] | 28 | extern int test6(); |
| 29 | void test7() { test6(); } // test6 is emitted as extern. |
| 30 | |
| 31 | // test6 changes to alias. |
| 32 | int test6() __attribute__((alias("test7"))); |
| 33 | |
| Alex Rosenberg | c857ce8 | 2012-10-05 23:12:53 +0000 | [diff] [blame] | 34 | static int inner(int a) { return 0; } |
| 35 | static int inner_weak(int a) { return 0; } |
| 36 | extern __typeof(inner) inner_a __attribute__((alias("inner"))); |
| 37 | static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak"))); |
| 38 | // CHECKCC: @inner_a = alias i32 (i32)* @inner |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 39 | // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] { |
| Alex Rosenberg | c857ce8 | 2012-10-05 23:12:53 +0000 | [diff] [blame] | 40 | |
| 41 | int outer(int a) { return inner(a); } |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 42 | // CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] { |
| Alex Rosenberg | cbeda89 | 2012-10-05 23:56:20 +0000 | [diff] [blame] | 43 | // CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}}) |
| Alex Rosenberg | c857ce8 | 2012-10-05 23:12:53 +0000 | [diff] [blame] | 44 | |
| 45 | int outer_weak(int a) { return inner_weak_a(a); } |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 46 | // CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] { |
| Alex Rosenberg | cbeda89 | 2012-10-05 23:56:20 +0000 | [diff] [blame] | 47 | // CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}}) |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 48 | // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] { |
| Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame] | 49 | |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 50 | // CHECKBASIC: attributes [[NUW]] = { nounwind{{.*}} } |
| Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame] | 51 | |
| Bill Wendling | c3af679 | 2013-02-26 23:08:48 +0000 | [diff] [blame] | 52 | // CHECKCC: attributes [[NUW]] = { nounwind{{.*}} } |
| Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame^] | 53 | |
| 54 | void test8_bar() {} |
| 55 | void test8_foo() __attribute__((weak, alias("test8_bar"))); |
| 56 | void test8_zed() __attribute__((alias("test8_foo"))); |