118 lines · c
1// REQUIRES: arm-registered-target2// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s3// RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s4// RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s5// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s6 7int g0;8// CHECKBASIC-DAG: @g0 ={{.*}} global i32 09// CHECKASM-DAG: .bss10// CHECKASM-DAG: .globl g011// CHECKASM-DAG: .p2align 212// CHECKASM-DAG: g0:13// CHECKASM-DAG: .long 014// CHECKASM-DAG: .size g0, 415__thread int TL_WITH_ALIAS;16// CHECKBASIC-DAG: @TL_WITH_ALIAS ={{.*}} thread_local global i32 0, align 417// CHECKASM-DAG: .globl TL_WITH_ALIAS18// CHECKASM-DAG: .size TL_WITH_ALIAS, 419static int bar1 = 42;20// CHECKBASIC-DAG: @bar1 = internal global i32 4221// CHECKASM-DAG: bar1:22// CHECKASM-DAG: .size bar1, 423 24// PR24379: alias variable expected to have same size as aliasee even when types differ25const int wacom_usb_ids[] = {1, 1, 2, 3, 5, 8, 13, 0};26// CHECKBASIC-DAG: @wacom_usb_ids ={{.*}} constant [8 x i32] [i32 1, i32 1, i32 2, i32 3, i32 5, i32 8, i32 13, i32 0], align 427// CHECKASM-DAG: .globl wacom_usb_ids28// CHECKASM-DAG: .size wacom_usb_ids, 3229extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids")));30// CHECKBASIC-DAG: @__mod_usb_device_table ={{.*}} alias i32, ptr @wacom_usb_ids31// CHECKASM-DAG: .globl __mod_usb_device_table32// CHECKASM-DAG: __mod_usb_device_table = wacom_usb_ids33// CHECKASM-NOT: .size __mod_usb_device_table34 35extern int g1;36extern int g1 __attribute((alias("g0")));37// CHECKBASIC-DAG: @g1 ={{.*}} alias i32, ptr @g038// CHECKASM-DAG: .globl g139// CHECKASM-DAG: g1 = g040// CHECKASM-NOT: .size g141 42extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));43// CHECKBASIC-DAG: @__libc_errno ={{.*}} thread_local alias i32, ptr @TL_WITH_ALIAS44// CHECKASM-DAG: .globl __libc_errno45// CHECKASM-DAG: __libc_errno = TL_WITH_ALIAS46// CHECKASM-NOT: .size __libc_errno47 48void f0(void) { }49extern void f1(void);50extern void f1(void) __attribute((alias("f0")));51// CHECKBASIC-DAG: @f1 ={{.*}} alias void (), ptr @f052// CHECKBASIC-DAG: @test8_foo = weak{{.*}} alias void (...), ptr @test8_bar53// CHECKBASIC-DAG: @test8_zed ={{.*}} alias void (...), ptr @test8_bar54// CHECKBASIC-DAG: @test9_zed ={{.*}} alias void (), ptr @test9_bar55// CHECKBASIC: define{{.*}} void @f0() [[NUW:#[0-9]+]] {56 57// Make sure that aliases cause referenced values to be emitted.58// PR320059static inline int foo1() { return 0; }60// CHECKBASIC-LABEL: define internal i32 @foo1()61int foo() __attribute__((alias("foo1")));62int bar() __attribute__((alias("bar1")));63 64extern int test6();65void test7() { test6(); } // test6 is emitted as extern.66 67// test6 changes to alias.68int test6() __attribute__((alias("test7")));69 70static int inner(int a) { return 0; }71static int inner_weak(int a) { return 0; }72extern __typeof(inner) inner_a __attribute__((alias("inner")));73static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));74// CHECKCC: @inner_a ={{.*}} alias i32 (i32), ptr @inner75// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 noundef %a) [[NUW:#[0-9]+]] {76 77int outer(int a) { return inner(a); }78// CHECKCC: define{{.*}} arm_aapcs_vfpcc i32 @outer(i32 noundef %a) [[NUW]] {79// CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 noundef %{{.*}})80 81int outer_weak(int a) { return inner_weak_a(a); }82// CHECKCC: define{{.*}} arm_aapcs_vfpcc i32 @outer_weak(i32 noundef %a) [[NUW]] {83// CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 noundef %{{.*}})84// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 noundef %a) [[NUW]] {85 86// CHECKBASIC: attributes [[NUW]] = { noinline nounwind{{.*}} }87 88// CHECKCC: attributes [[NUW]] = { noinline nounwind{{.*}} }89 90void test8_bar() {}91void test8_foo() __attribute__((weak, alias("test8_bar")));92void test8_zed() __attribute__((alias("test8_foo")));93 94void test9_bar(void) { }95void test9_zed(void) __attribute__((section("test")));96void test9_zed(void) __attribute__((alias("test9_bar")));97 98// Test that the alias gets its linkage from its declared qual type.99// CHECKGLOBALS: @test10_foo = internal100// CHECKGLOBALS-NOT: @test10_foo = dso_local101int test10;102static int test10_foo __attribute__((alias("test10")));103// CHECKGLOBALS: @test11_foo = internal104// CHECKGLOBALS-NOT: @test11_foo = dso_local105void test11(void) {}106static void test11_foo(void) __attribute__((alias("test11")));107 108// Test that gnu_inline+alias work.109// CHECKGLOBALS: @test12_alias ={{.*}} alias void (), ptr @test12110void test12(void) {}111inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));112 113// Test that a non visible (-Wvisibility) type doesn't assert.114// CHECKGLOBALS: @test13_alias ={{.*}} alias {}, ptr @test13115enum a_type { test13_a };116void test13(enum a_type y) {}117void test13_alias(enum undeclared_type y) __attribute__((alias ("test13")));118