2015-08-12 23:55:55 +08:00
|
|
|
// REQUIRES: arm-registered-target
|
2012-10-06 07:12:53 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
|
|
|
|
// RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
|
2015-08-12 23:15:27 +08:00
|
|
|
// RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
|
2019-08-23 07:18:46 +08:00
|
|
|
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
|
2009-03-19 16:27:24 +08:00
|
|
|
|
|
|
|
int g0;
|
2015-08-12 23:15:27 +08:00
|
|
|
// CHECKBASIC-DAG: @g0 = common global i32 0
|
|
|
|
// CHECKASM-DAG: .comm g0,4,4
|
2014-10-16 06:38:23 +08:00
|
|
|
__thread int TL_WITH_ALIAS;
|
|
|
|
// CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4
|
2015-08-12 23:15:27 +08:00
|
|
|
// CHECKASM-DAG: .globl TL_WITH_ALIAS
|
|
|
|
// CHECKASM-DAG: .size TL_WITH_ALIAS, 4
|
2012-10-06 07:12:48 +08:00
|
|
|
static int bar1 = 42;
|
2015-08-12 23:15:27 +08:00
|
|
|
// CHECKBASIC-DAG: @bar1 = internal global i32 42
|
|
|
|
// CHECKASM-DAG: bar1:
|
|
|
|
// CHECKASM-DAG: .size bar1, 4
|
|
|
|
|
|
|
|
// PR24379: alias variable expected to have same size as aliasee even when types differ
|
|
|
|
const int wacom_usb_ids[] = {1, 1, 2, 3, 5, 8, 13, 0};
|
|
|
|
// 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 4
|
|
|
|
// CHECKASM-DAG: .globl wacom_usb_ids
|
|
|
|
// CHECKASM-DAG: .size wacom_usb_ids, 32
|
|
|
|
extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids")));
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECKBASIC-DAG: @__mod_usb_device_table = alias i32, getelementptr inbounds ([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
|
2015-08-12 23:15:27 +08:00
|
|
|
// CHECKASM-DAG: .globl __mod_usb_device_table
|
2018-03-28 01:17:39 +08:00
|
|
|
// CHECKASM-DAG: .set __mod_usb_device_table, wacom_usb_ids
|
2016-02-27 03:34:01 +08:00
|
|
|
// CHECKASM-NOT: .size __mod_usb_device_table
|
2012-10-06 07:12:48 +08:00
|
|
|
|
2009-03-19 16:27:24 +08:00
|
|
|
extern int g1;
|
|
|
|
extern int g1 __attribute((alias("g0")));
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECKBASIC-DAG: @g1 = alias i32, i32* @g0
|
2015-08-12 23:15:27 +08:00
|
|
|
// CHECKASM-DAG: .globl g1
|
2018-03-28 01:17:39 +08:00
|
|
|
// CHECKASM-DAG: .set g1, g0
|
2016-02-27 03:34:01 +08:00
|
|
|
// CHECKASM-NOT: .size g1
|
2012-10-06 07:12:48 +08:00
|
|
|
|
2014-10-16 06:38:23 +08:00
|
|
|
extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECKBASIC-DAG: @__libc_errno = thread_local alias i32, i32* @TL_WITH_ALIAS
|
2015-08-12 23:15:27 +08:00
|
|
|
// CHECKASM-DAG: .globl __libc_errno
|
2018-03-28 01:17:39 +08:00
|
|
|
// CHECKASM-DAG: .set __libc_errno, TL_WITH_ALIAS
|
2016-02-27 03:34:01 +08:00
|
|
|
// CHECKASM-NOT: .size __libc_errno
|
2014-10-16 06:38:23 +08:00
|
|
|
|
2012-10-06 07:12:48 +08:00
|
|
|
void f0(void) { }
|
|
|
|
extern void f1(void);
|
|
|
|
extern void f1(void) __attribute((alias("f0")));
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECKBASIC-DAG: @f1 = alias void (), void ()* @f0
|
|
|
|
// CHECKBASIC-DAG: @test8_foo = weak alias void (...), bitcast (void ()* @test8_bar to void (...)*)
|
|
|
|
// CHECKBASIC-DAG: @test8_zed = alias void (...), bitcast (void ()* @test8_bar to void (...)*)
|
|
|
|
// CHECKBASIC-DAG: @test9_zed = alias void (), void ()* @test9_bar
|
2013-02-27 07:08:48 +08:00
|
|
|
// CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] {
|
2009-03-23 05:21:57 +08:00
|
|
|
|
|
|
|
// Make sure that aliases cause referenced values to be emitted.
|
|
|
|
// PR3200
|
|
|
|
static inline int foo1() { return 0; }
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECKBASIC-LABEL: define internal i32 @foo1()
|
2009-03-23 05:21:57 +08:00
|
|
|
int foo() __attribute__((alias("foo1")));
|
|
|
|
int bar() __attribute__((alias("bar1")));
|
|
|
|
|
2009-03-23 05:39:12 +08:00
|
|
|
extern int test6();
|
|
|
|
void test7() { test6(); } // test6 is emitted as extern.
|
|
|
|
|
|
|
|
// test6 changes to alias.
|
|
|
|
int test6() __attribute__((alias("test7")));
|
|
|
|
|
2012-10-06 07:12:53 +08:00
|
|
|
static int inner(int a) { return 0; }
|
|
|
|
static int inner_weak(int a) { return 0; }
|
|
|
|
extern __typeof(inner) inner_a __attribute__((alias("inner")));
|
|
|
|
static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECKCC: @inner_a = alias i32 (i32), i32 (i32)* @inner
|
2013-02-27 07:08:48 +08:00
|
|
|
// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] {
|
2012-10-06 07:12:53 +08:00
|
|
|
|
|
|
|
int outer(int a) { return inner(a); }
|
2013-02-27 07:08:48 +08:00
|
|
|
// CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] {
|
2012-10-06 07:56:20 +08:00
|
|
|
// CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}})
|
2012-10-06 07:12:53 +08:00
|
|
|
|
|
|
|
int outer_weak(int a) { return inner_weak_a(a); }
|
2013-02-27 07:08:48 +08:00
|
|
|
// CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] {
|
2012-10-06 07:56:20 +08:00
|
|
|
// CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}})
|
2013-02-27 07:08:48 +08:00
|
|
|
// CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] {
|
2013-02-20 15:22:19 +08:00
|
|
|
|
Cleanup the handling of noinline function attributes, -fno-inline,
-fno-inline-functions, -O0, and optnone.
These were really, really tangled together:
- We used the noinline LLVM attribute for -fno-inline
- But not for -fno-inline-functions (breaking LTO)
- But we did use it for -finline-hint-functions (yay, LTO is happy!)
- But we didn't for -O0 (LTO is sad yet again...)
- We had weird structuring of CodeGenOpts with both an inlining
enumeration and a boolean. They interacted in weird ways and
needlessly.
- A *lot* of set smashing went on with setting these, and then got worse
when we considered optnone and other inlining-effecting attributes.
- A bunch of inline affecting attributes were managed in a completely
different place from -fno-inline.
- Even with -fno-inline we failed to put the LLVM noinline attribute
onto many generated function definitions because they didn't show up
as AST-level functions.
- If you passed -O0 but -finline-functions we would run the normal
inliner pass in LLVM despite it being in the O0 pipeline, which really
doesn't make much sense.
- Lastly, we used things like '-fno-inline' to manipulate the pass
pipeline which forced the pass pipeline to be much more
parameterizable than it really needs to be. Instead we can *just* use
the optimization level to select a pipeline and control the rest via
attributes.
Sadly, this causes a bunch of churn in tests because we don't run the
optimizer in the tests and check the contents of attribute sets. It
would be awesome if attribute sets were a bit more FileCheck friendly,
but oh well.
I think this is a significant improvement and should remove the semantic
need to change what inliner pass we run in order to comply with the
requested inlining semantics by relying completely on attributes. It
also cleans up tho optnone and related handling a bit.
One unfortunate aspect of this is that for generating alwaysinline
routines like those in OpenMP we end up removing noinline and then
adding alwaysinline. I tried a bunch of other approaches, but because we
recompute function attributes from scratch and don't have a declaration
here I couldn't find anything substantially cleaner than this.
Differential Revision: https://reviews.llvm.org/D28053
llvm-svn: 290398
2016-12-23 09:24:49 +08:00
|
|
|
// CHECKBASIC: attributes [[NUW]] = { noinline nounwind{{.*}} }
|
2013-02-20 15:22:19 +08:00
|
|
|
|
Cleanup the handling of noinline function attributes, -fno-inline,
-fno-inline-functions, -O0, and optnone.
These were really, really tangled together:
- We used the noinline LLVM attribute for -fno-inline
- But not for -fno-inline-functions (breaking LTO)
- But we did use it for -finline-hint-functions (yay, LTO is happy!)
- But we didn't for -O0 (LTO is sad yet again...)
- We had weird structuring of CodeGenOpts with both an inlining
enumeration and a boolean. They interacted in weird ways and
needlessly.
- A *lot* of set smashing went on with setting these, and then got worse
when we considered optnone and other inlining-effecting attributes.
- A bunch of inline affecting attributes were managed in a completely
different place from -fno-inline.
- Even with -fno-inline we failed to put the LLVM noinline attribute
onto many generated function definitions because they didn't show up
as AST-level functions.
- If you passed -O0 but -finline-functions we would run the normal
inliner pass in LLVM despite it being in the O0 pipeline, which really
doesn't make much sense.
- Lastly, we used things like '-fno-inline' to manipulate the pass
pipeline which forced the pass pipeline to be much more
parameterizable than it really needs to be. Instead we can *just* use
the optimization level to select a pipeline and control the rest via
attributes.
Sadly, this causes a bunch of churn in tests because we don't run the
optimizer in the tests and check the contents of attribute sets. It
would be awesome if attribute sets were a bit more FileCheck friendly,
but oh well.
I think this is a significant improvement and should remove the semantic
need to change what inliner pass we run in order to comply with the
requested inlining semantics by relying completely on attributes. It
also cleans up tho optnone and related handling a bit.
One unfortunate aspect of this is that for generating alwaysinline
routines like those in OpenMP we end up removing noinline and then
adding alwaysinline. I tried a bunch of other approaches, but because we
recompute function attributes from scratch and don't have a declaration
here I couldn't find anything substantially cleaner than this.
Differential Revision: https://reviews.llvm.org/D28053
llvm-svn: 290398
2016-12-23 09:24:49 +08:00
|
|
|
// CHECKCC: attributes [[NUW]] = { noinline nounwind{{.*}} }
|
2014-03-27 23:27:20 +08:00
|
|
|
|
|
|
|
void test8_bar() {}
|
|
|
|
void test8_foo() __attribute__((weak, alias("test8_bar")));
|
|
|
|
void test8_zed() __attribute__((alias("test8_foo")));
|
2014-05-06 04:21:03 +08:00
|
|
|
|
|
|
|
void test9_bar(void) { }
|
|
|
|
void test9_zed(void) __attribute__((section("test")));
|
|
|
|
void test9_zed(void) __attribute__((alias("test9_bar")));
|
2019-08-23 04:47:12 +08:00
|
|
|
|
|
|
|
// Test that the alias gets its linkage from its declared qual type.
|
|
|
|
// CHECKGLOBALS: @test10_foo = internal
|
|
|
|
// CHECKGLOBALS-NOT: @test10_foo = dso_local
|
|
|
|
int test10;
|
|
|
|
static int test10_foo __attribute__((alias("test10")));
|
|
|
|
// CHECKGLOBALS: @test11_foo = internal
|
|
|
|
// CHECKGLOBALS-NOT: @test11_foo = dso_local
|
|
|
|
void test11(void) {}
|
|
|
|
static void test11_foo(void) __attribute__((alias("test11")));
|