aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2021-03-29 08:42:23 -0400
committerMatt Arsenault <Matthew.Arsenault@amd.com>2021-03-29 08:55:30 -0400
commit9a0c9402fa58012c1c40c3b48d57cec0f712fdb9 (patch)
tree50dea1f6467bea5a89f8ec514da6cc32736122db /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parente4abb64100e4fe8f9ea400ddeb5c82fadbd67ef9 (diff)
downloadllvm-9a0c9402fa58012c1c40c3b48d57cec0f712fdb9.zip
llvm-9a0c9402fa58012c1c40c3b48d57cec0f712fdb9.tar.gz
llvm-9a0c9402fa58012c1c40c3b48d57cec0f712fdb9.tar.bz2
Reapply "OpaquePtr: Turn inalloca into a type attribute"
This reverts commit 07e46367baeca96d84b03fa215b41775f69d5989.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp48
1 files changed, 38 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 951e32e..46db3ed 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1624,6 +1624,8 @@ Error BitcodeReader::parseAttributeGroupBlock() {
B.addByValAttr(nullptr);
else if (Kind == Attribute::StructRet)
B.addStructRetAttr(nullptr);
+ else if (Kind == Attribute::InAlloca)
+ B.addInAllocaAttr(nullptr);
B.addAttribute(Kind);
} else if (Record[i] == 1) { // Integer attribute
@@ -1675,6 +1677,8 @@ Error BitcodeReader::parseAttributeGroupBlock() {
B.addByRefAttr(getTypeByID(Record[++i]));
} else if (Kind == Attribute::Preallocated) {
B.addPreallocatedAttr(getTypeByID(Record[++i]));
+ } else if (Kind == Attribute::InAlloca) {
+ B.addInAllocaAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
}
}
}
@@ -3328,7 +3332,8 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
// argument's pointee type. There should be no opaque pointers where the byval
// type is implicit.
for (unsigned i = 0; i != Func->arg_size(); ++i) {
- for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet}) {
+ for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet,
+ Attribute::InAlloca}) {
if (!Func->hasParamAttribute(i, Kind))
continue;
@@ -3336,10 +3341,21 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
Type *PTy = cast<FunctionType>(FullFTy)->getParamType(i);
Type *PtrEltTy = getPointerElementFlatType(PTy);
- Attribute NewAttr =
- Kind == Attribute::ByVal
- ? Attribute::getWithByValType(Context, PtrEltTy)
- : Attribute::getWithStructRetType(Context, PtrEltTy);
+ Attribute NewAttr;
+ switch (Kind) {
+ case Attribute::ByVal:
+ NewAttr = Attribute::getWithByValType(Context, PtrEltTy);
+ break;
+ case Attribute::StructRet:
+ NewAttr = Attribute::getWithStructRetType(Context, PtrEltTy);
+ break;
+ case Attribute::InAlloca:
+ NewAttr = Attribute::getWithInAllocaType(Context, PtrEltTy);
+ break;
+ default:
+ llvm_unreachable("not an upgraded type attribute");
+ }
+
Func->addParamAttr(i, NewAttr);
}
}
@@ -3805,17 +3821,29 @@ Error BitcodeReader::typeCheckLoadStoreInst(Type *ValType, Type *PtrType) {
void BitcodeReader::propagateByValSRetTypes(CallBase *CB,
ArrayRef<Type *> ArgsFullTys) {
for (unsigned i = 0; i != CB->arg_size(); ++i) {
- for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet}) {
+ for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet,
+ Attribute::InAlloca}) {
if (!CB->paramHasAttr(i, Kind))
continue;
CB->removeParamAttr(i, Kind);
Type *PtrEltTy = getPointerElementFlatType(ArgsFullTys[i]);
- Attribute NewAttr =
- Kind == Attribute::ByVal
- ? Attribute::getWithByValType(Context, PtrEltTy)
- : Attribute::getWithStructRetType(Context, PtrEltTy);
+ Attribute NewAttr;
+ switch (Kind) {
+ case Attribute::ByVal:
+ NewAttr = Attribute::getWithByValType(Context, PtrEltTy);
+ break;
+ case Attribute::StructRet:
+ NewAttr = Attribute::getWithStructRetType(Context, PtrEltTy);
+ break;
+ case Attribute::InAlloca:
+ NewAttr = Attribute::getWithInAllocaType(Context, PtrEltTy);
+ break;
+ default:
+ llvm_unreachable("not an upgraded type attribute");
+ }
+
CB->addParamAttr(i, NewAttr);
}
}