aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/CaptureTracking.cpp
diff options
context:
space:
mode:
authorAlexander Richardson <alexrichardson@google.com>2025-08-08 14:22:42 -0700
committerGitHub <noreply@github.com>2025-08-08 14:22:42 -0700
commit3cf7262876cf261b5704bcf1d70d2de13d595e15 (patch)
tree82bdbd0f5da9f388e67925f8639bbd20cbec83a8 /llvm/lib/Analysis/CaptureTracking.cpp
parentd15280894bd03c618ec1b4debcbfdb1fecb81594 (diff)
downloadllvm-3cf7262876cf261b5704bcf1d70d2de13d595e15.zip
llvm-3cf7262876cf261b5704bcf1d70d2de13d595e15.tar.gz
llvm-3cf7262876cf261b5704bcf1d70d2de13d595e15.tar.bz2
[CaptureTracking] Handle ptrtoaddr
Unlike ptrtoint, ptrtoaddr does not capture provenance, only the address. Note: As defined by the LangRef, we always treat `ptrtoaddr` as a location-independent address capture since it is a direct inspection of the pointer address. Reviewed By: nikic Pull Request: https://github.com/llvm/llvm-project/pull/152221
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r--llvm/lib/Analysis/CaptureTracking.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp
index 076f417..bd0d417 100644
--- a/llvm/lib/Analysis/CaptureTracking.cpp
+++ b/llvm/lib/Analysis/CaptureTracking.cpp
@@ -359,6 +359,12 @@ UseCaptureInfo llvm::DetermineUseCaptureKind(const Use &U, const Value *Base) {
case Instruction::AddrSpaceCast:
// The original value is not captured via this if the new value isn't.
return UseCaptureInfo::passthrough();
+ case Instruction::PtrToAddr:
+ // We treat ptrtoaddr as a location-independent capture of the address even
+ // if it is ultimately not used. Continuing recursive analysis after
+ // ptrtoaddr would be possible, but we'd need logic to do that correctly,
+ // which is not the same as the current pointer following logic.
+ return CaptureComponents::Address;
case Instruction::ICmp: {
unsigned Idx = U.getOperandNo();
unsigned OtherIdx = 1 - Idx;