Skip to content

Commit

Permalink
Revert "[X86] Handle ifuncs in TargetMachine::isLargeGlobalObject() (l…
Browse files Browse the repository at this point in the history
…lvm#74911)"

This reverts commit 3850131.
  • Loading branch information
Zentrik committed Jul 7, 2024
1 parent fdea82a commit c27b24f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 136 deletions.
7 changes: 1 addition & 6 deletions llvm/lib/Target/TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@ bool TargetMachine::isLargeGlobalObject(const GlobalObject *GO) const {
if (getTargetTriple().getArch() != Triple::x86_64)
return false;

if (getCodeModel() != CodeModel::Medium && getCodeModel() != CodeModel::Large)
return false;

if (isa<Function>(GO))
return getCodeModel() == CodeModel::Large;

// Functions/GlobalIFuncs are only large under the large code model.
if (!GV)
return getCodeModel() == CodeModel::Large;
auto *GV = cast<GlobalVariable>(GO);

if (GV->isThreadLocal())
return false;
Expand Down
142 changes: 12 additions & 130 deletions llvm/test/CodeGen/X86/code-model-elf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -702,18 +702,6 @@ define internal void @static_fn() #0 {

declare void @extern_fn()

@ifunc_func = ifunc void (), ptr @resolver
@dso_local_ifunc_func = dso_local ifunc void (), ptr @resolver

define internal ptr @resolver() {
; CHECK-LABEL: resolver:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
entry:
ret ptr null
}

define dso_local ptr @lea_static_fn() #0 {
; SMALL-STATIC-LABEL: lea_static_fn:
; SMALL-STATIC: # %bb.0:
Expand Down Expand Up @@ -747,9 +735,9 @@ define dso_local ptr @lea_static_fn() #0 {
;
; LARGE-PIC-LABEL: lea_static_fn:
; LARGE-PIC: # %bb.0:
; LARGE-PIC-NEXT: .L14$pb:
; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx
; LARGE-PIC-NEXT: .L13$pb:
; LARGE-PIC-NEXT: leaq .L13$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L13$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $static_fn@GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
Expand Down Expand Up @@ -800,9 +788,9 @@ define dso_local ptr @lea_global_fn() #0 {
;
; LARGE-PIC-LABEL: lea_global_fn:
; LARGE-PIC: # %bb.0:
; LARGE-PIC-NEXT: .L15$pb:
; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx
; LARGE-PIC-NEXT: .L14$pb:
; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $global_fn@GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
Expand Down Expand Up @@ -853,9 +841,9 @@ define dso_local ptr @lea_extern_fn() #0 {
;
; LARGE-PIC-LABEL: lea_extern_fn:
; LARGE-PIC: # %bb.0:
; LARGE-PIC-NEXT: .L16$pb:
; LARGE-PIC-NEXT: leaq .L16$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L16$pb, %rcx
; LARGE-PIC-NEXT: .L15$pb:
; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $extern_fn@GOT, %rax
; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax
Expand All @@ -873,112 +861,6 @@ define dso_local ptr @lea_extern_fn() #0 {
ret ptr @extern_fn
}

define dso_local ptr @lea_ifunc() #0 {
; SMALL-STATIC-LABEL: lea_ifunc:
; SMALL-STATIC: # %bb.0:
; SMALL-STATIC-NEXT: movq ifunc_func@GOTPCREL(%rip), %rax
; SMALL-STATIC-NEXT: retq
;
; MEDIUM-STATIC-LABEL: lea_ifunc:
; MEDIUM-STATIC: # %bb.0:
; MEDIUM-STATIC-NEXT: movq ifunc_func@GOTPCREL(%rip), %rax
; MEDIUM-STATIC-NEXT: retq
;
; LARGE-STATIC-LABEL: lea_ifunc:
; LARGE-STATIC: # %bb.0:
; LARGE-STATIC-NEXT: movabsq $ifunc_func, %rax
; LARGE-STATIC-NEXT: retq
;
; SMALL-PIC-LABEL: lea_ifunc:
; SMALL-PIC: # %bb.0:
; SMALL-PIC-NEXT: movq ifunc_func@GOTPCREL(%rip), %rax
; SMALL-PIC-NEXT: retq
;
; MEDIUM-SMALL-DATA-PIC-LABEL: lea_ifunc:
; MEDIUM-SMALL-DATA-PIC: # %bb.0:
; MEDIUM-SMALL-DATA-PIC-NEXT: movq ifunc_func@GOTPCREL(%rip), %rax
; MEDIUM-SMALL-DATA-PIC-NEXT: retq
;
; MEDIUM-PIC-LABEL: lea_ifunc:
; MEDIUM-PIC: # %bb.0:
; MEDIUM-PIC-NEXT: movq ifunc_func@GOTPCREL(%rip), %rax
; MEDIUM-PIC-NEXT: retq
;
; LARGE-PIC-LABEL: lea_ifunc:
; LARGE-PIC: # %bb.0:
; LARGE-PIC-NEXT: .L17$pb:
; LARGE-PIC-NEXT: leaq .L17$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L17$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $ifunc_func@GOT, %rax
; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax
; LARGE-PIC-NEXT: retq
;
; LARGE-SMALL-DATA-PIC-LABEL: lea_ifunc:
; LARGE-SMALL-DATA-PIC: # %bb.0:
; LARGE-SMALL-DATA-PIC-NEXT: .L18$pb:
; LARGE-SMALL-DATA-PIC-NEXT: leaq .L18$pb(%rip), %rax
; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L18$pb, %rcx
; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
; LARGE-SMALL-DATA-PIC-NEXT: movabsq $ifunc_func@GOT, %rax
; LARGE-SMALL-DATA-PIC-NEXT: movq (%rcx,%rax), %rax
; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @ifunc_func
}

define dso_local ptr @lea_dso_local_ifunc() #0 {
; SMALL-STATIC-LABEL: lea_dso_local_ifunc:
; SMALL-STATIC: # %bb.0:
; SMALL-STATIC-NEXT: movl $dso_local_ifunc_func, %eax
; SMALL-STATIC-NEXT: retq
;
; MEDIUM-STATIC-LABEL: lea_dso_local_ifunc:
; MEDIUM-STATIC: # %bb.0:
; MEDIUM-STATIC-NEXT: movabsq $dso_local_ifunc_func, %rax
; MEDIUM-STATIC-NEXT: retq
;
; LARGE-STATIC-LABEL: lea_dso_local_ifunc:
; LARGE-STATIC: # %bb.0:
; LARGE-STATIC-NEXT: movabsq $dso_local_ifunc_func, %rax
; LARGE-STATIC-NEXT: retq
;
; SMALL-PIC-LABEL: lea_dso_local_ifunc:
; SMALL-PIC: # %bb.0:
; SMALL-PIC-NEXT: leaq dso_local_ifunc_func(%rip), %rax
; SMALL-PIC-NEXT: retq
;
; MEDIUM-SMALL-DATA-PIC-LABEL: lea_dso_local_ifunc:
; MEDIUM-SMALL-DATA-PIC: # %bb.0:
; MEDIUM-SMALL-DATA-PIC-NEXT: leaq dso_local_ifunc_func(%rip), %rax
; MEDIUM-SMALL-DATA-PIC-NEXT: retq
;
; MEDIUM-PIC-LABEL: lea_dso_local_ifunc:
; MEDIUM-PIC: # %bb.0:
; MEDIUM-PIC-NEXT: leaq dso_local_ifunc_func(%rip), %rax
; MEDIUM-PIC-NEXT: retq
;
; LARGE-PIC-LABEL: lea_dso_local_ifunc:
; LARGE-PIC: # %bb.0:
; LARGE-PIC-NEXT: .L18$pb:
; LARGE-PIC-NEXT: leaq .L18$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L18$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq $dso_local_ifunc_func@GOTOFF, %rax
; LARGE-PIC-NEXT: addq %rcx, %rax
; LARGE-PIC-NEXT: retq
;
; LARGE-SMALL-DATA-PIC-LABEL: lea_dso_local_ifunc:
; LARGE-SMALL-DATA-PIC: # %bb.0:
; LARGE-SMALL-DATA-PIC-NEXT: .L19$pb:
; LARGE-SMALL-DATA-PIC-NEXT: leaq .L19$pb(%rip), %rax
; LARGE-SMALL-DATA-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L19$pb, %rcx
; LARGE-SMALL-DATA-PIC-NEXT: addq %rax, %rcx
; LARGE-SMALL-DATA-PIC-NEXT: movabsq $dso_local_ifunc_func@GOTOFF, %rax
; LARGE-SMALL-DATA-PIC-NEXT: addq %rcx, %rax
; LARGE-SMALL-DATA-PIC-NEXT: retq
ret ptr @dso_local_ifunc_func
}

; FIXME: The result is same for small, medium and large model, because we
; specify pie option in the test case. And the type of tls is initial exec tls.
; For pic code. The large model code for pic tls should be emitted as below.
Expand Down Expand Up @@ -1047,9 +929,9 @@ define dso_local float @load_constant_pool(float %x) #0 {
;
; LARGE-PIC-LABEL: load_constant_pool:
; LARGE-PIC: # %bb.0:
; LARGE-PIC-NEXT: .L20$pb:
; LARGE-PIC-NEXT: leaq .L20$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L20$pb, %rcx
; LARGE-PIC-NEXT: .L17$pb:
; LARGE-PIC-NEXT: leaq .L17$pb(%rip), %rax
; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L17$pb, %rcx
; LARGE-PIC-NEXT: addq %rax, %rcx
; LARGE-PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
; LARGE-PIC-NEXT: addss (%rcx,%rax), %xmm0
Expand Down

0 comments on commit c27b24f

Please sign in to comment.