aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-01-17 09:31:00 +0100
committerGitHub <noreply@github.com>2024-01-17 09:31:00 +0100
commit5f57ad85a1a7c46eb43eee3c7d93b11d8fd7fcfa (patch)
treed271dc0fcb728dc1b38c6fddb56c6d7cd8edb7c5 /llvm/lib/Analysis/AliasAnalysis.cpp
parent55172b7005a6f972272f6d79f2b0d15063bc1b1c (diff)
downloadllvm-5f57ad85a1a7c46eb43eee3c7d93b11d8fd7fcfa.zip
llvm-5f57ad85a1a7c46eb43eee3c7d93b11d8fd7fcfa.tar.gz
llvm-5f57ad85a1a7c46eb43eee3c7d93b11d8fd7fcfa.tar.bz2
[BasicAA] Remove incorrect rule about constant pointers (#76815)
BasicAA currently says that any Constant cannot alias an identified local object. This is not correct if the local object escaped, as it's possible to create a pointer to the escaped object using an inttoptr constant expression base. To compensate for this, make sure that inttoptr constant expressions are treated as escape sources, just like inttoptr instructions. This ensures that the optimization can still be applied if the local object is non-escaping. This is sufficient to still optimize the original motivating case from c53e2ecf0296a55d3c33c19fb70a3aa7f81f2732. Fixes https://github.com/llvm/llvm-project/issues/76789.
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/AliasAnalysis.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index da18279..6eaaad5 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -883,6 +883,11 @@ bool llvm::isEscapeSource(const Value *V) {
if (isa<IntToPtrInst>(V))
return true;
+ // Same for inttoptr constant expressions.
+ if (auto *CE = dyn_cast<ConstantExpr>(V))
+ if (CE->getOpcode() == Instruction::IntToPtr)
+ return true;
+
return false;
}