[llvm] r305052 - Inliner: Don't touch indirect calls
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 20:29:20 PDT 2017
Author: dblaikie
Date: Thu Jun 8 22:29:20 2017
New Revision: 305052
URL: http://llvm.org/viewvc/llvm-project?rev=305052&view=rev
Log:
Inliner: Don't touch indirect calls
Other comments/implications are that this isn't intended behavior (nor
perserved/reimplemented in the new inliner) & complicates fixing the
'inlining' of trivially dead calls without consulting the cost function
first.
Modified:
llvm/trunk/lib/Transforms/IPO/Inliner.cpp
llvm/trunk/test/Transforms/Inline/basictest.ll
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=305052&r1=305051&r2=305052&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Jun 8 22:29:20 2017
@@ -519,6 +519,10 @@ inlineCallsImpl(CallGraphSCC &SCC, CallG
Function *Caller = CS.getCaller();
Function *Callee = CS.getCalledFunction();
+ // We can only inline direct calls to non-declarations.
+ if (!Callee || Callee->isDeclaration())
+ continue;
+
// If this call site is dead and it is to a readonly function, we should
// just delete the call instead of trying to inline it, regardless of
// size. This happens because IPSCCP propagates the result out of the
@@ -531,10 +535,6 @@ inlineCallsImpl(CallGraphSCC &SCC, CallG
CS.getInstruction()->eraseFromParent();
++NumCallsDeleted;
} else {
- // We can only inline direct calls to non-declarations.
- if (!Callee || Callee->isDeclaration())
- continue;
-
// If this call site was obtained by inlining another function, verify
// that the include path for the function did not include the callee
// itself. If so, we'd be recursively inlining the same function,
Modified: llvm/trunk/test/Transforms/Inline/basictest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/basictest.ll?rev=305052&r1=305051&r2=305052&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/basictest.ll (original)
+++ llvm/trunk/test/Transforms/Inline/basictest.ll Thu Jun 8 22:29:20 2017
@@ -91,3 +91,27 @@ define i32 @test() {
ret i32 %e
; CHECK: }
}
+
+; Inliner shouldn't delete calls it can't inline, even if they're trivially dead
+; CHECK-LABEL: @outer4(
+define void @outer4(void ()* %inner4) {
+entry:
+; CHECK: call void %inner4()
+ call void %inner4() nounwind readnone
+ ret void
+}
+
+declare void @inner5_inner()
+
+define void @inner5(void ()* %x) {
+ call void %x() nounwind readnone
+ ret void
+}
+
+; Inliner shouldn't delete calls it can't inline, even if they're trivially dead and temporarily indirect
+; CHECK-LABEL: @outer5(
+define void @outer5() {
+; CHECK: call void @inner5_inner(
+ call void @inner5(void ()* @inner5_inner)
+ ret void
+}
More information about the llvm-commits
mailing list