1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s 2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s 3f4a2713aSLionel Sambuc 4f4a2713aSLionel Sambuc int g0; 5f4a2713aSLionel Sambuc // CHECKBASIC: @g0 = common global i32 0 6*0a6a1f1dSLionel Sambuc __thread int TL_WITH_ALIAS; 7*0a6a1f1dSLionel Sambuc // CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4 8f4a2713aSLionel Sambuc static int bar1 = 42; 9f4a2713aSLionel Sambuc // CHECKBASIC: @bar1 = internal global i32 42 10f4a2713aSLionel Sambuc 11f4a2713aSLionel Sambuc extern int g1; 12f4a2713aSLionel Sambuc extern int g1 __attribute((alias("g0"))); 13f4a2713aSLionel Sambuc // CHECKBASIC-DAG: @g1 = alias i32* @g0 14f4a2713aSLionel Sambuc 15*0a6a1f1dSLionel Sambuc extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS"))); 16*0a6a1f1dSLionel Sambuc // CHECKBASIC-DAG: @__libc_errno = thread_local alias i32* @TL_WITH_ALIAS 17*0a6a1f1dSLionel Sambuc f0(void)18f4a2713aSLionel Sambucvoid f0(void) { } 19f4a2713aSLionel Sambuc extern void f1(void); 20f4a2713aSLionel Sambuc extern void f1(void) __attribute((alias("f0"))); 21f4a2713aSLionel Sambuc // CHECKBASIC-DAG: @f1 = alias void ()* @f0 22*0a6a1f1dSLionel Sambuc // CHECKBASIC-DAG: @test8_foo = weak alias bitcast (void ()* @test8_bar to void (...)*) 23*0a6a1f1dSLionel Sambuc // CHECKBASIC-DAG: @test8_zed = alias bitcast (void ()* @test8_bar to void (...)*) 24*0a6a1f1dSLionel Sambuc // CHECKBASIC-DAG: @test9_zed = alias void ()* @test9_bar 25f4a2713aSLionel Sambuc // CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] { 26f4a2713aSLionel Sambuc 27f4a2713aSLionel Sambuc // Make sure that aliases cause referenced values to be emitted. 28f4a2713aSLionel Sambuc // PR3200 foo1()29f4a2713aSLionel Sambucstatic inline int foo1() { return 0; } 30f4a2713aSLionel Sambuc // CHECKBASIC-LABEL: define internal i32 @foo1() 31f4a2713aSLionel Sambuc int foo() __attribute__((alias("foo1"))); 32f4a2713aSLionel Sambuc int bar() __attribute__((alias("bar1"))); 33f4a2713aSLionel Sambuc 34f4a2713aSLionel Sambuc extern int test6(); test7()35f4a2713aSLionel Sambucvoid test7() { test6(); } // test6 is emitted as extern. 36f4a2713aSLionel Sambuc 37f4a2713aSLionel Sambuc // test6 changes to alias. 38f4a2713aSLionel Sambuc int test6() __attribute__((alias("test7"))); 39f4a2713aSLionel Sambuc inner(int a)40f4a2713aSLionel Sambucstatic int inner(int a) { return 0; } inner_weak(int a)41f4a2713aSLionel Sambucstatic int inner_weak(int a) { return 0; } 42f4a2713aSLionel Sambuc extern __typeof(inner) inner_a __attribute__((alias("inner"))); 43f4a2713aSLionel Sambuc static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak"))); 44f4a2713aSLionel Sambuc // CHECKCC: @inner_a = alias i32 (i32)* @inner 45f4a2713aSLionel Sambuc // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] { 46f4a2713aSLionel Sambuc outer(int a)47f4a2713aSLionel Sambucint outer(int a) { return inner(a); } 48f4a2713aSLionel Sambuc // CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] { 49f4a2713aSLionel Sambuc // CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}}) 50f4a2713aSLionel Sambuc outer_weak(int a)51f4a2713aSLionel Sambucint outer_weak(int a) { return inner_weak_a(a); } 52f4a2713aSLionel Sambuc // CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] { 53f4a2713aSLionel Sambuc // CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}}) 54f4a2713aSLionel Sambuc // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] { 55f4a2713aSLionel Sambuc 56f4a2713aSLionel Sambuc // CHECKBASIC: attributes [[NUW]] = { nounwind{{.*}} } 57f4a2713aSLionel Sambuc 58f4a2713aSLionel Sambuc // CHECKCC: attributes [[NUW]] = { nounwind{{.*}} } 59*0a6a1f1dSLionel Sambuc test8_bar()60*0a6a1f1dSLionel Sambucvoid test8_bar() {} 61*0a6a1f1dSLionel Sambuc void test8_foo() __attribute__((weak, alias("test8_bar"))); 62*0a6a1f1dSLionel Sambuc void test8_zed() __attribute__((alias("test8_foo"))); 63*0a6a1f1dSLionel Sambuc test9_bar(void)64*0a6a1f1dSLionel Sambucvoid test9_bar(void) { } 65*0a6a1f1dSLionel Sambuc void test9_zed(void) __attribute__((section("test"))); 66*0a6a1f1dSLionel Sambuc void test9_zed(void) __attribute__((alias("test9_bar"))); 67