From e7ebb87222e33936f6e5f3bd3fda919080ece1a0 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 25 Mar 2021 14:47:31 -0700 Subject: [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 --- llvm/lib/IR/Value.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/IR/Value.cpp') 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(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(V)) + if (A->hasPointeeInMemoryValueAttr()) + return false; + const Function *F = nullptr; if (auto *I = dyn_cast(V)) F = I->getFunction(); -- cgit v1.1