Home | History | Annotate | Download | only in CodeGen
      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
      3 
      4 int g0;
      5 // CHECKBASIC: @g0 = common global i32 0
      6 static int bar1 = 42;
      7 // CHECKBASIC: @bar1 = internal global i32 42
      8 
      9 extern int g1;
     10 extern int g1 __attribute((alias("g0")));
     11 // CHECKBASIC-DAG: @g1 = alias i32* @g0
     12 
     13 void f0(void) { }
     14 extern void f1(void);
     15 extern void f1(void) __attribute((alias("f0")));
     16 // CHECKBASIC-DAG: @f1 = alias void ()* @f0
     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 (...)*)
     19 // CHECKBASIC-DAG: @test9_zed = alias void ()* @test9_bar
     20 // CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] {
     21 
     22 // Make sure that aliases cause referenced values to be emitted.
     23 // PR3200
     24 static inline int foo1() { return 0; }
     25 // CHECKBASIC-LABEL: define internal i32 @foo1()
     26 int foo() __attribute__((alias("foo1")));
     27 int bar() __attribute__((alias("bar1")));
     28 
     29 extern int test6();
     30 void test7() { test6(); }  // test6 is emitted as extern.
     31 
     32 // test6 changes to alias.
     33 int test6() __attribute__((alias("test7")));
     34 
     35 static int inner(int a) { return 0; }
     36 static int inner_weak(int a) { return 0; }
     37 extern __typeof(inner) inner_a __attribute__((alias("inner")));
     38 static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));
     39 // CHECKCC: @inner_a = alias i32 (i32)* @inner
     40 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] {
     41 
     42 int outer(int a) { return inner(a); }
     43 // CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] {
     44 // CHECKCC: call arm_aapcs_vfpcc  i32 @inner(i32 %{{.*}})
     45 
     46 int outer_weak(int a) { return inner_weak_a(a); }
     47 // CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] {
     48 // CHECKCC: call arm_aapcs_vfpcc  i32 @inner_weak(i32 %{{.*}})
     49 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] {
     50 
     51 // CHECKBASIC: attributes [[NUW]] = { nounwind{{.*}} }
     52 
     53 // CHECKCC: attributes [[NUW]] = { nounwind{{.*}} }
     54 
     55 void test8_bar() {}
     56 void test8_foo() __attribute__((weak, alias("test8_bar")));
     57 void test8_zed() __attribute__((alias("test8_foo")));
     58 
     59 void test9_bar(void) { }
     60 void test9_zed(void) __attribute__((section("test")));
     61 void test9_zed(void) __attribute__((alias("test9_bar")));
     62