Skip to content

Commit a981a4f

Browse files
aeubankststellar
authored andcommitted
[X86] Always use 64-bit relocations in no-PIC large code model (llvm#89101)
This matches other types of relocations, e.g. to constant pool. And makes things more consistent with PIC large code model. Some users of the large code model may not place small data in the lower 2GB of the address space (e.g. ClangBuiltLinux/linux#2016), so just unconditionally use 64-bit relocations in the large code model. So now functions in a section not marked large will use 64-bit relocations to reference everything when using the large code model. This also fixes some lldb tests broken by llvm#88172 (https://lab.llvm.org/buildbot/#/builders/68/builds/72458). (cherry picked from commit 6cea7c4)
1 parent 4ddac85 commit a981a4f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -2923,11 +2923,10 @@ bool X86DAGToDAGISel::selectAddr(SDNode *Parent, SDValue N, SDValue &Base,
29232923
}
29242924

29252925
bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
2926-
// Cannot use 32 bit constants to reference objects in kernel code model.
2927-
// Cannot use 32 bit constants to reference objects in large PIC mode since
2928-
// GOTOFF is 64 bits.
2926+
// Cannot use 32 bit constants to reference objects in kernel/large code
2927+
// model.
29292928
if (TM.getCodeModel() == CodeModel::Kernel ||
2930-
(TM.getCodeModel() == CodeModel::Large && TM.isPositionIndependent()))
2929+
TM.getCodeModel() == CodeModel::Large)
29312930
return false;
29322931

29332932
// In static codegen with small code model, we can get the address of a label

llvm/test/CodeGen/X86/code-model-elf.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ define dso_local ptr @lea_forced_small_data() #0 {
346346
;
347347
; LARGE-STATIC-LABEL: lea_forced_small_data:
348348
; LARGE-STATIC: # %bb.0:
349-
; LARGE-STATIC-NEXT: movl $forced_small_data, %eax
349+
; LARGE-STATIC-NEXT: movabsq $forced_small_data, %rax
350350
; LARGE-STATIC-NEXT: retq
351351
;
352352
; SMALL-PIC-LABEL: lea_forced_small_data:
@@ -399,7 +399,7 @@ define dso_local i32 @load_forced_small_data() #0 {
399399
;
400400
; LARGE-STATIC-LABEL: load_forced_small_data:
401401
; LARGE-STATIC: # %bb.0:
402-
; LARGE-STATIC-NEXT: movl $forced_small_data+8, %eax
402+
; LARGE-STATIC-NEXT: movabsq $forced_small_data+8, %rax
403403
; LARGE-STATIC-NEXT: movl (%rax), %eax
404404
; LARGE-STATIC-NEXT: retq
405405
;

0 commit comments

Comments
 (0)