blob: 113b26def2ff615472191f0ed0ed19bb12cedf97 [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")));
Alex Rosenbergc857ce82012-10-05 23:12:53 +000011// CHECKBASIC: @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")));
Alex Rosenbergc857ce82012-10-05 23:12:53 +000016// CHECKBASIC: @f1 = alias void ()* @f0
Bill Wendlingf7a9da02013-02-20 07:22:19 +000017// CHECKBASIC: define void @f0() #0 {
Chris Lattner82227ff2009-03-22 21:21:57 +000018
19// Make sure that aliases cause referenced values to be emitted.
20// PR3200
Chris Lattner82227ff2009-03-22 21:21:57 +000021static inline int foo1() { return 0; }
Alex Rosenbergc857ce82012-10-05 23:12:53 +000022// CHECKBASIC: define internal i32 @foo1()
Chris Lattner82227ff2009-03-22 21:21:57 +000023int foo() __attribute__((alias("foo1")));
Chris Lattner82227ff2009-03-22 21:21:57 +000024int bar() __attribute__((alias("bar1")));
25
Chris Lattner35f6c132009-03-22 21:39:12 +000026extern int test6();
27void test7() { test6(); } // test6 is emitted as extern.
28
29// test6 changes to alias.
30int test6() __attribute__((alias("test7")));
31
Alex Rosenbergc857ce82012-10-05 23:12:53 +000032static int inner(int a) { return 0; }
33static int inner_weak(int a) { return 0; }
34extern __typeof(inner) inner_a __attribute__((alias("inner")));
35static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));
36// CHECKCC: @inner_a = alias i32 (i32)* @inner
Bill Wendlingf7a9da02013-02-20 07:22:19 +000037// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) #0 {
Alex Rosenbergc857ce82012-10-05 23:12:53 +000038
39int outer(int a) { return inner(a); }
Bill Wendlingf7a9da02013-02-20 07:22:19 +000040// CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) #0 {
Alex Rosenbergcbeda892012-10-05 23:56:20 +000041// CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}})
Alex Rosenbergc857ce82012-10-05 23:12:53 +000042
43int outer_weak(int a) { return inner_weak_a(a); }
Bill Wendlingf7a9da02013-02-20 07:22:19 +000044// CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) #0 {
Alex Rosenbergcbeda892012-10-05 23:56:20 +000045// CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}})
Bill Wendlingf7a9da02013-02-20 07:22:19 +000046// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) #0 {
47
48// CHECKBASIC: attributes #0 = { nounwind "target-features"={{.*}} }
49// CHECKBASIC: attributes #1 = { inlinehint nounwind "target-features"={{.*}} }
50
51// CHECKCC: attributes #0 = { nounwind }
52// CHECKCC: attributes #1 = { inlinehint nounwind }