forked from OSchip/llvm-project
[NewGVN] Mark function as changed if we erase instructions.
Currently eliminateInstructions only returns true if any instruction got replaced. In the test case for this patch, we eliminate the trivially dead calls, for which eliminateInstructions not do a replacement and the function is not marked as changed, which is why the inliner crashes while traversing the call graph. Alternatively we could also change eliminateInstructions to return true in case we mark instructions for deletion, but that's slightly more code and doing it at the place where the replacement happens seems safer. Fixes PR37517. Reviewers: davide, mcrosier, efriedma, bjope Reviewed By: bjope Differential Revision: https://reviews.llvm.org/D51169 llvm-svn: 341651
This commit is contained in:
parent
a2aef22a72
commit
b30f7aeeeb
|
@ -3497,9 +3497,11 @@ bool NewGVN::runGVN() {
|
|||
if (!ToErase->use_empty())
|
||||
ToErase->replaceAllUsesWith(UndefValue::get(ToErase->getType()));
|
||||
|
||||
if (ToErase->getParent())
|
||||
ToErase->eraseFromParent();
|
||||
assert(ToErase->getParent() &&
|
||||
"BB containing ToErase deleted unexpectedly!");
|
||||
ToErase->eraseFromParent();
|
||||
}
|
||||
Changed |= !InstructionsToErase.empty();
|
||||
|
||||
// Delete all unreachable blocks.
|
||||
auto UnreachableBlockPred = [&](const BasicBlock &BB) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
; RUN: opt -inline -newgvn -S < %s | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: @f2()
|
||||
; CHECK-NEXT: ret void
|
||||
; CHECK-NOT: @f1
|
||||
|
||||
define void @f2() {
|
||||
call void @f1()
|
||||
call void @f1()
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @f1() #1 {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #1 = { noinline nounwind readnone }
|
Loading…
Reference in New Issue