[llvm] MemoryDependenceAnalysis: Consider a pointer clobbered if it is saved (PR #142096)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 30 00:10:37 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: YunQiang Su (wzssyqa)
<details>
<summary>Changes</summary>
In MemoryDependenceResults::getSimplePointerDependencyFrom, when we find the instruction that a LoadInst depends, if we find an store instruction that save the pointer used by LoadInst, we consider the pointer may be clobbered.
---
Full diff: https://github.com/llvm/llvm-project/pull/142096.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/MemoryDependenceAnalysis.cpp (+5)
``````````diff
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index f062189bac6a0..00f36b9e088ad 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -564,6 +564,11 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
if (!QueryInst || QueryInst->isVolatile())
return MemDepResult::getClobber(SI);
+ // If we store the pointer of QueryInst, it is danger due to that the address
+ // may be modified with other reference.
+ if (QueryInst && QueryInst->getOperand(0) == SI->getOperand(0))
+ return MemDepResult::getClobber(SI);
+
// If alias analysis can tell that this store is guaranteed to not modify
// the query pointer, ignore it. Use getModRefInfo to handle cases where
// the query pointer points to constant memory etc.
``````````
</details>
https://github.com/llvm/llvm-project/pull/142096
More information about the llvm-commits
mailing list