diff options
author | goldsteinn <35538541+goldsteinn@users.noreply.github.com> | 2024-10-16 12:53:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-16 11:53:21 -0500 |
commit | ae778ae7ce72219270c30d5c8b3d88c9a4803f81 (patch) | |
tree | a8c5311b233e19d76d9c19a35117d5cf613b0bf7 /llvm/lib/IR/Attributes.cpp | |
parent | 0850e721ab1c198f08994f003873a4147ec05e25 (diff) | |
download | llvm-ae778ae7ce72219270c30d5c8b3d88c9a4803f81.zip llvm-ae778ae7ce72219270c30d5c8b3d88c9a4803f81.tar.gz llvm-ae778ae7ce72219270c30d5c8b3d88c9a4803f81.tar.bz2 |
[Inliner] Propagate more attributes to params when inlining (#91101)
- **[Inliner] Add tests for propagating more parameter attributes; NFC**
- **[Inliner] Propagate more attributes to params when inlining**
Add support for propagating:
- `derefereancable`
- `derefereancable_or_null`
- `align`
- `nonnull`
- `range`
These are only propagated if the parameter to the to-be-inlined callsite
match the exact parameter used in the to-be-inlined function.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index c2fba49..55851d4 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1931,6 +1931,14 @@ AttributeList::getParamDereferenceableOrNullBytes(unsigned Index) const { return getParamAttrs(Index).getDereferenceableOrNullBytes(); } +std::optional<ConstantRange> +AttributeList::getParamRange(unsigned ArgNo) const { + auto RangeAttr = getParamAttrs(ArgNo).getAttribute(Attribute::Range); + if (RangeAttr.isValid()) + return RangeAttr.getRange(); + return std::nullopt; +} + FPClassTest AttributeList::getRetNoFPClass() const { return getRetAttrs().getNoFPClass(); } @@ -2277,6 +2285,13 @@ Attribute AttrBuilder::getAttribute(StringRef A) const { return {}; } +std::optional<ConstantRange> AttrBuilder::getRange() const { + const Attribute RangeAttr = getAttribute(Attribute::Range); + if (RangeAttr.isValid()) + return RangeAttr.getRange(); + return std::nullopt; +} + bool AttrBuilder::contains(Attribute::AttrKind A) const { return getAttribute(A).isValid(); } |