Skip to content

Commit

Permalink
ARM: don't try to load function pointer before long call.
Browse files Browse the repository at this point in the history
Deciding to load an arbitrary global based on whether the entire module is
being built for long calls is pretty clearly spurious, and in fact the existing
indirect logic is sufficient.
  • Loading branch information
TNorthover committed Jun 27, 2022
1 parent cfb4c1a commit 69ae441
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Target/ARM/ARMFastISel.cpp
Expand Up @@ -601,8 +601,7 @@ unsigned ARMFastISel::ARMMaterializeGV(const GlobalValue *GV, MVT VT) {
}

if ((Subtarget->isTargetELF() && Subtarget->isGVInGOT(GV)) ||
(Subtarget->isTargetMachO() && IsIndirect) ||
Subtarget->genLongCalls()) {
(Subtarget->isTargetMachO() && IsIndirect)) {
MachineInstrBuilder MIB;
Register NewDestReg = createResultReg(TLI.getRegClassFor(VT));
if (isThumb2)
Expand Down
11 changes: 8 additions & 3 deletions llvm/test/CodeGen/ARM/fast-isel-call.ll
Expand Up @@ -2,6 +2,7 @@
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi | FileCheck %s --check-prefix=ARM
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios | FileCheck %s --check-prefix=THUMB
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -mattr=+long-calls | FileCheck %s --check-prefix=ARM-LONG --check-prefix=ARM-LONG-MACHO
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=static -mtriple=armv7-apple-ios -mattr=+long-calls | FileCheck %s --check-prefix=ARM-LONG --check-prefix=ARM-LONG-MACHO-STATIC
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -mattr=+long-calls | FileCheck %s --check-prefix=ARM-LONG --check-prefix=ARM-LONG-ELF
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -mattr=+long-calls | FileCheck %s --check-prefix=THUMB-LONG
; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -mattr=-fpregs | FileCheck %s --check-prefix=ARM-NOVFP
Expand Down Expand Up @@ -109,9 +110,13 @@ entry:
; ARM-LONG-MACHO: {{(movt [[R1]], :upper16:L_bar\$non_lazy_ptr)?}}
; ARM-LONG-MACHO: ldr [[R:r[0-9]+]], [[[R1]]]

; ARM-LONG-ELF: movw [[R1:r[0-9]*]], :lower16:bar
; ARM-LONG-ELF: movt [[R1]], :upper16:bar
; ARM-LONG-ELF: ldr [[R:r[0-9]+]], [[[R1]]]
; ARM-LONG-MACHO-STATIC: movw [[R:.*]], :lower16:_bar
; ARM-LONG-MACHO-STATIC: movt [[R]], :upper16:_bar
; ARM-LONG-MACHO-STATIC-NOT: ldr{{.*}}[[R]]

; ARM-LONG-ELF: movw [[R:r[0-9]*]], :lower16:bar
; ARM-LONG-ELF: movt [[R]], :upper16:bar
; ARM-LONG-ELF-NOT: ldr{{.*}}[[R]]

; ARM-LONG: blx [[R]]
; THUMB-LABEL: @t10
Expand Down

0 comments on commit 69ae441

Please sign in to comment.