comparison 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
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
3 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s 3 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
4 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s 4 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
5 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s 5 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
6 6
7 int g0; 7 int g0;
8 // CHECKBASIC-DAG: @g0 = global i32 0 8 // CHECKBASIC-DAG: @g0 ={{.*}} global i32 0
9 // CHECKASM-DAG: .bss 9 // CHECKASM-DAG: .bss
10 // CHECKASM-DAG: .globl g0 10 // CHECKASM-DAG: .globl g0
11 // CHECKASM-DAG: .p2align 2 11 // CHECKASM-DAG: .p2align 2
12 // CHECKASM-DAG: g0: 12 // CHECKASM-DAG: g0:
13 // CHECKASM-DAG: .long 0 13 // CHECKASM-DAG: .long 0
14 // CHECKASM-DAG: .size g0, 4 14 // CHECKASM-DAG: .size g0, 4
15 __thread int TL_WITH_ALIAS; 15 __thread int TL_WITH_ALIAS;
16 // CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4 16 // CHECKBASIC-DAG: @TL_WITH_ALIAS ={{.*}} thread_local global i32 0, align 4
17 // CHECKASM-DAG: .globl TL_WITH_ALIAS 17 // CHECKASM-DAG: .globl TL_WITH_ALIAS
18 // CHECKASM-DAG: .size TL_WITH_ALIAS, 4 18 // CHECKASM-DAG: .size TL_WITH_ALIAS, 4
19 static int bar1 = 42; 19 static int bar1 = 42;
20 // CHECKBASIC-DAG: @bar1 = internal global i32 42 20 // CHECKBASIC-DAG: @bar1 = internal global i32 42
21 // CHECKASM-DAG: bar1: 21 // CHECKASM-DAG: bar1:
22 // CHECKASM-DAG: .size bar1, 4 22 // CHECKASM-DAG: .size bar1, 4
23 23
24 // PR24379: alias variable expected to have same size as aliasee even when types differ 24 // PR24379: alias variable expected to have same size as aliasee even when types differ
25 const int wacom_usb_ids[] = {1, 1, 2, 3, 5, 8, 13, 0}; 25 const 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 4 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
27 // CHECKASM-DAG: .globl wacom_usb_ids 27 // CHECKASM-DAG: .globl wacom_usb_ids
28 // CHECKASM-DAG: .size wacom_usb_ids, 32 28 // CHECKASM-DAG: .size wacom_usb_ids, 32
29 extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids"))); 29 extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids")));
30 // CHECKBASIC-DAG: @__mod_usb_device_table = alias i32, getelementptr inbounds ([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0) 30 // CHECKBASIC-DAG: @__mod_usb_device_table ={{.*}} alias i32, getelementptr inbounds ([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
31 // CHECKASM-DAG: .globl __mod_usb_device_table 31 // CHECKASM-DAG: .globl __mod_usb_device_table
32 // CHECKASM-DAG: .set __mod_usb_device_table, wacom_usb_ids 32 // CHECKASM-DAG: .set __mod_usb_device_table, wacom_usb_ids
33 // CHECKASM-NOT: .size __mod_usb_device_table 33 // CHECKASM-NOT: .size __mod_usb_device_table
34 34
35 extern int g1; 35 extern int g1;
36 extern int g1 __attribute((alias("g0"))); 36 extern int g1 __attribute((alias("g0")));
37 // CHECKBASIC-DAG: @g1 = alias i32, i32* @g0 37 // CHECKBASIC-DAG: @g1 ={{.*}} alias i32, i32* @g0
38 // CHECKASM-DAG: .globl g1 38 // CHECKASM-DAG: .globl g1
39 // CHECKASM-DAG: .set g1, g0 39 // CHECKASM-DAG: .set g1, g0
40 // CHECKASM-NOT: .size g1 40 // CHECKASM-NOT: .size g1
41 41
42 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS"))); 42 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
43 // CHECKBASIC-DAG: @__libc_errno = thread_local alias i32, i32* @TL_WITH_ALIAS 43 // CHECKBASIC-DAG: @__libc_errno ={{.*}} thread_local alias i32, i32* @TL_WITH_ALIAS
44 // CHECKASM-DAG: .globl __libc_errno 44 // CHECKASM-DAG: .globl __libc_errno
45 // CHECKASM-DAG: .set __libc_errno, TL_WITH_ALIAS 45 // CHECKASM-DAG: .set __libc_errno, TL_WITH_ALIAS
46 // CHECKASM-NOT: .size __libc_errno 46 // CHECKASM-NOT: .size __libc_errno
47 47
48 void f0(void) { } 48 void f0(void) { }
49 extern void f1(void); 49 extern void f1(void);
50 extern void f1(void) __attribute((alias("f0"))); 50 extern void f1(void) __attribute((alias("f0")));
51 // CHECKBASIC-DAG: @f1 = alias void (), void ()* @f0 51 // CHECKBASIC-DAG: @f1 ={{.*}} alias void (), void ()* @f0
52 // CHECKBASIC-DAG: @test8_foo = weak alias void (...), bitcast (void ()* @test8_bar to void (...)*) 52 // CHECKBASIC-DAG: @test8_foo = weak{{.*}} alias void (...), bitcast (void ()* @test8_bar to void (...)*)
53 // CHECKBASIC-DAG: @test8_zed = alias void (...), bitcast (void ()* @test8_bar to void (...)*) 53 // CHECKBASIC-DAG: @test8_zed ={{.*}} alias void (...), bitcast (void ()* @test8_bar to void (...)*)
54 // CHECKBASIC-DAG: @test9_zed = alias void (), void ()* @test9_bar 54 // CHECKBASIC-DAG: @test9_zed ={{.*}} alias void (), void ()* @test9_bar
55 // CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] { 55 // CHECKBASIC: define{{.*}} void @f0() [[NUW:#[0-9]+]] {
56 56
57 // Make sure that aliases cause referenced values to be emitted. 57 // Make sure that aliases cause referenced values to be emitted.
58 // PR3200 58 // PR3200
59 static inline int foo1() { return 0; } 59 static inline int foo1() { return 0; }
60 // CHECKBASIC-LABEL: define internal i32 @foo1() 60 // CHECKBASIC-LABEL: define internal i32 @foo1()
69 69
70 static int inner(int a) { return 0; } 70 static int inner(int a) { return 0; }
71 static int inner_weak(int a) { return 0; } 71 static int inner_weak(int a) { return 0; }
72 extern __typeof(inner) inner_a __attribute__((alias("inner"))); 72 extern __typeof(inner) inner_a __attribute__((alias("inner")));
73 static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak"))); 73 static __typeof(inner_weak) inner_weak_a __attribute__((weakref, alias("inner_weak")));
74 // CHECKCC: @inner_a = alias i32 (i32), i32 (i32)* @inner 74 // CHECKCC: @inner_a ={{.*}} alias i32 (i32), i32 (i32)* @inner
75 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] { 75 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner(i32 %a) [[NUW:#[0-9]+]] {
76 76
77 int outer(int a) { return inner(a); } 77 int outer(int a) { return inner(a); }
78 // CHECKCC: define arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] { 78 // CHECKCC: define{{.*}} arm_aapcs_vfpcc i32 @outer(i32 %a) [[NUW]] {
79 // CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}}) 79 // CHECKCC: call arm_aapcs_vfpcc i32 @inner(i32 %{{.*}})
80 80
81 int outer_weak(int a) { return inner_weak_a(a); } 81 int outer_weak(int a) { return inner_weak_a(a); }
82 // CHECKCC: define arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] { 82 // CHECKCC: define{{.*}} arm_aapcs_vfpcc i32 @outer_weak(i32 %a) [[NUW]] {
83 // CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}}) 83 // CHECKCC: call arm_aapcs_vfpcc i32 @inner_weak(i32 %{{.*}})
84 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] { 84 // CHECKCC: define internal arm_aapcs_vfpcc i32 @inner_weak(i32 %a) [[NUW]] {
85 85
86 // CHECKBASIC: attributes [[NUW]] = { noinline nounwind{{.*}} } 86 // CHECKBASIC: attributes [[NUW]] = { noinline nounwind{{.*}} }
87 87
104 // CHECKGLOBALS-NOT: @test11_foo = dso_local 104 // CHECKGLOBALS-NOT: @test11_foo = dso_local
105 void test11(void) {} 105 void test11(void) {}
106 static void test11_foo(void) __attribute__((alias("test11"))); 106 static void test11_foo(void) __attribute__((alias("test11")));
107 107
108 // Test that gnu_inline+alias work. 108 // Test that gnu_inline+alias work.
109 // CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12 109 // CHECKGLOBALS: @test12_alias ={{.*}} alias void (), void ()* @test12
110 void test12(void) {} 110 void test12(void) {}
111 inline void test12_alias(void) __attribute__((gnu_inline, alias("test12"))); 111 inline 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 {}, bitcast (void (i32)* @test13 to {}*)
115 enum a_type { test13_a };
116 void test13(enum a_type y) {}
117 void test13_alias(enum undeclared_type y) __attribute__((alias ("test13")));