aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorAndreas Jonson <andjo403@hotmail.com>2024-08-08 18:07:09 +0200
committerGitHub <noreply@github.com>2024-08-08 18:07:09 +0200
commit04da77308fcff417d9c925502d92d70761b5054b (patch)
treeb5376816d46b1f241e40b43bf321fdf7adf71d5f /llvm/lib/IR/Attributes.cpp
parentbe40c723ce2b7bf2690d22039d74d21b2bd5b7cf (diff)
downloadllvm-04da77308fcff417d9c925502d92d70761b5054b.zip
llvm-04da77308fcff417d9c925502d92d70761b5054b.tar.gz
llvm-04da77308fcff417d9c925502d92d70761b5054b.tar.bz2
Allow empty range attribute and add assert for full range (#100601)
fix #99619
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index abd05e3..fa124e4 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -171,6 +171,7 @@ Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
const ConstantRange &CR) {
assert(Attribute::isConstantRangeAttrKind(Kind) &&
"Not a ConstantRange attribute");
+ assert(!CR.isFullSet() && "ConstantRange attribute must not be full");
LLVMContextImpl *pImpl = Context.pImpl;
FoldingSetNodeID ID;
ID.AddInteger(Kind);
@@ -2020,6 +2021,9 @@ AttrBuilder &AttrBuilder::addInAllocaAttr(Type *Ty) {
AttrBuilder &AttrBuilder::addConstantRangeAttr(Attribute::AttrKind Kind,
const ConstantRange &CR) {
+ if (CR.isFullSet())
+ return *this;
+
return addAttribute(Attribute::get(Ctx, Kind, CR));
}