diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -606,7 +606,9 @@ } } - 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 --- a/llvm/test/CodeGen/ARM/fast-isel-intrinsic.ll +++ b/llvm/test/CodeGen/ARM/fast-isel-intrinsic.ll @@ -61,8 +61,8 @@ ; 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 @@ ; 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