diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-07-25 18:21:13 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-07-25 18:21:13 +0200 |
commit | 087a8eea359a4d8ef22c42fddca3b09833928c6a (patch) | |
tree | dafacf5d78424c047f0c2742111ae13a39083961 /llvm/lib/IR/Attributes.cpp | |
parent | 99f869c8f00a36dac3c774178b69d05876a29a31 (diff) | |
download | llvm-087a8eea359a4d8ef22c42fddca3b09833928c6a.zip llvm-087a8eea359a4d8ef22c42fddca3b09833928c6a.tar.gz llvm-087a8eea359a4d8ef22c42fddca3b09833928c6a.tar.bz2 |
[Attributes] Clean up handling of UB implying attributes (NFC)
Rather than adding methods for dropping these attributes in
various places, add a function that returns an AttrBuilder with
these attributes, which can then be used with existing methods
for dropping attributes. This is with an eye on D104641, which
also needs to drop them from returns, not just parameters.
Also be more explicit about the semantics of the method in the
documentation. Refer to UB rather than Undef, which is what this
is actually about.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 92721c7..5cd1baf 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1335,16 +1335,6 @@ AttributeList AttributeList::removeAttributes(LLVMContext &C, return getImpl(C, AttrSets); } -AttributeList -AttributeList::removeParamUndefImplyingAttributes(LLVMContext &C, - unsigned ArgNo) const { - AttrBuilder B; - B.addAttribute(Attribute::NoUndef); - B.addDereferenceableAttr(1); - B.addDereferenceableOrNullAttr(1); - return removeParamAttributes(C, ArgNo, B); -} - AttributeList AttributeList::addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const { @@ -1926,6 +1916,14 @@ AttrBuilder AttributeFuncs::typeIncompatible(Type *Ty) { return Incompatible; } +AttrBuilder AttributeFuncs::getUBImplyingAttributes() { + AttrBuilder B; + B.addAttribute(Attribute::NoUndef); + B.addDereferenceableAttr(1); + B.addDereferenceableOrNullAttr(1); + return B; +} + template<typename AttrClass> static bool isEqual(const Function &Caller, const Function &Callee) { return Caller.getFnAttribute(AttrClass::getKind()) == |