aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-07-14 20:58:52 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-07-14 21:02:10 +0200
commit5e4b33fe9218703f0b29e2446159bcf4202d15fa (patch)
tree0d9685736f306ccf9eefa63564030318db6b4b4f /llvm/lib/IR/Attributes.cpp
parent9c2de2382197109388a25c9486f0e4408896d36e (diff)
downloadllvm-5e4b33fe9218703f0b29e2446159bcf4202d15fa.zip
llvm-5e4b33fe9218703f0b29e2446159bcf4202d15fa.tar.gz
llvm-5e4b33fe9218703f0b29e2446159bcf4202d15fa.tar.bz2
[Verifier] Improve incompatible attribute type check
A couple of attributes had explicit checks for incompatibility with pointer types. However, this is already handled generically by the typeIncompatible() check. We can drop these after adding SwiftError to typeIncompatible(). However, the previous implementation of the check prints out all attributes that are incompatible with a given type, even though those attributes aren't actually used. This has the annoying result that the error message changes every time a new attribute is added to the list. Improve this by explicitly finding which attribute isn't compatible and printing just that.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index beb8a24..31cef09 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -1923,11 +1923,12 @@ AttrBuilder AttributeFuncs::typeIncompatible(Type *Ty) {
.addAttribute(Attribute::NoAlias)
.addAttribute(Attribute::NoCapture)
.addAttribute(Attribute::NonNull)
+ .addAttribute(Attribute::ReadNone)
+ .addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::SwiftError)
.addAlignmentAttr(1) // the int here is ignored
.addDereferenceableAttr(1) // the int here is ignored
.addDereferenceableOrNullAttr(1) // the int here is ignored
- .addAttribute(Attribute::ReadNone)
- .addAttribute(Attribute::ReadOnly)
.addPreallocatedAttr(Ty)
.addInAllocaAttr(Ty)
.addByValAttr(Ty)