diff options
author | Tres Popp <tpopp@google.com> | 2020-09-29 10:24:54 +0200 |
---|---|---|
committer | Tres Popp <tpopp@google.com> | 2020-09-29 10:31:04 +0200 |
commit | eb9f7c28e5fe6d75fed3587023e17f2997c8024b (patch) | |
tree | ae988a9b545aa266e6a2e8a3674c34400539a5ae /llvm/lib/IR/Attributes.cpp | |
parent | 297ec611304663931be52e6118d9f135ceb8a027 (diff) | |
download | llvm-eb9f7c28e5fe6d75fed3587023e17f2997c8024b.zip llvm-eb9f7c28e5fe6d75fed3587023e17f2997c8024b.tar.gz llvm-eb9f7c28e5fe6d75fed3587023e17f2997c8024b.tar.bz2 |
Revert "OpaquePtr: Add type to sret attribute"
This reverts commit 55c4ff91bd820d72014f63dcf7f3d5a0d3397986.
Issues were introduced as discussed in https://reviews.llvm.org/D88241
where this change made previous bugs in the linker and BitCodeWriter
visible.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 172341d..a3940c0 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -172,10 +172,6 @@ Attribute Attribute::getWithByValType(LLVMContext &Context, Type *Ty) { return get(Context, ByVal, Ty); } -Attribute Attribute::getWithStructRetType(LLVMContext &Context, Type *Ty) { - return get(Context, StructRet, Ty); -} - Attribute Attribute::getWithByRefType(LLVMContext &Context, Type *Ty) { return get(Context, ByRef, Ty); } @@ -437,6 +433,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const { return "shadowcallstack"; if (hasAttribute(Attribute::StrictFP)) return "strictfp"; + if (hasAttribute(Attribute::StructRet)) + return "sret"; if (hasAttribute(Attribute::SanitizeThread)) return "sanitize_thread"; if (hasAttribute(Attribute::SanitizeMemory)) @@ -452,10 +450,9 @@ std::string Attribute::getAsString(bool InAttrGrp) const { if (hasAttribute(Attribute::NoUndef)) return "noundef"; - const bool IsByVal = hasAttribute(Attribute::ByVal); - if (IsByVal || hasAttribute(Attribute::StructRet)) { + if (hasAttribute(Attribute::ByVal)) { std::string Result; - Result += IsByVal ? "byval" : "sret"; + Result += "byval"; if (Type *Ty = getValueAsType()) { raw_string_ostream OS(Result); Result += '('; @@ -757,10 +754,6 @@ Type *AttributeSet::getByValType() const { return SetNode ? SetNode->getByValType() : nullptr; } -Type *AttributeSet::getStructRetType() const { - return SetNode ? SetNode->getStructRetType() : nullptr; -} - Type *AttributeSet::getPreallocatedType() const { return SetNode ? SetNode->getPreallocatedType() : nullptr; } @@ -857,9 +850,6 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C, const AttrBuilder &B) { case Attribute::ByVal: Attr = Attribute::getWithByValType(C, B.getByValType()); break; - case Attribute::StructRet: - Attr = Attribute::getWithStructRetType(C, B.getStructRetType()); - break; case Attribute::ByRef: Attr = Attribute::getWithByRefType(C, B.getByRefType()); break; @@ -949,12 +939,6 @@ Type *AttributeSetNode::getByValType() const { return nullptr; } -Type *AttributeSetNode::getStructRetType() const { - if (auto A = findEnumAttribute(Attribute::StructRet)) - return A->getValueAsType(); - return nullptr; -} - Type *AttributeSetNode::getByRefType() const { if (auto A = findEnumAttribute(Attribute::ByRef)) return A->getValueAsType(); @@ -1482,10 +1466,6 @@ Type *AttributeList::getParamByValType(unsigned Index) const { return getAttributes(Index+FirstArgIndex).getByValType(); } -Type *AttributeList::getParamStructRetType(unsigned Index) const { - return getAttributes(Index + FirstArgIndex).getStructRetType(); -} - Type *AttributeList::getParamByRefType(unsigned Index) const { return getAttributes(Index + FirstArgIndex).getByRefType(); } @@ -1575,7 +1555,6 @@ void AttrBuilder::clear() { DerefBytes = DerefOrNullBytes = 0; AllocSizeArgs = 0; ByValType = nullptr; - StructRetType = nullptr; ByRefType = nullptr; PreallocatedType = nullptr; } @@ -1595,8 +1574,6 @@ AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) { StackAlignment = Attr.getStackAlignment(); else if (Kind == Attribute::ByVal) ByValType = Attr.getValueAsType(); - else if (Kind == Attribute::StructRet) - StructRetType = Attr.getValueAsType(); else if (Kind == Attribute::ByRef) ByRefType = Attr.getValueAsType(); else if (Kind == Attribute::Preallocated) @@ -1625,8 +1602,6 @@ AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) { StackAlignment.reset(); else if (Val == Attribute::ByVal) ByValType = nullptr; - else if (Val == Attribute::StructRet) - StructRetType = nullptr; else if (Val == Attribute::ByRef) ByRefType = nullptr; else if (Val == Attribute::Preallocated) @@ -1719,12 +1694,6 @@ AttrBuilder &AttrBuilder::addByValAttr(Type *Ty) { return *this; } -AttrBuilder &AttrBuilder::addStructRetAttr(Type *Ty) { - Attrs[Attribute::StructRet] = true; - StructRetType = Ty; - return *this; -} - AttrBuilder &AttrBuilder::addByRefAttr(Type *Ty) { Attrs[Attribute::ByRef] = true; ByRefType = Ty; @@ -1757,9 +1726,6 @@ AttrBuilder &AttrBuilder::merge(const AttrBuilder &B) { if (!ByValType) ByValType = B.ByValType; - if (!StructRetType) - StructRetType = B.StructRetType; - if (!ByRefType) ByRefType = B.ByRefType; @@ -1794,9 +1760,6 @@ AttrBuilder &AttrBuilder::remove(const AttrBuilder &B) { if (B.ByValType) ByValType = nullptr; - if (B.StructRetType) - StructRetType = nullptr; - if (B.ByRefType) ByRefType = nullptr; @@ -1863,8 +1826,7 @@ bool AttrBuilder::operator==(const AttrBuilder &B) { return Alignment == B.Alignment && StackAlignment == B.StackAlignment && DerefBytes == B.DerefBytes && ByValType == B.ByValType && - StructRetType == B.StructRetType && ByRefType == B.ByRefType && - PreallocatedType == B.PreallocatedType; + ByRefType == B.ByRefType && PreallocatedType == B.PreallocatedType; } //===----------------------------------------------------------------------===// @@ -1890,10 +1852,10 @@ AttrBuilder AttributeFuncs::typeIncompatible(Type *Ty) { .addDereferenceableOrNullAttr(1) // the int here is ignored .addAttribute(Attribute::ReadNone) .addAttribute(Attribute::ReadOnly) + .addAttribute(Attribute::StructRet) .addAttribute(Attribute::InAlloca) .addPreallocatedAttr(Ty) .addByValAttr(Ty) - .addStructRetAttr(Ty) .addByRefAttr(Ty); return Incompatible; |