Skip to content

[X86] Always use 64-bit relocations in no-PIC large code model #89101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2927,11 +2927,10 @@ bool X86DAGToDAGISel::selectAddr(SDNode *Parent, SDValue N, SDValue &Base,
}

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

// In static codegen with small code model, we can get the address of a label
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/X86/code-model-elf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ define dso_local ptr @lea_forced_small_data() #0 {
;
; LARGE-STATIC-LABEL: lea_forced_small_data:
; LARGE-STATIC: # %bb.0:
; LARGE-STATIC-NEXT: movl $forced_small_data, %eax
; LARGE-STATIC-NEXT: movabsq $forced_small_data, %rax
; LARGE-STATIC-NEXT: retq
;
; SMALL-PIC-LABEL: lea_forced_small_data:
Expand Down Expand Up @@ -403,7 +403,7 @@ define dso_local i32 @load_forced_small_data() #0 {
;
; LARGE-STATIC-LABEL: load_forced_small_data:
; LARGE-STATIC: # %bb.0:
; LARGE-STATIC-NEXT: movl $forced_small_data+8, %eax
; LARGE-STATIC-NEXT: movabsq $forced_small_data+8, %rax
; LARGE-STATIC-NEXT: movl (%rax), %eax
; LARGE-STATIC-NEXT: retq
;
Expand Down
Loading