[llvm] 2bcc4db - [EarlyCSE] Explicitly require AAResultsWrapperPass.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 01:15:17 PDT 2020
Author: Florian Hahn
Date: 2020-09-09T09:14:50+01:00
New Revision: 2bcc4db761768f1b7431237920f26360549ca268
URL: https://github.com/llvm/llvm-project/commit/2bcc4db761768f1b7431237920f26360549ca268
DIFF: https://github.com/llvm/llvm-project/commit/2bcc4db761768f1b7431237920f26360549ca268.diff
LOG: [EarlyCSE] Explicitly require AAResultsWrapperPass.
The MemorySSAWrapperPass depends on AAResultsWrapperPass and if
MemorySSA is preserved but AAResultsWrapperPass is not, this could lead
to a crash when updating the last user of the MemorySSAWrapperPass.
Alternatively AAResultsWrapperPass could be marked preserved by GVN, but
I am not sure if that would be safe. I am not sure what is required in
order to preserve AAResultsWrapperPass. At the moment, it seems like a
couple of passes that do similar transforms to GVN are preserving it.
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D87137
Added:
llvm/test/Transforms/EarlyCSE/reuse-preserved-memoryssa.ll
Modified:
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/lib/Transforms/Scalar/GVN.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 51da10fc4879..b655204d26dd 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -1463,6 +1463,7 @@ class EarlyCSELegacyCommonPass : public FunctionPass {
AU.addRequired<TargetLibraryInfoWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
if (UseMemorySSA) {
+ AU.addRequired<AAResultsWrapperPass>();
AU.addRequired<MemorySSAWrapperPass>();
AU.addPreserved<MemorySSAWrapperPass>();
}
@@ -1504,6 +1505,7 @@ INITIALIZE_PASS_BEGIN(EarlyCSEMemSSALegacyPass, "early-cse-memssa",
"Early CSE w/ MemorySSA", false, false)
INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
+INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass)
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index c71038d66f99..036ca1d1054f 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2850,7 +2850,6 @@ class llvm::gvn::GVNLegacyPass : public FunctionPass {
if (Impl.isMemDepEnabled())
AU.addRequired<MemoryDependenceWrapperPass>();
AU.addRequired<AAResultsWrapperPass>();
-
AU.addPreserved<DominatorTreeWrapperPass>();
AU.addPreserved<GlobalsAAWrapperPass>();
AU.addPreserved<TargetLibraryInfoWrapperPass>();
diff --git a/llvm/test/Transforms/EarlyCSE/reuse-preserved-memoryssa.ll b/llvm/test/Transforms/EarlyCSE/reuse-preserved-memoryssa.ll
new file mode 100644
index 000000000000..744389c24db2
--- /dev/null
+++ b/llvm/test/Transforms/EarlyCSE/reuse-preserved-memoryssa.ll
@@ -0,0 +1,7 @@
+; RUN: opt -memoryssa -gvn -early-cse-memssa %s -S | FileCheck %s
+
+; CHECK: define void @foo(
+
+define void @foo() {
+ ret void
+}
More information about the llvm-commits
mailing list