diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp index 3a7c2eed2249..da1d9af8d5b5 100644 --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -606,7 +606,9 @@ unsigned ARMFastISel::ARMMaterializeGV(const GlobalValue *GV, MVT VT) { } } - if (IsIndirect) { + if ((Subtarget->isTargetELF() && Subtarget->isGVInGOT(GV)) || + (Subtarget->isTargetMachO() && IsIndirect) || + Subtarget->genLongCalls()) { MachineInstrBuilder MIB; unsigned NewDestReg = createResultReg(TLI.getRegClassFor(VT)); if (isThumb2) diff --git a/llvm/test/CodeGen/ARM/fast-isel-intrinsic.ll b/llvm/test/CodeGen/ARM/fast-isel-intrinsic.ll index ee6f57307686..4ad74df771b3 100644 --- a/llvm/test/CodeGen/ARM/fast-isel-intrinsic.ll +++ b/llvm/test/CodeGen/ARM/fast-isel-intrinsic.ll @@ -61,8 +61,8 @@ define void @t2() nounwind ssp { ; ARM-ELF: movw [[REG1:r[0-9]+]], :lower16:temp ; ARM-ELF: movt [[REG1]], :upper16:temp -; ARM-ELF: add [[REG1]], r1, #4 -; ARM-ELF-NEXT: add r1, r1, #16 +; ARM-ELF: add r0, [[REG1]], #4 +; ARM-ELF-NEXT: add r1, [[REG1]], #16 ; ARM: movw r2, #17 ; ARM: bl {{_?}}memcpy @@ -106,7 +106,7 @@ define void @t3() nounwind ssp { ; ARM-ELF: movw [[REG0:r[0-9]+]], :lower16:temp ; ARM-ELF: movt [[REG0]], :upper16:temp -; ARM-ELF: add [[REG0]], r1, #4 +; ARM-ELF: add r0, [[REG0]], #4 ; ARM-ELF-NEXT: add r1, r1, #16 ; ARM: movw r2, #10