[llvm] r297940 - [PM/Inliner] Fix a bug in r297374 where we would leave stale calls in
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 03:45:42 PDT 2017
Author: chandlerc
Date: Thu Mar 16 05:45:42 2017
New Revision: 297940
URL: http://llvm.org/viewvc/llvm-project?rev=297940&view=rev
Log:
[PM/Inliner] Fix a bug in r297374 where we would leave stale calls in
the work queue and crash when trying to visit them after deleting the
function containing those calls.
Added:
llvm/trunk/test/Transforms/Inline/internal-scc-members.ll
Modified:
llvm/trunk/lib/Transforms/IPO/Inliner.cpp
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=297940&r1=297939&r2=297940&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Mar 16 05:45:42 2017
@@ -903,6 +903,12 @@ PreservedAnalyses InlinerPass::run(LazyC
// made dead by this operation on other functions).
Callee.removeDeadConstantUsers();
if (Callee.use_empty()) {
+ Calls.erase(
+ std::remove_if(Calls.begin() + i + 1, Calls.end(),
+ [&Callee](const std::pair<CallSite, int> &Call) {
+ return Call.first.getCaller() == &Callee;
+ }),
+ Calls.end());
// Clear the body and queue the function itself for deletion when we
// finish inlining and call graph updates.
// Note that after this point, it is an error to do anything other
Added: llvm/trunk/test/Transforms/Inline/internal-scc-members.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/internal-scc-members.ll?rev=297940&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Inline/internal-scc-members.ll (added)
+++ llvm/trunk/test/Transforms/Inline/internal-scc-members.ll Thu Mar 16 05:45:42 2017
@@ -0,0 +1,31 @@
+; Test that the inliner can handle deleting functions within an SCC while still
+; processing the calls in that SCC.
+;
+; RUN: opt < %s -S -inline | FileCheck %s
+; RUN: opt < %s -S -passes=inline | FileCheck %s
+
+; CHECK-LABEL: define internal void @test1_scc0()
+; CHECK-NOT: call
+; CHECK: call void @test1_scc0()
+; CHECK-NOT: call
+; CHECK: ret
+define internal void @test1_scc0() {
+entry:
+ call void @test1_scc1()
+ ret void
+}
+
+; CHECK-NOT: @test1_scc1
+define internal void @test1_scc1() {
+entry:
+ call void @test1_scc0()
+ ret void
+}
+
+; CHECK-LABEL: define void @test1()
+; CHECK: call void @test1_scc0()
+define void @test1() {
+entry:
+ call void @test1_scc0() noinline
+ ret void
+}
More information about the llvm-commits
mailing list