diff options
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(); |