aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-03-28 13:02:52 -0400
committerNico Weber <thakis@chromium.org>2021-03-28 13:02:52 -0400
commit20d5c42e0ef5d252b434bcb610b04f1cb79fe771 (patch)
tree95e7fb9e08aa21e2d320765aca5e85d4ceebbefb /llvm/lib/IR/Attributes.cpp
parent821547cabb5819ed42245376a9afcd11cdee5ddd (diff)
downloadllvm-20d5c42e0ef5d252b434bcb610b04f1cb79fe771.zip
llvm-20d5c42e0ef5d252b434bcb610b04f1cb79fe771.tar.gz
llvm-20d5c42e0ef5d252b434bcb610b04f1cb79fe771.tar.bz2
Revert "OpaquePtr: Turn inalloca into a type attribute"
This reverts commit 4fefed65637ec46c8c2edad6b07b5569ac61e9e5. Broke check-clang everywhere.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp78
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);