[PATCH] D130211: [GlobalOpt] Enable evaluation of atomic loads
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 14:38: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 rGe9afdf838eb9: [GlobalOpt] Enable evaluation of atomic loads (authored by alexander-shaposhnikov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130211/new/
https://reviews.llvm.org/D130211
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
@@ -1,7 +1,7 @@
; RUN: opt < %s -passes=globalopt -S | FileCheck %s
; CHECK-NOT: CTOR
%ini = type { i32, void()*, i8* }
- at llvm.global_ctors = appending global [15 x %ini] [
+ at llvm.global_ctors = appending global [16 x %ini] [
%ini { i32 65534, void ()* @CTOR1, i8* null },
%ini { i32 65535, void ()* @CTOR1, i8* null },
%ini { i32 65535, void ()* @CTOR1, i8* null },
@@ -13,6 +13,7 @@
%ini { i32 65535, void ()* @CTOR7, i8* null },
%ini { i32 65535, void ()* @CTOR8, i8* null },
%ini { i32 65535, void ()* @CTOR9, i8* null },
+ %ini { i32 65535, void ()* @CTOR14,i8* null },
%ini { i32 65536, void ()* @CTOR10_EXTERNAL, i8* null },
%ini { i32 65536, void ()* @CTOR11, i8* null },
%ini { i32 65537, void ()* @CTOR12, i8* null },
@@ -28,6 +29,7 @@
@D = global double 0.000000e+00 ; <double*> [#uses=1]
@CTORGV = internal global i1 false ; <i1*> [#uses=2]
@GA = global i32 0 ; <i32*> [#uses=1]
+ at GA14 = global i32 0 ; <i32*> [#uses=1]
define internal void @CTOR1() {
ret void
@@ -137,3 +139,12 @@
store atomic i32 123, i32* @GA seq_cst, align 4
ret void
}
+
+; CHECK-NOT: CTOR14
+define internal void @CTOR14() {
+ %X = load atomic i32, i32* @GA14 seq_cst, align 4
+ %Y = add i32 %X, 124
+ store i32 %Y, i32* @GA14
+ ret void
+}
+
Index: llvm/lib/Transforms/Utils/Evaluator.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Evaluator.cpp
+++ llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -337,10 +337,10 @@
if (!Res.first->second.write(Val, Offset, DL))
return false;
} else if (LoadInst *LI = dyn_cast<LoadInst>(CurInst)) {
- if (!LI->isSimple()) {
+ if (LI->isVolatile()) {
LLVM_DEBUG(
- dbgs() << "Found a Load! Not a simple load, can not evaluate.\n");
- return false; // no volatile/atomic accesses.
+ dbgs() << "Found a Load! Volatile load, can not evaluate.\n");
+ return false; // no volatile accesses.
}
Constant *Ptr = getVal(LI->getOperand(0));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130211.446637.patch
Type: text/x-patch
Size: 2267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220721/882bbf61/attachment-0001.bin>
More information about the llvm-commits
mailing list