diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2020-06-25 19:17:24 -0400 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2020-09-24 09:57:28 -0400 |
commit | dc08185ca797a3bcd7721a0d55db876a6cc4de10 (patch) | |
tree | 599e37e633e7aef4a1e2c24b691677d4390dc37f /llvm/lib/IR/Value.cpp | |
parent | d65a7003c435de22b8e30dca292160fea822d887 (diff) | |
download | llvm-dc08185ca797a3bcd7721a0d55db876a6cc4de10.zip llvm-dc08185ca797a3bcd7721a0d55db876a6cc4de10.tar.gz llvm-dc08185ca797a3bcd7721a0d55db876a6cc4de10.tar.bz2 |
IR: Have byref imply dereferenceable
The langref already states it does, but this wasn't implemented. Also
covers inalloca and preallocated. Also helps fix a dependence on
pointer element types.
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 545404f..f01a639 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -712,11 +712,16 @@ uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL, CanBeNull = false; if (const Argument *A = dyn_cast<Argument>(this)) { DerefBytes = A->getDereferenceableBytes(); - if (DerefBytes == 0 && (A->hasByValAttr() || A->hasStructRetAttr())) { - Type *PT = cast<PointerType>(A->getType())->getElementType(); - if (PT->isSized()) - DerefBytes = DL.getTypeStoreSize(PT).getKnownMinSize(); + if (DerefBytes == 0) { + // Handle byval/byref/inalloca/preallocated arguments + if (Type *ArgMemTy = A->getPointeeInMemoryValueType()) { + if (ArgMemTy->isSized()) { + // FIXME: Why isn't this the type alloc size? + DerefBytes = DL.getTypeStoreSize(ArgMemTy).getKnownMinSize(); + } + } } + if (DerefBytes == 0) { DerefBytes = A->getDereferenceableOrNullBytes(); CanBeNull = true; |