[PATCH] D51169: [NewGVN] Mark function as changed if we erase instructions.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 6 07:49:08 PDT 2018
fhahn updated this revision to Diff 164217.
https://reviews.llvm.org/D51169
Files:
lib/Transforms/Scalar/NewGVN.cpp
test/Transforms/NewGVN/eliminate-callsite-inline.ll
Index: test/Transforms/NewGVN/eliminate-callsite-inline.ll
===================================================================
--- /dev/null
+++ test/Transforms/NewGVN/eliminate-callsite-inline.ll
@@ -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 }
Index: lib/Transforms/Scalar/NewGVN.cpp
===================================================================
--- lib/Transforms/Scalar/NewGVN.cpp
+++ lib/Transforms/Scalar/NewGVN.cpp
@@ -3497,9 +3497,11 @@
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51169.164217.patch
Type: text/x-patch
Size: 1171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180906/e9423823/attachment.bin>
More information about the llvm-commits
mailing list