annotate clang/test/CodeGen/alias.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // REQUIRES: arm-registered-target
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 int g0;
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
8 // CHECKBASIC-DAG: @g0 ={{.*}} global i32 0
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
9 // CHECKASM-DAG: .bss
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
10 // CHECKASM-DAG: .globl g0
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
11 // CHECKASM-DAG: .p2align 2
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
12 // CHECKASM-DAG: g0:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
13 // CHECKASM-DAG: .long 0
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
14 // CHECKASM-DAG: .size g0, 4
150
anatofuz
parents:
diff changeset
15 __thread int TL_WITH_ALIAS;
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
16 // CHECKBASIC-DAG: @TL_WITH_ALIAS ={{.*}} thread_local global i32 0, align 4
150
anatofuz
parents:
diff changeset
17 // CHECKASM-DAG: .globl TL_WITH_ALIAS
anatofuz
parents:
diff changeset
18 // CHECKASM-DAG: .size TL_WITH_ALIAS, 4
anatofuz
parents:
diff changeset
19 static int bar1 = 42;
anatofuz
parents:
diff changeset
20 // CHECKBASIC-DAG: @bar1 = internal global i32 42
anatofuz
parents:
diff changeset
21 // CHECKASM-DAG: bar1:
anatofuz
parents:
diff changeset
22 // CHECKASM-DAG: .size bar1, 4
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 // PR24379: alias variable expected to have same size as aliasee even when types differ
anatofuz
parents:
diff changeset
25 const int wacom_usb_ids[] = {1, 1, 2, 3, 5, 8, 13, 0};
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
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 4
150
anatofuz
parents:
diff changeset
27 // CHECKASM-DAG: .globl wacom_usb_ids
anatofuz
parents:
diff changeset
28 // CHECKASM-DAG: .size wacom_usb_ids, 32
anatofuz
parents:
diff changeset
29 extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids")));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
30 // CHECKBASIC-DAG: @__mod_usb_device_table ={{.*}} alias i32, getelementptr inbounds ([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
150
anatofuz
parents:
diff changeset
31 // CHECKASM-DAG: .globl __mod_usb_device_table
anatofuz
parents:
diff changeset
32 // CHECKASM-DAG: .set __mod_usb_device_table, wacom_usb_ids
anatofuz
parents:
diff changeset
33 // CHECKASM-NOT: .size __mod_usb_device_table
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 extern int g1;
anatofuz
parents:
diff changeset
36 extern int g1 __attribute((alias("g0")));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
37 // CHECKBASIC-DAG: @g1 ={{.*}} alias i32, i32* @g0
150
anatofuz
parents:
diff changeset
38 // CHECKASM-DAG: .globl g1
anatofuz
parents:
diff changeset
39 // CHECKASM-DAG: .set g1, g0
anatofuz
parents:
diff changeset
40 // CHECKASM-NOT: .size g1
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
43 // CHECKBASIC-DAG: @__libc_errno ={{.*}} thread_local alias i32, i32* @TL_WITH_ALIAS
150
anatofuz
parents:
diff changeset
44 // CHECKASM-DAG: .globl __libc_errno
anatofuz
parents:
diff changeset
45 // CHECKASM-DAG: .set __libc_errno, TL_WITH_ALIAS
anatofuz
parents:
diff changeset
46 // CHECKASM-NOT: .size __libc_errno
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 void f0(void) { }
anatofuz
parents:
diff changeset
49 extern void f1(void);
anatofuz
parents:
diff changeset
50 extern void f1(void) __attribute((alias("f0")));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
51 // CHECKBASIC-DAG: @f1 ={{.*}} alias void (), void ()* @f0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
52 // CHECKBASIC-DAG: @test8_foo = weak{{.*}} alias void (...), bitcast (void ()* @test8_bar to void (...)*)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
53 // CHECKBASIC-DAG: @test8_zed ={{.*}} alias void (...), bitcast (void ()* @test8_bar to void (...)*)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
54 // CHECKBASIC-DAG: @test9_zed ={{.*}} alias void (), void ()* @test9_bar
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
55 // CHECKBASIC: define{{.*}} void @f0() [[NUW:#[0-9]+]] {
150
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 // Make sure that aliases cause referenced values to be emitted.
anatofuz
parents:
diff changeset
58 // PR3200
anatofuz
parents:
diff changeset
59 static inline int foo1() { return 0; }
anatofuz
parents:
diff changeset
60 // CHECKBASIC-LABEL: define internal i32 @foo1()
anatofuz
parents:
diff changeset
61 int foo() __attribute__((alias("foo1")));
anatofuz
parents:
diff changeset
62 int bar() __attribute__((alias("bar1")));
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 extern int test6();
anatofuz
parents:
diff changeset
65 void test7() { test6(); } // test6 is emitted as extern.
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 // test6 changes to alias.
anatofuz
parents:
diff changeset
68 int test6() __attribute__((alias("test7")));
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 static int inner(int a) { return 0; }
anatofuz
parents:
diff changeset
71 static int inner_weak(int a) { return 0; }
anatofuz
parents:
diff changeset
72 extern __typeof(inner) inner_a __attribute__((alias("inner")));
anatofuz
parents:
diff changeset
73 static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
74 // CHECKCC: @inner_a ={{.*}} alias i32 (i32), i32 (i32)* @inner
150
anatofuz
parents:
diff changeset
75 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] {
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 int outer(int a) { return inner(a); }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
78 // CHECKCC: define{{.*}} arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] {
150
anatofuz
parents:
diff changeset
79 // CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}})
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 int outer_weak(int a) { return inner_weak_a(a); }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
82 // CHECKCC: define{{.*}} arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] {
150
anatofuz
parents:
diff changeset
83 // CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}})
anatofuz
parents:
diff changeset
84 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] {
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 // CHECKBASIC: attributes [[NUW]] = { noinline nounwind{{.*}} }
anatofuz
parents:
diff changeset
87
anatofuz
parents:
diff changeset
88 // CHECKCC: attributes [[NUW]] = { noinline nounwind{{.*}} }
anatofuz
parents:
diff changeset
89
anatofuz
parents:
diff changeset
90 void test8_bar() {}
anatofuz
parents:
diff changeset
91 void test8_foo() __attribute__((weak, alias("test8_bar")));
anatofuz
parents:
diff changeset
92 void test8_zed() __attribute__((alias("test8_foo")));
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 void test9_bar(void) { }
anatofuz
parents:
diff changeset
95 void test9_zed(void) __attribute__((section("test")));
anatofuz
parents:
diff changeset
96 void test9_zed(void) __attribute__((alias("test9_bar")));
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98 // Test that the alias gets its linkage from its declared qual type.
anatofuz
parents:
diff changeset
99 // CHECKGLOBALS: @test10_foo = internal
anatofuz
parents:
diff changeset
100 // CHECKGLOBALS-NOT: @test10_foo = dso_local
anatofuz
parents:
diff changeset
101 int test10;
anatofuz
parents:
diff changeset
102 static int test10_foo __attribute__((alias("test10")));
anatofuz
parents:
diff changeset
103 // CHECKGLOBALS: @test11_foo = internal
anatofuz
parents:
diff changeset
104 // CHECKGLOBALS-NOT: @test11_foo = dso_local
anatofuz
parents:
diff changeset
105 void test11(void) {}
anatofuz
parents:
diff changeset
106 static void test11_foo(void) __attribute__((alias("test11")));
anatofuz
parents:
diff changeset
107
anatofuz
parents:
diff changeset
108 // Test that gnu_inline+alias work.
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
109 // CHECKGLOBALS: @test12_alias ={{.*}} alias void (), void ()* @test12
150
anatofuz
parents:
diff changeset
110 void test12(void) {}
anatofuz
parents:
diff changeset
111 inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
112
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
113 // Test that a non visible (-Wvisibility) type doesn't assert.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
114 // CHECKGLOBALS: @test13_alias ={{.*}} alias {}, bitcast (void (i32)* @test13 to {}*)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
115 enum a_type { test13_a };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
116 void test13(enum a_type y) {}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
117 void test13_alias(enum undeclared_type y) __attribute__((alias ("test13")));