[llvm] 67f1fe8 - [GlobalOpt] Enable evaluation of atomic stores
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 15:34:30 PDT 2022
Author: Alexander Shaposhnikov
Date: 2022-07-20T22:33:58Z
New Revision: 67f1fe8597817f9630c84d77ca23852e362e62d6
URL: https://github.com/llvm/llvm-project/commit/67f1fe8597817f9630c84d77ca23852e362e62d6
DIFF: https://github.com/llvm/llvm-project/commit/67f1fe8597817f9630c84d77ca23852e362e62d6.diff
LOG: [GlobalOpt] Enable evaluation of atomic stores
Relax the check to allow evaluation of atomic stores
(but still skip volatile stores).
Test plan:
1/ ninja check-llvm check-clang
2/ Bootstrapped LLVM/Clang pass tests
Differential revision: https://reviews.llvm.org/D129841
Added:
Modified:
llvm/lib/Transforms/Utils/Evaluator.cpp
llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp
index 7b8d8553bac22..3989fbc0da661 100644
--- a/llvm/lib/Transforms/Utils/Evaluator.cpp
+++ b/llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -301,9 +301,9 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
LLVM_DEBUG(dbgs() << "Evaluating Instruction: " << *CurInst << "\n");
if (StoreInst *SI = dyn_cast<StoreInst>(CurInst)) {
- if (!SI->isSimple()) {
- LLVM_DEBUG(dbgs() << "Store is not simple! Can not evaluate.\n");
- return false; // no volatile/atomic accesses.
+ if (SI->isVolatile()) {
+ LLVM_DEBUG(dbgs() << "Store is volatile! Can not evaluate.\n");
+ return false; // no volatile accesses.
}
Constant *Ptr = getVal(SI->getOperand(1));
Constant *FoldedPtr = ConstantFoldConstant(Ptr, DL, TLI);
diff --git a/llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll b/llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
index d0399416c434f..d351be182cebb 100644
--- a/llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
@@ -27,6 +27,7 @@
@Z = global i32 123 ; <i32*> [#uses=1]
@D = global double 0.000000e+00 ; <double*> [#uses=1]
@CTORGV = internal global i1 false ; <i1*> [#uses=2]
+ at GA = global i32 0 ; <i32*> [#uses=1]
define internal void @CTOR1() {
ret void
@@ -130,3 +131,9 @@ define internal void @CTOR11() {
define internal void @CTOR12() {
ret void
}
+
+; CHECK-NOT: CTOR13
+define internal void @CTOR13() {
+ store atomic i32 123, i32* @GA seq_cst, align 4
+ ret void
+}
More information about the llvm-commits
mailing list