From 69ae441e4ce7422d9514dc5778d2caeeab64b1b0 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Mon, 27 Jun 2022 13:59:35 +0100 Subject: [PATCH] ARM: don't try to load function pointer before long call. 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. --- llvm/lib/Target/ARM/ARMFastISel.cpp | 3 +-- llvm/test/CodeGen/ARM/fast-isel-call.ll | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp index f42b2a911cbf4..a167225e27430 100644 --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -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) diff --git a/llvm/test/CodeGen/ARM/fast-isel-call.ll b/llvm/test/CodeGen/ARM/fast-isel-call.ll index d1e5ebc30c254..1c4ef0d7b1c4f 100644 --- a/llvm/test/CodeGen/ARM/fast-isel-call.ll +++ b/llvm/test/CodeGen/ARM/fast-isel-call.ll @@ -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 @@ -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