Skip to content

Commit 9970817

Browse files
committed
Deduplicate S_CONSTANTs in LLD.
Summary: Deduplicate S_CONSTANTS when linking, if they have the same value. Reviewers: rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63151 llvm-svn: 363089
1 parent 36bd1c9 commit 9970817

File tree

4 files changed

+450
-4
lines changed

4 files changed

+450
-4
lines changed
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
.text
2+
.def @feat.00;
3+
.scl 3;
4+
.type 0;
5+
.endef
6+
.globl @feat.00
7+
.set @feat.00, 0
8+
.file "t.cpp"
9+
.def main;
10+
.scl 2;
11+
.type 32;
12+
.endef
13+
.globl main # -- Begin function main
14+
.p2align 4, 0x90
15+
main: # @main
16+
.Lfunc_begin0:
17+
.cv_func_id 0
18+
.cv_file 1 "C:\\src\\testing\\t.cpp" "D28AB0CC784E17E5DF9BBB49CB629C81" 1
19+
.cv_loc 0 1 4 0 # t.cpp:4:0
20+
.seh_proc main
21+
# %bb.0: # %entry
22+
pushq %rax
23+
.seh_stackalloc 8
24+
.seh_endprologue
25+
movl $0, 4(%rsp)
26+
.Ltmp0:
27+
movl $83, %eax
28+
popq %rcx
29+
retq
30+
.Ltmp1:
31+
.Lfunc_end0:
32+
.seh_handlerdata
33+
.text
34+
.seh_endproc
35+
# -- End function
36+
.section .debug$S,"dr"
37+
.p2align 2
38+
.long 4 # Debug section magic
39+
.long 241
40+
.long .Ltmp3-.Ltmp2 # Subsection size
41+
.Ltmp2:
42+
.short .Ltmp5-.Ltmp4 # Record length
43+
.Ltmp4:
44+
.short 4412 # Record kind: S_COMPILE3
45+
.long 1 # Flags and language
46+
.short 208 # CPUType
47+
.short 9 # Frontend version
48+
.short 0
49+
.short 0
50+
.short 0
51+
.short 9000 # Backend version
52+
.short 0
53+
.short 0
54+
.short 0
55+
.asciz "clang version 9.0.0 (https://github.com/llvm/llvm-project.git ad522e17b285b1f2667163d52da5abf0968ec650)" # Null-terminated compiler version string
56+
.p2align 2
57+
.Ltmp5:
58+
.Ltmp3:
59+
.p2align 2
60+
.long 241 # Symbol subsection for main
61+
.long .Ltmp7-.Ltmp6 # Subsection size
62+
.Ltmp6:
63+
.short .Ltmp9-.Ltmp8 # Record length
64+
.Ltmp8:
65+
.short 4423 # Record kind: S_GPROC32_ID
66+
.long 0 # PtrParent
67+
.long 0 # PtrEnd
68+
.long 0 # PtrNext
69+
.long .Lfunc_end0-main # Code size
70+
.long 0 # Offset after prologue
71+
.long 0 # Offset before epilogue
72+
.long 4098 # Function type index
73+
.secrel32 main # Function section relative address
74+
.secidx main # Function section index
75+
.byte 0 # Flags
76+
.asciz "main" # Function name
77+
.p2align 2
78+
.Ltmp9:
79+
.short .Ltmp11-.Ltmp10 # Record length
80+
.Ltmp10:
81+
.short 4114 # Record kind: S_FRAMEPROC
82+
.long 8 # FrameSize
83+
.long 0 # Padding
84+
.long 0 # Offset of padding
85+
.long 0 # Bytes of callee saved registers
86+
.long 0 # Exception handler offset
87+
.short 0 # Exception handler section
88+
.long 81920 # Flags (defines frame register)
89+
.p2align 2
90+
.Ltmp11:
91+
.short 2 # Record length
92+
.short 4431 # Record kind: S_PROC_ID_END
93+
.Ltmp7:
94+
.p2align 2
95+
.cv_linetable 0, main, .Lfunc_end0
96+
.long 241 # Symbol subsection for globals
97+
.long .Ltmp13-.Ltmp12 # Subsection size
98+
.Ltmp12:
99+
.short .Ltmp15-.Ltmp14 # Record length
100+
.Ltmp14:
101+
.short 4359 # Record kind: S_CONSTANT
102+
.long 4099 # Type
103+
.byte 0x29, 0x00 # Value
104+
.asciz "Foo" # Name
105+
.p2align 2
106+
.Ltmp15:
107+
.short .Ltmp17-.Ltmp16 # Record length
108+
.Ltmp16:
109+
.short 4359 # Record kind: S_CONSTANT
110+
.long 4099 # Type
111+
.byte 0x2a, 0x00 # Value
112+
.asciz "Bar" # Name
113+
.p2align 2
114+
.Ltmp17:
115+
.Ltmp13:
116+
.p2align 2
117+
.cv_filechecksums # File index to string table offset subsection
118+
.cv_stringtable # String table
119+
.long 241
120+
.long .Ltmp19-.Ltmp18 # Subsection size
121+
.Ltmp18:
122+
.short .Ltmp21-.Ltmp20 # Record length
123+
.Ltmp20:
124+
.short 4428 # Record kind: S_BUILDINFO
125+
.long 4102 # LF_BUILDINFO index
126+
.p2align 2
127+
.Ltmp21:
128+
.Ltmp19:
129+
.p2align 2
130+
.section .debug$T,"dr"
131+
.p2align 2
132+
.long 4 # Debug section magic
133+
# ArgList (0x1000) {
134+
# TypeLeafKind: LF_ARGLIST (0x1201)
135+
# NumArgs: 0
136+
# Arguments [
137+
# ]
138+
# }
139+
.byte 0x06, 0x00, 0x01, 0x12
140+
.byte 0x00, 0x00, 0x00, 0x00
141+
# Procedure (0x1001) {
142+
# TypeLeafKind: LF_PROCEDURE (0x1008)
143+
# ReturnType: int (0x74)
144+
# CallingConvention: NearC (0x0)
145+
# FunctionOptions [ (0x0)
146+
# ]
147+
# NumParameters: 0
148+
# ArgListType: () (0x1000)
149+
# }
150+
.byte 0x0e, 0x00, 0x08, 0x10
151+
.byte 0x74, 0x00, 0x00, 0x00
152+
.byte 0x00, 0x00, 0x00, 0x00
153+
.byte 0x00, 0x10, 0x00, 0x00
154+
# FuncId (0x1002) {
155+
# TypeLeafKind: LF_FUNC_ID (0x1601)
156+
# ParentScope: 0x0
157+
# FunctionType: int () (0x1001)
158+
# Name: main
159+
# }
160+
.byte 0x12, 0x00, 0x01, 0x16
161+
.byte 0x00, 0x00, 0x00, 0x00
162+
.byte 0x01, 0x10, 0x00, 0x00
163+
.byte 0x6d, 0x61, 0x69, 0x6e
164+
.byte 0x00, 0xf3, 0xf2, 0xf1
165+
# Modifier (0x1003) {
166+
# TypeLeafKind: LF_MODIFIER (0x1001)
167+
# ModifiedType: int (0x74)
168+
# Modifiers [ (0x1)
169+
# Const (0x1)
170+
# ]
171+
# }
172+
.byte 0x0a, 0x00, 0x01, 0x10
173+
.byte 0x74, 0x00, 0x00, 0x00
174+
.byte 0x01, 0x00, 0xf2, 0xf1
175+
# StringId (0x1004) {
176+
# TypeLeafKind: LF_STRING_ID (0x1605)
177+
# Id: 0x0
178+
# StringData: C:\src\testing
179+
# }
180+
.byte 0x16, 0x00, 0x05, 0x16
181+
.byte 0x00, 0x00, 0x00, 0x00
182+
.byte 0x43, 0x3a, 0x5c, 0x73
183+
.byte 0x72, 0x63, 0x5c, 0x74
184+
.byte 0x65, 0x73, 0x74, 0x69
185+
.byte 0x6e, 0x67, 0x00, 0xf1
186+
# StringId (0x1005) {
187+
# TypeLeafKind: LF_STRING_ID (0x1605)
188+
# Id: 0x0
189+
# StringData: t.cpp
190+
# }
191+
.byte 0x0e, 0x00, 0x05, 0x16
192+
.byte 0x00, 0x00, 0x00, 0x00
193+
.byte 0x74, 0x2e, 0x63, 0x70
194+
.byte 0x70, 0x00, 0xf2, 0xf1
195+
# BuildInfo (0x1006) {
196+
# TypeLeafKind: LF_BUILDINFO (0x1603)
197+
# NumArgs: 5
198+
# Arguments [
199+
# ArgType: C:\src\testing (0x1004)
200+
# ArgType: 0x0
201+
# ArgType: t.cpp (0x1005)
202+
# ArgType: 0x0
203+
# ArgType: 0x0
204+
# ]
205+
# }
206+
.byte 0x1a, 0x00, 0x03, 0x16
207+
.byte 0x05, 0x00, 0x04, 0x10
208+
.byte 0x00, 0x00, 0x00, 0x00
209+
.byte 0x00, 0x00, 0x05, 0x10
210+
.byte 0x00, 0x00, 0x00, 0x00
211+
.byte 0x00, 0x00, 0x00, 0x00
212+
.byte 0x00, 0x00, 0xf2, 0xf1
213+
214+
.addrsig

0 commit comments

Comments
 (0)