aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-01-17 12:52:24 +0000
committerGitHub <noreply@github.com>2025-01-17 12:52:24 +0000
commit22637a877ae7fbfd5cf030400979fd4527eaebcf (patch)
treee0857280f65e23a70eff1fc0d68eed323de8b170 /llvm/lib/Analysis/Loads.cpp
parent8a229f595a5c0ff354cdfa05cda974a9d56674df (diff)
downloadllvm-22637a877ae7fbfd5cf030400979fd4527eaebcf.zip
llvm-22637a877ae7fbfd5cf030400979fd4527eaebcf.tar.gz
llvm-22637a877ae7fbfd5cf030400979fd4527eaebcf.tar.bz2
[Loads] Respect UseDerefAtPointSemantics in isDerefAndAlignedPointer. (#123196)
If a pointer gets freed, it may not be dereferenceable any longer, even though there is a dominating dereferenceable assumption. As first step, only consider assumptions if the pointer value cannot be freed if UseDerefAtPointSemantics is used. PR: https://github.com/llvm/llvm-project/pull/123196
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r--llvm/lib/Analysis/Loads.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 7bbd469..11ccfa3 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -25,6 +25,8 @@
using namespace llvm;
+extern cl::opt<bool> UseDerefAtPointSemantics;
+
static bool isAligned(const Value *Base, Align Alignment,
const DataLayout &DL) {
return Base->getPointerAlignment(DL) >= Alignment;
@@ -168,7 +170,7 @@ static bool isDereferenceableAndAlignedPointer(
Size, DL, CtxI, AC, DT, TLI,
Visited, MaxDepth);
- if (CtxI) {
+ if (CtxI && (!UseDerefAtPointSemantics || !V->canBeFreed())) {
/// Look through assumes to see if both dereferencability and alignment can
/// be proven by an assume if needed.
RetainedKnowledge AlignRK;