[PATCH] D26290: Only consider local functions local for the purpose of NOP eliminate after calls on PPC64
Joerg Sonnenberger via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 15:08:01 PDT 2016
joerg created this revision.
joerg added reviewers: wschmidt, hfinkel.
joerg added a subscriber: llvm-commits.
joerg set the repository for this revision to rL LLVM.
Herald added a subscriber: nemanjai.
As shown in https://llvm.org/bugs/show_bug.cgi?id=30868 the current assumption that ld will use local calls for global symbols is incorrect. For the nop elimination, we must use the much stricter ELF local symbol definition. At least GNU ld does assume that the call is otherwise interposable.
Repository:
rL LLVM
https://reviews.llvm.org/D26290
Files:
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/call-nop.ll
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"
+
+ at 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
+
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<GlobalAddressSDNode>(Callee))
- return G->getGlobal()->isStrongDefinitionForLinker();
+ return G->getGlobal()->hasLocalLinkage();
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26290.76892.patch
Type: text/x-patch
Size: 1222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161103/fd82229c/attachment.bin>
More information about the llvm-commits
mailing list