diff options
author | Philip Reames <listmail@philipreames.com> | 2021-03-25 14:47:31 -0700 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2021-03-25 14:47:31 -0700 |
commit | e7ebb87222e33936f6e5f3bd3fda919080ece1a0 (patch) | |
tree | b03f76fe301eb73ad50faf37a4ba5d68c9f9a2e5 /llvm/lib/IR/Value.cpp | |
parent | 67e28173f140dbd032a5256f0decacb6b7b2eae7 (diff) | |
download | llvm-e7ebb87222e33936f6e5f3bd3fda919080ece1a0.zip llvm-e7ebb87222e33936f6e5f3bd3fda919080ece1a0.tar.gz llvm-e7ebb87222e33936f6e5f3bd3fda919080ece1a0.tar.bz2 |
[deref] Handle byval/byref/sret/inalloc/preallocated arguments for deref-at-point semantics
All of these are scoped allocations which remain dereferenceable during the lifetime of the callee.
Differential Revision: https://reviews.llvm.org/D99310
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 8c06d4f..fb4eb9a 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -739,6 +739,12 @@ static bool canBeFreed(const Value *V) { if (isa<Constant>(V)) return false; + // Handle byval/byref/sret/inalloca/preallocated arguments. The storage + // lifetime is guaranteed to be longer than the callee's lifetime. + if (auto *A = dyn_cast<Argument>(V)) + if (A->hasPointeeInMemoryValueAttr()) + return false; + const Function *F = nullptr; if (auto *I = dyn_cast<Instruction>(V)) F = I->getFunction(); |