Skip to content

Commit d6256d5

Browse files
committed
Revert "[X86] Always use 64-bit relocations in no-PIC large code model (llvm#89101)"
This reverts commit 6cea7c4.
1 parent 81423ac commit d6256d5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,10 +2923,11 @@ 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/large code
2927-
// model.
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.
29282929
if (TM.getCodeModel() == CodeModel::Kernel ||
2929-
TM.getCodeModel() == CodeModel::Large)
2930+
(TM.getCodeModel() == CodeModel::Large && TM.isPositionIndependent()))
29302931
return false;
29312932

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

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

Lines changed: 2 additions & 2 deletions
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: movabsq $forced_small_data, %rax
349+
; LARGE-STATIC-NEXT: movl $forced_small_data, %eax
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: movabsq $forced_small_data+8, %rax
402+
; LARGE-STATIC-NEXT: movl $forced_small_data+8, %eax
403403
; LARGE-STATIC-NEXT: movl (%rax), %eax
404404
; LARGE-STATIC-NEXT: retq
405405
;

0 commit comments

Comments
 (0)