forked from OSchip/llvm-project
[AlwaysInliner] Invalidate analyses when we delete functions
Fixes PR52292. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D112473
This commit is contained in:
parent
882df21a1b
commit
4a9db7367d
|
@ -108,8 +108,10 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
|
||||||
// Delete the non-comdat ones from the module and also from our vector.
|
// Delete the non-comdat ones from the module and also from our vector.
|
||||||
auto NonComdatBegin = partition(
|
auto NonComdatBegin = partition(
|
||||||
InlinedFunctions, [&](Function *F) { return F->hasComdat(); });
|
InlinedFunctions, [&](Function *F) { return F->hasComdat(); });
|
||||||
for (Function *F : make_range(NonComdatBegin, InlinedFunctions.end()))
|
for (Function *F : make_range(NonComdatBegin, InlinedFunctions.end())) {
|
||||||
M.getFunctionList().erase(F);
|
M.getFunctionList().erase(F);
|
||||||
|
Changed = true;
|
||||||
|
}
|
||||||
InlinedFunctions.erase(NonComdatBegin, InlinedFunctions.end());
|
InlinedFunctions.erase(NonComdatBegin, InlinedFunctions.end());
|
||||||
|
|
||||||
if (!InlinedFunctions.empty()) {
|
if (!InlinedFunctions.empty()) {
|
||||||
|
@ -117,8 +119,10 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
|
||||||
// are not actually dead.
|
// are not actually dead.
|
||||||
filterDeadComdatFunctions(M, InlinedFunctions);
|
filterDeadComdatFunctions(M, InlinedFunctions);
|
||||||
// The remaining functions are actually dead.
|
// The remaining functions are actually dead.
|
||||||
for (Function *F : InlinedFunctions)
|
for (Function *F : InlinedFunctions) {
|
||||||
M.getFunctionList().erase(F);
|
M.getFunctionList().erase(F);
|
||||||
|
Changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
|
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
; RUN: opt -passes='require<no-op-module>,always-inline' -disable-output < %s 2>&1 -debug-pass-manager | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: Invalidating {{.*}} NoOpModuleAnalysis
|
||||||
|
; CHECK-NOT: @f
|
||||||
|
|
||||||
|
define internal void @f() alwaysinline {
|
||||||
|
unreachable
|
||||||
|
}
|
Loading…
Reference in New Issue