[PATCH] D129841: [GlobalOpt] Enable evaluation of atomic stores
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 15 02:09:10 PDT 2022
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: aeubanks, rnk, nikic.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a subscriber: hiraditya.
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129841
Files:
llvm/lib/Transforms/Utils/Evaluator.cpp
llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
Index: llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
+++ 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 @CTOR12() {
ret void
}
+
+; CHECK-NOT CTOR13
+define internal void @CTOR13() {
+ store atomic i32 123, i32* @GA seq_cst, align 4
+ ret void
+}
Index: llvm/lib/Transforms/Utils/Evaluator.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Evaluator.cpp
+++ llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -301,9 +301,9 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129841.444918.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220715/c53a89d7/attachment.bin>
More information about the llvm-commits
mailing list