[PATCH] D129841: [GlobalOpt] Enable evaluation of atomic stores

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 15:34:39 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67f1fe859781: [GlobalOpt] Enable evaluation of atomic stores (authored by alexander-shaposhnikov).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129841/new/

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.446282.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220720/2326387c/attachment.bin>


More information about the llvm-commits mailing list