Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -4549,7 +4606,7 @@ bool isLocalCall(const SDValue &Callee) { if (GlobalAddressSDNode *G = dyn_cast(Callee)) - return G->getGlobal()->isStrongDefinitionForLinker(); + return G->getGlobal()->hasLocalLinkage(); return false; } @@ -4677,9 +4734,7 @@ // The address needs to go after the chain input but before the flag (or // any other variadic arguments). Ops.insert(std::next(Ops.begin()), AddTOC); - } else if ((CallOpc == PPCISD::CALL) && - (!isLocalCall(Callee) || - DAG.getTarget().getRelocationModel() == Reloc::PIC_)) + } else if (CallOpc == PPCISD::CALL && !isLocalCall(Callee)) // Otherwise insert NOP for non-local calls. CallOpc = PPCISD::CALL_NOP; } Index: test/CodeGen/PowerPC/call-nop.ll =================================================================== --- test/CodeGen/PowerPC/call-nop.ll +++ test/CodeGen/PowerPC/call-nop.ll @@ -0,0 +1,27 @@ +; RUN: llc -O2 < %s | FileCheck %s + +target datalayout = "E-m:e-i64:64-n32:64" +target triple = "powerpc64--linux" + +@f.x = internal global i32 0, align 4 + +; Function Attrs: noinline nounwind +define signext i32 @f() noinline { + %1 = load volatile i32, i32* @f.x, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define signext i32 @g() { + %1 = call signext i32 @f() + %2 = call signext i32 @f() + %3 = add nsw i32 %1, %2 + ret i32 %3 +} + +; CHECK-LABEL: @g +; CHECK: bl f +; CHECK-NEXT: nop +; CHECK: bl f +; CHECK-NEXT: nop +