diff options
author | Oliver Stannard <oliver.stannard@linaro.org> | 2021-03-29 11:31:17 +0100 |
---|---|---|
committer | Oliver Stannard <oliver.stannard@linaro.org> | 2021-03-29 11:32:22 +0100 |
commit | 07e46367baeca96d84b03fa215b41775f69d5989 (patch) | |
tree | 154a7d4ca86da09b4610d7be3b4b4fb72e612f42 /llvm/lib/IR/Attributes.cpp | |
parent | b5da813fe91ee1d7b965bf3aa72e56a13d02dd7d (diff) | |
download | llvm-07e46367baeca96d84b03fa215b41775f69d5989.zip llvm-07e46367baeca96d84b03fa215b41775f69d5989.tar.gz llvm-07e46367baeca96d84b03fa215b41775f69d5989.tar.bz2 |
Revert "Reapply "OpaquePtr: Turn inalloca into a type attribute""
Reverting because test 'Bindings/Go/go.test' is failing on most
buildbots.
This reverts commit fc9df309917e57de704f3ce4372138a8d4a23d7a.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 78 |
1 files changed, 17 insertions, 61 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index c174e4f..831186a 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -195,10 +195,6 @@ Attribute Attribute::getWithPreallocatedType(LLVMContext &Context, Type *Ty) { return get(Context, Preallocated, Ty); } -Attribute Attribute::getWithInAllocaType(LLVMContext &Context, Type *Ty) { - return get(Context, InAlloca, Ty); -} - Attribute Attribute::getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional<unsigned> &NumElemsArg) { @@ -381,6 +377,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const { return "inaccessiblememonly"; if (hasAttribute(Attribute::InaccessibleMemOrArgMemOnly)) return "inaccessiblemem_or_argmemonly"; + if (hasAttribute(Attribute::InAlloca)) + return "inalloca"; if (hasAttribute(Attribute::InlineHint)) return "inlinehint"; if (hasAttribute(Attribute::InReg)) @@ -486,30 +484,24 @@ std::string Attribute::getAsString(bool InAttrGrp) const { if (hasAttribute(Attribute::MustProgress)) return "mustprogress"; - if (isTypeAttribute()) { + const bool IsByVal = hasAttribute(Attribute::ByVal); + if (IsByVal || hasAttribute(Attribute::StructRet)) { std::string Result; - raw_string_ostream OS(Result); - - switch (getKindAsEnum()) { - case Attribute::ByVal: - Result += "byval"; - break; - case Attribute::StructRet: - Result += "sret"; - break; - case Attribute::ByRef: - Result += "byref"; - break; - case Attribute::Preallocated: - Result += "preallocated"; - break; - case Attribute::InAlloca: - Result += "inalloca"; - break; - default: - llvm_unreachable("unhandled type attribute"); + Result += IsByVal ? "byval" : "sret"; + if (Type *Ty = getValueAsType()) { + raw_string_ostream OS(Result); + Result += '('; + Ty->print(OS, false, true); + OS.flush(); + Result += ')'; } + return Result; + } + const bool IsByRef = hasAttribute(Attribute::ByRef); + if (IsByRef || hasAttribute(Attribute::Preallocated)) { + std::string Result = IsByRef ? "byref" : "preallocated"; + raw_string_ostream OS(Result); Result += '('; getValueAsType()->print(OS, false, true); OS.flush(); @@ -817,10 +809,6 @@ Type *AttributeSet::getPreallocatedType() const { return SetNode ? SetNode->getPreallocatedType() : nullptr; } -Type *AttributeSet::getInAllocaType() const { - return SetNode ? SetNode->getInAllocaType() : nullptr; -} - std::pair<unsigned, Optional<unsigned>> AttributeSet::getAllocSizeArgs() const { return SetNode ? SetNode->getAllocSizeArgs() : std::pair<unsigned, Optional<unsigned>>(0, 0); @@ -927,9 +915,6 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C, const AttrBuilder &B) { case Attribute::Preallocated: Attr = Attribute::getWithPreallocatedType(C, B.getPreallocatedType()); break; - case Attribute::InAlloca: - Attr = Attribute::getWithInAllocaType(C, B.getInAllocaType()); - break; case Attribute::Alignment: assert(B.getAlignment() && "Alignment must be set"); Attr = Attribute::getWithAlignment(C, *B.getAlignment()); @@ -1036,12 +1021,6 @@ Type *AttributeSetNode::getPreallocatedType() const { return nullptr; } -Type *AttributeSetNode::getInAllocaType() const { - if (auto A = findEnumAttribute(Attribute::InAlloca)) - return A->getValueAsType(); - return nullptr; -} - uint64_t AttributeSetNode::getDereferenceableBytes() const { if (auto A = findEnumAttribute(Attribute::Dereferenceable)) return A->getDereferenceableBytes(); @@ -1599,10 +1578,6 @@ Type *AttributeList::getParamPreallocatedType(unsigned Index) const { return getAttributes(Index + FirstArgIndex).getPreallocatedType(); } -Type *AttributeList::getParamInAllocaType(unsigned Index) const { - return getAttributes(Index + FirstArgIndex).getInAllocaType(); -} - MaybeAlign AttributeList::getStackAlignment(unsigned Index) const { return getAttributes(Index).getStackAlignment(); } @@ -1724,9 +1699,6 @@ AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) { AllocSizeArgs = Attr.getValueAsInt(); else if (Kind == Attribute::VScaleRange) VScaleRangeArgs = Attr.getValueAsInt(); - else if (Kind == Attribute::InAlloca) - InAllocaType = Attr.getValueAsType(); - return *this; } @@ -1751,8 +1723,6 @@ AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) { ByRefType = nullptr; else if (Val == Attribute::Preallocated) PreallocatedType = nullptr; - else if (Val == Attribute::InAlloca) - InAllocaType = nullptr; else if (Val == Attribute::Dereferenceable) DerefBytes = 0; else if (Val == Attribute::DereferenceableOrNull) @@ -1882,12 +1852,6 @@ AttrBuilder &AttrBuilder::addPreallocatedAttr(Type *Ty) { return *this; } -AttrBuilder &AttrBuilder::addInAllocaAttr(Type *Ty) { - Attrs[Attribute::InAlloca] = true; - InAllocaType = Ty; - return *this; -} - AttrBuilder &AttrBuilder::merge(const AttrBuilder &B) { // FIXME: What if both have alignments, but they don't match?! if (!Alignment) @@ -1917,9 +1881,6 @@ AttrBuilder &AttrBuilder::merge(const AttrBuilder &B) { if (!PreallocatedType) PreallocatedType = B.PreallocatedType; - if (!InAllocaType) - InAllocaType = B.InAllocaType; - if (!VScaleRangeArgs) VScaleRangeArgs = B.VScaleRangeArgs; @@ -1960,9 +1921,6 @@ AttrBuilder &AttrBuilder::remove(const AttrBuilder &B) { if (B.PreallocatedType) PreallocatedType = nullptr; - if (B.InAllocaType) - InAllocaType = nullptr; - if (B.VScaleRangeArgs) VScaleRangeArgs = 0; @@ -2027,7 +1985,6 @@ bool AttrBuilder::operator==(const AttrBuilder &B) const { DerefBytes == B.DerefBytes && ByValType == B.ByValType && StructRetType == B.StructRetType && ByRefType == B.ByRefType && PreallocatedType == B.PreallocatedType && - InAllocaType == B.InAllocaType && VScaleRangeArgs == B.VScaleRangeArgs; } @@ -2057,7 +2014,6 @@ AttrBuilder AttributeFuncs::typeIncompatible(Type *Ty) { .addAttribute(Attribute::ReadOnly) .addAttribute(Attribute::InAlloca) .addPreallocatedAttr(Ty) - .addInAllocaAttr(Ty) .addByValAttr(Ty) .addStructRetAttr(Ty) .addByRefAttr(Ty); |