[llvm] [Mem2Reg] Don't use single store optimization for potentially poison value (PR #97711)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 04:13:21 PDT 2024


================
@@ -525,7 +525,14 @@ rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info, LargeBlockInfo &LBI,
                          SmallSet<DbgAssignIntrinsic *, 8> *DbgAssignsToDelete,
                          SmallSet<DbgVariableRecord *, 8> *DVRAssignsToDelete) {
   StoreInst *OnlyStore = Info.OnlyStore;
-  bool StoringGlobalVal = !isa<Instruction>(OnlyStore->getOperand(0));
+  Value *ReplVal = OnlyStore->getOperand(0);
+  // Loads may either load the stored value or uninitialized memory (undef).
+  // If the stored value may be poison, then replacing an uninitialized memory
+  // load with it would be incorrect.
----------------
DianQK wrote:

IIUC, a single store implies a similar meaning of dominating all loads (or we add store undef for all other paths). Should we add more clarification here as to why this is incorrect?

https://github.com/llvm/llvm-project/pull/97711


More information about the llvm-commits mailing list