mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
Add a dereferenceable attribute
This attribute indicates that the parameter or return pointer is dereferenceable. Practically speaking, loads from such a pointer within the associated byte range are safe to speculatively execute. Such pointer parameters are common in source languages (C++ references, for example). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -77,11 +77,17 @@ unsigned Argument::getArgNo() const {
|
||||
}
|
||||
|
||||
/// hasNonNullAttr - Return true if this argument has the nonnull attribute on
|
||||
/// it in its containing function.
|
||||
/// it in its containing function. Also returns true if at least one byte is
|
||||
/// known to be dereferenceable and the pointer is in addrspace(0).
|
||||
bool Argument::hasNonNullAttr() const {
|
||||
if (!getType()->isPointerTy()) return false;
|
||||
return getParent()->getAttributes().
|
||||
hasAttribute(getArgNo()+1, Attribute::NonNull);
|
||||
if (getParent()->getAttributes().
|
||||
hasAttribute(getArgNo()+1, Attribute::NonNull))
|
||||
return true;
|
||||
else if (getDereferenceableBytes() > 0 &&
|
||||
getType()->getPointerAddressSpace() == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// hasByValAttr - Return true if this argument has the byval attribute on it
|
||||
@@ -113,6 +119,12 @@ unsigned Argument::getParamAlignment() const {
|
||||
|
||||
}
|
||||
|
||||
uint64_t Argument::getDereferenceableBytes() const {
|
||||
assert(getType()->isPointerTy() &&
|
||||
"Only pointers have dereferenceable bytes");
|
||||
return getParent()->getDereferenceableBytes(getArgNo()+1);
|
||||
}
|
||||
|
||||
/// hasNestAttr - Return true if this argument has the nest attribute on
|
||||
/// it in its containing function.
|
||||
bool Argument::hasNestAttr() const {
|
||||
|
Reference in New Issue
Block a user