[PATCH] D99977: [GVN] Clear ICF cache when we simplify a value
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 23:43:05 PDT 2021
aeubanks updated this revision to Diff 336014.
aeubanks added a comment.
actually make the test do something
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99977/new/
https://reviews.llvm.org/D99977
Files:
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/test/Transforms/GVN/simplify-icf-cache-invalidation.ll
Index: llvm/test/Transforms/GVN/simplify-icf-cache-invalidation.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/GVN/simplify-icf-cache-invalidation.ll
@@ -0,0 +1,50 @@
+; RUN: opt -passes=gvn -S < %s | FileCheck %s
+
+; CHECK: define {{.*}}@eggs
+
+%struct.zot = type { i32 (...)** }
+%struct.wombat = type { i8* }
+%struct.baz = type { i8, i8* }
+
+ at global = hidden unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* undef, i8* bitcast (void (%struct.zot*, i1)* @quux to i8*)] }, align 8
+
+define hidden void @eggs(%struct.zot* %arg) unnamed_addr align 2 {
+bb:
+ %tmp = alloca %struct.wombat, align 8
+ %tmp1 = getelementptr %struct.zot, %struct.zot* %arg, i64 0, i32 0
+ store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @global, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %tmp1, align 8, !invariant.group !0
+ br i1 undef, label %bb4, label %bb2
+
+bb2: ; preds = %bb
+ %tmp3 = atomicrmw sub i32* undef, i32 undef acq_rel, align 4
+ br label %bb4
+
+bb4: ; preds = %bb2, %bb
+ %tmp5 = load %struct.baz*, %struct.baz** null, align 8
+ %tmp6 = getelementptr inbounds %struct.baz, %struct.baz* %tmp5, i64 0, i32 1
+ br i1 undef, label %bb9, label %bb7
+
+bb7: ; preds = %bb4
+ %tmp8 = tail call i8* undef()
+ br label %bb9
+
+bb9: ; preds = %bb7, %bb4
+ %tmp10 = load %struct.baz*, %struct.baz** null, align 8
+ %tmp11 = getelementptr inbounds %struct.baz, %struct.baz* %tmp10, i64 0, i32 0
+ %tmp12 = bitcast %struct.zot* %arg to void (%struct.zot*, i1)***
+ %tmp13 = load void (%struct.zot*, i1)**, void (%struct.zot*, i1)*** %tmp12, align 8, !invariant.group !0
+ %tmp14 = getelementptr inbounds void (%struct.zot*, i1)*, void (%struct.zot*, i1)** %tmp13, i64 1
+ %tmp15 = load void (%struct.zot*, i1)*, void (%struct.zot*, i1)** %tmp14, align 8
+ tail call void %tmp15(%struct.zot* %arg, i1 undef)
+ %tmp16 = getelementptr inbounds %struct.wombat, %struct.wombat* %tmp, i64 0, i32 0
+ %tmp17 = load i8*, i8** %tmp16, align 8
+ %tmp18 = icmp eq i8* %tmp17, null
+ ret void
+}
+
+; Function Attrs: nounwind willreturn
+declare hidden void @quux(%struct.zot*, i1) unnamed_addr #0 align 2
+
+attributes #0 = { nounwind willreturn }
+
+!0 = !{}
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2169,6 +2169,9 @@
bool Changed = false;
if (!I->use_empty()) {
I->replaceAllUsesWith(V);
+ // Simplification can cause a special instruction to become not special.
+ // For example, devirtualization to a willreturn function.
+ ICF->clear();
Changed = true;
}
if (isInstructionTriviallyDead(I, TLI)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99977.336014.patch
Type: text/x-patch
Size: 3026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/5836ff6e/attachment.bin>
More information about the llvm-commits
mailing list