llvm-project

Форк
0
/
lto-internalize-unnamed-addr.ll 
128 строк · 7.4 Кб
1
; REQUIRES: x86
2
; RUN: rm -rf %t; split-file %s %t
3
;; This test covers both FullLTO and ThinLTO code paths because we have observed
4
;; (unexpected) differences between the two.
5
; RUN: llvm-as %t/test.ll -o %t/test.o
6
; RUN: llvm-as %t/test2.ll -o %t/test2.o
7
; RUN: opt -module-summary %t/test.ll -o %t/test.thinlto.o
8
; RUN: opt -module-summary %t/test2.ll -o %t/test2.thinlto.o
9

10
; RUN: %lld -lSystem %t/test.o %t/test2.o -o %t/test -save-temps
11
; RUN: llvm-dis < %t/test.0.2.internalize.bc | FileCheck %s --check-prefix=LTO-BC
12
; RUN: llvm-nm -m %t/test | FileCheck %s --check-prefix=LTO
13

14
; RUN: %lld -lSystem -dylib %t/test.o %t/test2.o -o %t/test.dylib -save-temps
15
; RUN: llvm-dis < %t/test.dylib.0.2.internalize.bc | FileCheck %s --check-prefix=LTO-BC-DYLIB
16
; RUN: llvm-nm -m %t/test.dylib | FileCheck %s --check-prefix=LTO-DYLIB
17

18
; RUN: %lld -lSystem %t/test.thinlto.o %t/test2.thinlto.o -o %t/test.thinlto \
19
; RUN:   -save-temps
20
; RUN: llvm-dis < %t/test.thinlto.o.2.internalize.bc | FileCheck %s --check-prefix=THINLTO-BC
21
; RUN: llvm-dis < %t/test2.thinlto.o.2.internalize.bc | FileCheck %s --check-prefix=THINLTO-BC-2
22
; RUN: llvm-nm -m %t/test.thinlto | FileCheck %s --check-prefix=THINLTO
23

24
; RUN: %lld -lSystem -dylib %t/test.thinlto.o %t/test2.thinlto.o -o \
25
; RUN:   %t/test.thinlto.dylib -save-temps
26
; RUN: llvm-dis < %t/test.thinlto.o.2.internalize.bc | FileCheck %s --check-prefix=THINLTO-BC-DYLIB
27
; RUN: llvm-dis < %t/test2.thinlto.o.2.internalize.bc | FileCheck %s --check-prefix=THINLTO-BC-2
28
; RUN: llvm-nm -m %t/test.thinlto.dylib | FileCheck %s --check-prefix=THINLTO-DYLIB
29

30
; LTO-BC-DAG: @global_unnamed = internal unnamed_addr global i8 42
31
; LTO-BC-DAG: @global_unnamed_sometimes_linkonce = internal unnamed_addr global i8 42
32
; LTO-BC-DAG: @local_unnamed_const = internal constant i8 42
33
; LTO-BC-DAG: @local_unnamed = internal global i8 42
34
; LTO-BC-DAG: @local_unnamed_always_const = internal constant i8 42
35
; LTO-BC-DAG: @local_unnamed_sometimes_const = internal constant i8 42
36

37
; LTO-BC-DYLIB-DAG: @global_unnamed = internal unnamed_addr global i8 42
38
; LTO-BC-DYLIB-DAG: @local_unnamed_const = internal constant i8 42
39
; LTO-BC-DYLIB-DAG: @local_unnamed = weak_odr global i8 42
40
; LTO-BC-DYLIB-DAG: @global_unnamed_sometimes_linkonce = weak_odr unnamed_addr global i8 42
41
; LTO-BC-DYLIB-DAG: @local_unnamed_always_const = internal constant i8 42
42
; LTO-BC-DYLIB-DAG: @local_unnamed_sometimes_const = weak_odr constant i8 42
43

44
; THINLTO-BC-DAG: @global_unnamed = internal unnamed_addr global i8 42
45
; THINLTO-BC-DAG: @global_unnamed_sometimes_linkonce = weak_odr unnamed_addr global i8 42
46
; THINLTO-BC-DAG: @local_unnamed_const = internal local_unnamed_addr constant i8 42
47
; THINLTO-BC-DAG: @local_unnamed_always_const = weak_odr hidden local_unnamed_addr constant i8 42
48
; THINLTO-BC-DAG: @local_unnamed_sometimes_const = weak_odr local_unnamed_addr constant i8 42
49
; THINLTO-BC-DAG: @local_unnamed = internal local_unnamed_addr global i8 42
50

51
; THINLTO-BC-DYLIB-DAG: @global_unnamed = internal unnamed_addr global i8 42
52
; THINLTO-BC-DYLIB-DAG: @global_unnamed_sometimes_linkonce = weak_odr unnamed_addr global i8 42
53
; THINLTO-BC-DYLIB-DAG: @local_unnamed_const = internal local_unnamed_addr constant i8 42
54
; THINLTO-BC-DYLIB-DAG: @local_unnamed_always_const = weak_odr hidden local_unnamed_addr constant i8 42
55
; THINLTO-BC-DYLIB-DAG: @local_unnamed_sometimes_const = weak_odr local_unnamed_addr constant i8 42
56
; THINLTO-BC-DYLIB-DAG: @local_unnamed = weak_odr local_unnamed_addr global i8 42
57

58
; THINLTO-BC-2-DAG: @global_unnamed_sometimes_linkonce = available_externally unnamed_addr global i8 42
59
; THINLTO-BC-2-DAG: @local_unnamed_always_const = available_externally local_unnamed_addr constant i8 42
60
; THINLTO-BC-2-DAG: @local_unnamed_sometimes_const = available_externally local_unnamed_addr global i8 42
61

62
; LTO-DAG: (__DATA,__data) non-external _global_unnamed
63
; LTO-DAG: (__DATA,__data) non-external _global_unnamed_sometimes_linkonce
64
; LTO-DAG: (__DATA,__data) non-external _local_unnamed
65
;; LD64 marks this with (was a private external). IMO both LD64 and LLD should
66
;; mark all the other internalized symbols with (was a private external).
67
; LTO-DAG: (__TEXT,__const) non-external _local_unnamed_always_const
68
; LTO-DAG: (__TEXT,__const) non-external _local_unnamed_const
69
;; LD64 doesn't internalize this -- it emits it as a weak external -- which I
70
;; think is a missed optimization on its end.
71
; LTO-DAG: (__TEXT,__const) non-external _local_unnamed_sometimes_const
72

73
;; The output here is largely identical to LD64's, except that the non-external
74
;; symbols here are all marked as (was a private external) by LD64. LLD should
75
;; follow suit.
76
; LTO-DYLIB-DAG: (__DATA,__data) non-external _global_unnamed
77
; LTO-DYLIB-DAG: (__DATA,__data) weak external _global_unnamed_sometimes_linkonce
78
; LTO-DYLIB-DAG: (__DATA,__data) weak external _local_unnamed
79
; LTO-DYLIB-DAG: (__TEXT,__const) non-external _local_unnamed_always_const
80
; LTO-DYLIB-DAG: (__TEXT,__const) non-external _local_unnamed_const
81
; LTO-DYLIB-DAG: (__TEXT,__const) weak external _local_unnamed_sometimes_const
82

83
; THINLTO-DAG: (__DATA,__data) non-external _global_unnamed
84
;; FIXME: This next symbol should probably be internalized, just like it is
85
;; under fullLTO.
86
; THINLTO-DAG: (__DATA,__data) weak external _global_unnamed_sometimes_linkonce
87
; THINLTO-DAG: (__DATA,__data) non-external _local_unnamed
88
; THINLTO-DAG: (__TEXT,__const) non-external (was a private external) _local_unnamed_always_const
89
; THINLTO-DAG: (__TEXT,__const) non-external _local_unnamed_const
90
;; LD64 actually fails to link when the following symbol is included in the test
91
;; input, instead producing this error:
92
;; reference to bitcode symbol '_local_unnamed_sometimes_const' which LTO has not compiled in '_used' from /tmp/lto.o for architecture x86_64
93
; THINLTO-DAG: (__TEXT,__const) weak external _local_unnamed_sometimes_const
94

95
; THINLTO-DYLIB-DAG: (__DATA,__data) non-external _global_unnamed
96
; THINLTO-DYLIB-DAG: (__DATA,__data) weak external _global_unnamed_sometimes_linkonce
97
; THINLTO-DYLIB-DAG: (__DATA,__data) weak external _local_unnamed
98
; THINLTO-DYLIB-DAG: (__TEXT,__const) non-external (was a private external) _local_unnamed_always_const
99
; THINLTO-DYLIB-DAG: (__TEXT,__const) non-external _local_unnamed_const
100
; THINLTO-DYLIB-DAG: (__TEXT,__const) weak external _local_unnamed_sometimes_const
101

102
;--- test.ll
103
target triple = "x86_64-apple-darwin"
104
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
105

106
@global_unnamed = linkonce_odr unnamed_addr global i8 42
107
@global_unnamed_sometimes_linkonce = linkonce_odr unnamed_addr global i8 42
108
@local_unnamed_const = linkonce_odr local_unnamed_addr constant i8 42
109
@local_unnamed_always_const = linkonce_odr local_unnamed_addr constant i8 42
110
@local_unnamed_sometimes_const = linkonce_odr local_unnamed_addr constant i8 42
111
@local_unnamed = linkonce_odr local_unnamed_addr global i8 42
112
@used = hidden constant [6 x ptr] [ptr @global_unnamed,
113
  ptr @global_unnamed_sometimes_linkonce, ptr @local_unnamed,
114
  ptr @local_unnamed_const, ptr @local_unnamed_always_const,
115
  ptr @local_unnamed_sometimes_const]
116
@llvm.used = appending global [1 x ptr] [ptr @used]
117

118
define void @main() {
119
  ret void
120
}
121

122
;--- test2.ll
123
target triple = "x86_64-apple-darwin"
124
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
125

126
@global_unnamed_sometimes_linkonce = weak_odr unnamed_addr global i8 42
127
@local_unnamed_always_const = linkonce_odr local_unnamed_addr constant i8 42
128
@local_unnamed_sometimes_const = linkonce_odr local_unnamed_addr global i8 42
129

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.