blob: 5aafd95fde295fbd0d60bcc868f8c2f64f8565db [file] [log] [blame]
Alex Rosenbergc857ce82012-10-05 23:12:53 +00001// 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 Rosenberg26994a12012-10-05 23:12:48 +00003
4int g0;
Alex Rosenbergc857ce82012-10-05 23:12:53 +00005// CHECKBASIC: @g0 = common global i32 0
Alex Rosenberg26994a12012-10-05 23:12:48 +00006static int bar1 = 42;
Alex Rosenbergc857ce82012-10-05 23:12:53 +00007// CHECKBASIC: @bar1 = internal global i32 42
Alex Rosenberg26994a12012-10-05 23:12:48 +00008
9extern int g1;
10extern int g1 __attribute((alias("g0")));
Rafael Espindola03954b32013-10-14 16:18:39 +000011// CHECKBASIC-DAG: @g1 = alias i32* @g0
Daniel Dunbar5e1e1f92009-03-19 08:27:24 +000012
13void f0(void) { }
14extern void f1(void);
15extern void f1(void) __attribute((alias("f0")));
Rafael Espindola03954b32013-10-14 16:18:39 +000016// CHECKBASIC-DAG: @f1 = alias void ()* @f0
Stephen Hines6bcf27b2014-05-29 04:14:42 -070017// CHECKBASIC-DAG: @test8_foo = alias weak void (...), void ()* @test8_bar
18// CHECKBASIC-DAG: @test8_zed = alias void (...), void ()* @test8_bar
19// CHECKBASIC-DAG: @test9_zed = alias void ()* @test9_bar
Bill Wendlingc3af6792013-02-26 23:08:48 +000020// CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] {
Chris Lattner82227ff2009-03-22 21:21:57 +000021
22// Make sure that aliases cause referenced values to be emitted.
23// PR3200
Chris Lattner82227ff2009-03-22 21:21:57 +000024static inline int foo1() { return 0; }
Stephen Lin93ab6bf2013-08-15 06:47:53 +000025// CHECKBASIC-LABEL: define internal i32 @foo1()
Chris Lattner82227ff2009-03-22 21:21:57 +000026int foo() __attribute__((alias("foo1")));
Chris Lattner82227ff2009-03-22 21:21:57 +000027int bar() __attribute__((alias("bar1")));
28
Chris Lattner35f6c132009-03-22 21:39:12 +000029extern int test6();
30void test7() { test6(); } // test6 is emitted as extern.
31
32// test6 changes to alias.
33int test6() __attribute__((alias("test7")));
34
Alex Rosenbergc857ce82012-10-05 23:12:53 +000035static int inner(int a) { return 0; }
36static int inner_weak(int a) { return 0; }
37extern __typeof(inner) inner_a __attribute__((alias("inner")));
38static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));
39// CHECKCC: @inner_a = alias i32 (i32)* @inner
Bill Wendlingc3af6792013-02-26 23:08:48 +000040// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] {
Alex Rosenbergc857ce82012-10-05 23:12:53 +000041
42int outer(int a) { return inner(a); }
Bill Wendlingc3af6792013-02-26 23:08:48 +000043// CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] {
Alex Rosenbergcbeda892012-10-05 23:56:20 +000044// CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}})
Alex Rosenbergc857ce82012-10-05 23:12:53 +000045
46int outer_weak(int a) { return inner_weak_a(a); }
Bill Wendlingc3af6792013-02-26 23:08:48 +000047// CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] {
Alex Rosenbergcbeda892012-10-05 23:56:20 +000048// CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}})
Bill Wendlingc3af6792013-02-26 23:08:48 +000049// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] {
Bill Wendlingf7a9da02013-02-20 07:22:19 +000050
Bill Wendlingc3af6792013-02-26 23:08:48 +000051// CHECKBASIC: attributes [[NUW]] = { nounwind{{.*}} }
Bill Wendlingf7a9da02013-02-20 07:22:19 +000052
Bill Wendlingc3af6792013-02-26 23:08:48 +000053// CHECKCC: attributes [[NUW]] = { nounwind{{.*}} }
Stephen Hines651f13c2014-04-23 16:59:28 -070054
55void test8_bar() {}
56void test8_foo() __attribute__((weak, alias("test8_bar")));
57void test8_zed() __attribute__((alias("test8_foo")));
Stephen Hines6bcf27b2014-05-29 04:14:42 -070058
59void test9_bar(void) { }
60void test9_zed(void) __attribute__((section("test")));
61void test9_zed(void) __attribute__((alias("test9_bar")));