diff options
author | goldsteinn <35538541+goldsteinn@users.noreply.github.com> | 2024-10-17 11:32:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 10:32:55 -0500 |
commit | c85611e8583e6392d56075ebdfa60893b6284813 (patch) | |
tree | 0e9755aaff4332c655e985d957f821faca52661f /llvm/lib/IR/Attributes.cpp | |
parent | ab208de34efbde4fea03732eaa353a701e72f626 (diff) | |
download | llvm-c85611e8583e6392d56075ebdfa60893b6284813.zip llvm-c85611e8583e6392d56075ebdfa60893b6284813.tar.gz llvm-c85611e8583e6392d56075ebdfa60893b6284813.tar.bz2 |
[SimplifyLibCall][Attribute] Fix bug where we may keep `range` attr with incompatible type (#112649)
In a variety of places we change the bitwidth of a parameter but don't
update the attributes.
The issue in this case is from the `range` attribute when inlining
`__memset_chk`. `optimizeMemSetChk` will replace an `i32` with an
`i8`, and if the `i32` had a `range` attr assosiated it will cause an
error.
Fixes #112633
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index c2fba49..223c917 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -2300,7 +2300,7 @@ bool AttributeFuncs::isNoFPClassCompatibleType(Type *Ty) { } /// Which attributes cannot be applied to a type. -AttributeMask AttributeFuncs::typeIncompatible(Type *Ty, +AttributeMask AttributeFuncs::typeIncompatible(Type *Ty, AttributeSet AS, AttributeSafetyKind ASK) { AttributeMask Incompatible; @@ -2316,6 +2316,11 @@ AttributeMask AttributeFuncs::typeIncompatible(Type *Ty, // Attributes that only apply to integers or vector of integers. if (ASK & ASK_SAFE_TO_DROP) Incompatible.addAttribute(Attribute::Range); + } else { + Attribute RangeAttr = AS.getAttribute(Attribute::Range); + if (RangeAttr.isValid() && + RangeAttr.getRange().getBitWidth() != Ty->getScalarSizeInBits()) + Incompatible.addAttribute(Attribute::Range); } if (!Ty->isPointerTy()) { |