Skip to content

Commit 109e70d

Browse files
committed
[TargetMachine] Drop implied dso_local for an edge case (extern_weak + non-pic + hidden)
This does not deserve special handling. The code should be added to Clang instead if deemed useful. With this simplification, we can additionally delete the PIC extern_weak special case.
1 parent a553ac9 commit 109e70d

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

llvm/lib/Target/TargetMachine.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
143143
if (TT.isOSBinFormatCOFF() || TT.isOSWindows())
144144
return true;
145145

146-
// Most PIC code sequences that assume that a symbol is local cannot
147-
// produce a 0 if it turns out the symbol is undefined. While this
148-
// is ABI and relocation depended, it seems worth it to handle it
149-
// here.
150-
if (isPositionIndependent() && GV->hasExternalWeakLinkage())
151-
return false;
152-
153-
if (!GV->hasDefaultVisibility())
154-
return true;
155-
156146
if (TT.isOSBinFormatMachO()) {
157147
if (RM == Reloc::Static)
158148
return true;

llvm/test/CodeGen/ARM/hidden-vis-3.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ define i32 @t() nounwind readonly {
77
entry:
88
; CHECK: LCPI0_0:
99
; CHECK-NEXT: .long _x
10+
;; .long _y can be used if @y is dso_local.
1011
; CHECK: LCPI0_1:
11-
; CHECK-NEXT: .long _y
12+
; CHECK-NEXT: .long L_y$non_lazy_ptr
1213

1314
%0 = load i32, i32* @x, align 4 ; <i32> [#uses=1]
1415
%1 = load i32, i32* @y, align 4 ; <i32> [#uses=1]

llvm/test/CodeGen/X86/hidden-vis-3.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
define i32 @t() nounwind readonly {
88
entry:
9+
;; movl _y, %eax can be used if @y is dso_local.
910
; X32: _t:
10-
; X32: movl _y, %eax
11+
; X32: movl L_y$non_lazy_ptr, %eax
12+
; X32-NEXT: movl (%eax), %eax
1113

1214
; X64: _t:
1315
; X64: movq _y@GOTPCREL(%rip), %rax

0 commit comments

Comments
 (0)