llvm.org GIT mirror llvm / 3d47402
Error if we see an alias to a declaration. In ELF and COFF an alias is just another offset in a section. There is no way to represent an alias to something in another file. In MachO, the spec has the N_INDR type which should allow for exactly that, but is not currently implemented. Given that it is specified but not implemented, we error in codegen to avoid miscompiling but don't reject aliases to declarations in the verifier to leave the option open of implementing it. In the past we have used alias to declarations as a way of implementing weakref, which is why it exists in some old tests which this patch updates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194705 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
10 changed file(s) with 75 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
948948 MCSymbol *Name = getSymbol(I);
949949
950950 const GlobalValue *GV = I->getAliasedGlobal();
951 if (GV->isDeclaration()) {
952 report_fatal_error(Name->getName() +
953 ": Target doesn't support aliases to declarations");
954 }
955
951956 MCSymbol *Target = getSymbol(GV);
952957
953958 if (I->hasExternalLinkage() || !MAI->getWeakRefDirective())
1515 ; CHECK: .globl A
1616 ; CHECK: A = bar
1717
18 @bar = external global i32
18 @bar = global i32 42
1919 @foo1 = alias i32* @bar
2020 @foo2 = alias i32* @bar
2121
2222 %FunTy = type i32()
2323
24 declare i32 @foo_f()
24 define i32 @foo_f() {
25 ret i32 0
26 }
2527 @bar_f = alias weak %FunTy* @foo_f
2628
2729 @bar_i = alias internal i32* @bar
6262 br label %bb44
6363 }
6464
65 declare i32 @pthread_once(i32*, void ()*)
65 define i32 @pthread_once(i32*, void ()*) {
66 ret i32 0
67 }
6668
67 declare i8* @pthread_getspecific(i32)
69 define i8* @pthread_getspecific(i32) {
70 ret i8* null
71 }
6872
69 declare i32 @pthread_setspecific(i32, i8*)
73 define i32 @pthread_setspecific(i32, i8*) {
74 ret i32 0
75 }
7076
71 declare i32 @pthread_create(i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*)
77 define i32 @pthread_create(i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*) {
78 ret i32 0
79 }
7280
73 declare i32 @pthread_cancel(i64)
81 define i32 @pthread_cancel(i64) {
82 ret i32 0
83 }
7484
75 declare i32 @pthread_mutex_lock(%struct.pthread_mutex_t*)
85 define i32 @pthread_mutex_lock(%struct.pthread_mutex_t*) {
86 ret i32 0
87 }
7688
77 declare i32 @pthread_mutex_trylock(%struct.pthread_mutex_t*)
89 define i32 @pthread_mutex_trylock(%struct.pthread_mutex_t*) {
90 ret i32 0
91 }
7892
79 declare i32 @pthread_mutex_unlock(%struct.pthread_mutex_t*)
93 define i32 @pthread_mutex_unlock(%struct.pthread_mutex_t*) {
94 ret i32 0
95 }
8096
81 declare i32 @pthread_mutex_init(%struct.pthread_mutex_t*, %struct.Alignment*)
97 define i32 @pthread_mutex_init(%struct.pthread_mutex_t*, %struct.Alignment*) {
98 ret i32 0
99 }
82100
83 declare i32 @pthread_key_create(i32*, void (i8*)*)
101 define i32 @pthread_key_create(i32*, void (i8*)*) {
102 ret i32 0
103 }
84104
85 declare i32 @pthread_key_delete(i32)
105 define i32 @pthread_key_delete(i32) {
106 ret i32 0
107 }
86108
87 declare i32 @pthread_mutexattr_init(%struct.Alignment*)
109 define i32 @pthread_mutexattr_init(%struct.Alignment*) {
110 ret i32 0
111 }
88112
89 declare i32 @pthread_mutexattr_settype(%struct.Alignment*, i32)
113 define i32 @pthread_mutexattr_settype(%struct.Alignment*, i32) {
114 ret i32 0
115 }
90116
91 declare i32 @pthread_mutexattr_destroy(%struct.Alignment*)
117 define i32 @pthread_mutexattr_destroy(%struct.Alignment*) {
118 ret i32 0
119 }
66 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
77 target triple = "powerpc64-unknown-linux-gnu"
88
9 @ei = external global i32
10 @a = alias i32* @ei
9 @a = external global i32
1110
1211 define signext i32 @test_external() nounwind {
1312 entry:
0 ; RUN: llc < %s -march=x86 | grep weak | count 2
11 @__gthrw_pthread_once = alias weak i32 (i32*, void ()*)* @pthread_once ; [#uses=0]
22
3 declare extern_weak i32 @pthread_once(i32*, void ()*)
3 define weak i32 @pthread_once(i32*, void ()*) {
4 ret i32 0
5 }
4444 ret i64 0
4545 }
4646
47 declare i64 @__wcstoll_l(i32*, i32**, i32, %struct.__locale_struct*) nounwind
47 define i64 @__wcstoll_l(i32*, i32**, i32, %struct.__locale_struct*) nounwind {
48 ret i64 0
49 }
0 ; RUN: not llc < %s -mtriple=i686-pc-linux-gnu %s 2>&1 | FileCheck %s
1
2 @a = external global i32
3 @b = alias i32* @a
4 ; CHECK: b: Target doesn't support aliases to declarations
0 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false | FileCheck %s
11
2 @bar = external global i32
2 @bar = global i32 42
33
44 ; CHECK-DAG: .globl foo1
55 @foo1 = alias i32* @bar
99
1010 %FunTy = type i32()
1111
12 declare i32 @foo_f()
12 define i32 @foo_f() {
13 ret i32 0
14 }
1315 ; CHECK-DAG: .weak bar_f
1416 @bar_f = alias weak %FunTy* @foo_f
1517
88 ret void
99 }
1010
11 declare extern_weak i32 @f()
11 define weak i32 @f() {
12 ret i32 42
13 }
0 ; RUN: llc < %s -march=xcore | FileCheck %s
1 declare void @a_val() nounwind
2 @b_val = external constant i32, section ".cp.rodata"
3 @c_val = external global i32
1 define void @a_val() nounwind {
2 ret void
3 }
4 @b_val = constant i32 42, section ".cp.rodata"
5 @c_val = global i32 42
46
57 @a = alias void ()* @a_val
68 @b = alias i32* @b_val