mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
[IR] Introduce a dereferenceable_or_null(N) attribute.
Summary: If a pointer is marked as dereferenceable_or_null(N), LLVM assumes it is either `null` or `dereferenceable(N)` or both. This change only introduces the attribute and adds a token test case for the `llvm-as` / `llvm-dis`. It does not hook up other parts of the optimizer to actually exploit the attribute -- those changes will come later. For pointers in address space 0, `dereferenceable(N)` is now exactly equivalent to `dereferenceable_or_null(N)` && `nonnull`. For other address spaces, `dereferenceable(N)` is potentially weaker than `dereferenceable_or_null(N)` && `nonnull` (since we could have a null `dereferenceable(N)` pointer). The motivating case for this change is Java (and other managed languages), where pointers are either `null` or dereferenceable up to some usually known-at-compile-time constant offset. Reviewers: rafael, hfinkel Reviewed By: hfinkel Subscribers: nicholas, llvm-commits Differential Revision: http://reviews.llvm.org/D8650 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1098,6 +1098,8 @@ static Attribute::AttrKind GetAttrFromCode(uint64_t Code) {
|
||||
return Attribute::NonNull;
|
||||
case bitc::ATTR_KIND_DEREFERENCEABLE:
|
||||
return Attribute::Dereferenceable;
|
||||
case bitc::ATTR_KIND_DEREFERENCEABLE_OR_NULL:
|
||||
return Attribute::DereferenceableOrNull;
|
||||
case bitc::ATTR_KIND_NO_RED_ZONE:
|
||||
return Attribute::NoRedZone;
|
||||
case bitc::ATTR_KIND_NO_RETURN:
|
||||
@ -1214,6 +1216,8 @@ std::error_code BitcodeReader::ParseAttributeGroupBlock() {
|
||||
B.addStackAlignmentAttr(Record[++i]);
|
||||
else if (Kind == Attribute::Dereferenceable)
|
||||
B.addDereferenceableAttr(Record[++i]);
|
||||
else if (Kind == Attribute::DereferenceableOrNull)
|
||||
B.addDereferenceableOrNullAttr(Record[++i]);
|
||||
} else { // String attribute
|
||||
assert((Record[i] == 3 || Record[i] == 4) &&
|
||||
"Invalid attribute group entry");
|
||||
|
Reference in New Issue
Block a user