[NFC] Remove uses of PointerType::getElementType()

Instead use either Type::getPointerElementType() or
Type::getNonOpaquePointerElementType().

This is part of D117885, in preparation for deprecating the API.
This commit is contained in:
Nikita Popov
2022-01-21 13:03:15 +01:00
parent 2a14bc55c5
commit aa97bc116d
54 changed files with 182 additions and 188 deletions

View File

@@ -2702,7 +2702,7 @@ Error BitcodeReader::parseConstants() {
PointerType *OrigPtrTy = cast<PointerType>(Elt0FullTy->getScalarType());
if (!PointeeType)
PointeeType = OrigPtrTy->getElementType();
PointeeType = OrigPtrTy->getPointerElementType();
else if (!OrigPtrTy->isOpaqueOrPointeeTypeMatches(PointeeType))
return error("Explicit gep operator type does not match pointee type "
"of pointer operand");
@@ -2825,9 +2825,8 @@ Error BitcodeReader::parseConstants() {
ConstrStr += (char)Record[3+AsmStrSize+i];
UpgradeInlineAsmString(&AsmStr);
// FIXME: support upgrading in opaque pointers mode.
V = InlineAsm::get(
cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
V = InlineAsm::get(cast<FunctionType>(CurTy->getPointerElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
break;
}
// This version adds support for the asm dialect keywords (e.g.,
@@ -2852,10 +2851,9 @@ Error BitcodeReader::parseConstants() {
ConstrStr += (char)Record[3+AsmStrSize+i];
UpgradeInlineAsmString(&AsmStr);
// FIXME: support upgrading in opaque pointers mode.
V = InlineAsm::get(
cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
InlineAsm::AsmDialect(AsmDialect));
V = InlineAsm::get(cast<FunctionType>(CurTy->getPointerElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
InlineAsm::AsmDialect(AsmDialect));
break;
}
// This version adds support for the unwind keyword.
@@ -2884,10 +2882,9 @@ Error BitcodeReader::parseConstants() {
ConstrStr += (char)Record[OpNum + AsmStrSize + i];
UpgradeInlineAsmString(&AsmStr);
// FIXME: support upgrading in opaque pointers mode.
V = InlineAsm::get(
cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
InlineAsm::AsmDialect(AsmDialect), CanThrow);
V = InlineAsm::get(cast<FunctionType>(CurTy->getPointerElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
InlineAsm::AsmDialect(AsmDialect), CanThrow);
break;
}
// This version adds explicit function type.
@@ -3282,7 +3279,7 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
if (!Ty->isPointerTy())
return error("Invalid type for value");
AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
Ty = cast<PointerType>(Ty)->getElementType();
Ty = Ty->getPointerElementType();
}
uint64_t RawLinkage = Record[3];
@@ -3375,7 +3372,7 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
if (!FTy)
return error("Invalid record");
if (auto *PTy = dyn_cast<PointerType>(FTy))
FTy = PTy->getElementType();
FTy = PTy->getPointerElementType();
if (!isa<FunctionType>(FTy))
return error("Invalid type for value");
@@ -3416,7 +3413,7 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
Func->removeParamAttr(i, Kind);
Type *PTy = cast<FunctionType>(FTy)->getParamType(i);
Type *PtrEltTy = cast<PointerType>(PTy)->getElementType();
Type *PtrEltTy = PTy->getPointerElementType();
Attribute NewAttr;
switch (Kind) {
case Attribute::ByVal:
@@ -3539,7 +3536,7 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord(
auto *PTy = dyn_cast<PointerType>(Ty);
if (!PTy)
return error("Invalid type for value");
Ty = PTy->getElementType();
Ty = PTy->getPointerElementType();
AddrSpace = PTy->getAddressSpace();
} else {
AddrSpace = Record[OpNum++];
@@ -3908,7 +3905,7 @@ void BitcodeReader::propagateAttributeTypes(CallBase *CB,
CB->removeParamAttr(i, Kind);
Type *PtrEltTy = cast<PointerType>(ArgsTys[i])->getElementType();
Type *PtrEltTy = ArgsTys[i]->getPointerElementType();
Attribute NewAttr;
switch (Kind) {
case Attribute::ByVal:
@@ -3949,7 +3946,7 @@ void BitcodeReader::propagateAttributeTypes(CallBase *CB,
case Intrinsic::preserve_array_access_index:
case Intrinsic::preserve_struct_access_index:
if (!CB->getAttributes().getParamElementType(0)) {
Type *ElTy = cast<PointerType>(ArgsTys[0])->getElementType();
Type *ElTy = ArgsTys[0]->getPointerElementType();
Attribute NewAttr = Attribute::get(Context, Attribute::ElementType, ElTy);
CB->addParamAttr(0, NewAttr);
}
@@ -4239,8 +4236,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
return error("Invalid record");
if (!Ty) {
Ty = cast<PointerType>(BasePtr->getType()->getScalarType())
->getElementType();
Ty = BasePtr->getType()->getScalarType()->getPointerElementType();
} else if (!cast<PointerType>(BasePtr->getType()->getScalarType())
->isOpaqueOrPointeeTypeMatches(Ty)) {
return error(
@@ -4756,8 +4752,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (!CalleeTy)
return error("Callee is not a pointer");
if (!FTy) {
FTy = dyn_cast<FunctionType>(
cast<PointerType>(Callee->getType())->getElementType());
FTy =
dyn_cast<FunctionType>(Callee->getType()->getPointerElementType());
if (!FTy)
return error("Callee is not of pointer to function type");
} else if (!CalleeTy->isOpaqueOrPointeeTypeMatches(FTy))
@@ -4837,8 +4833,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (!OpTy)
return error("Callee is not a pointer type");
if (!FTy) {
FTy = dyn_cast<FunctionType>(
cast<PointerType>(Callee->getType())->getElementType());
FTy =
dyn_cast<FunctionType>(Callee->getType()->getPointerElementType());
if (!FTy)
return error("Callee is not of pointer to function type");
} else if (!OpTy->isOpaqueOrPointeeTypeMatches(FTy))
@@ -5000,7 +4996,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
auto *PTy = dyn_cast_or_null<PointerType>(Ty);
if (!PTy)
return error("Old-style alloca with a non-pointer type");
Ty = PTy->getElementType();
Ty = PTy->getPointerElementType();
}
Type *OpTy = getTypeByID(Record[1]);
Value *Size = getFnValueByID(Record[2], OpTy);
@@ -5045,7 +5041,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (OpNum + 3 == Record.size()) {
Ty = getTypeByID(Record[OpNum++]);
} else {
Ty = cast<PointerType>(Op->getType())->getElementType();
Ty = Op->getType()->getPointerElementType();
}
if (Error Err = typeCheckLoadStoreInst(Ty, Op->getType()))
@@ -5078,7 +5074,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (OpNum + 5 == Record.size()) {
Ty = getTypeByID(Record[OpNum++]);
} else {
Ty = cast<PointerType>(Op->getType())->getElementType();
Ty = Op->getType()->getPointerElementType();
}
if (Error Err = typeCheckLoadStoreInst(Ty, Op->getType()))
@@ -5110,8 +5106,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
(BitCode == bitc::FUNC_CODE_INST_STORE
? getValueTypePair(Record, OpNum, NextValueNo, Val)
: popValue(Record, OpNum, NextValueNo,
cast<PointerType>(Ptr->getType())->getElementType(),
Val)) ||
Ptr->getType()->getPointerElementType(), Val)) ||
OpNum + 2 != Record.size())
return error("Invalid record");
@@ -5139,8 +5134,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
(BitCode == bitc::FUNC_CODE_INST_STOREATOMIC
? getValueTypePair(Record, OpNum, NextValueNo, Val)
: popValue(Record, OpNum, NextValueNo,
cast<PointerType>(Ptr->getType())->getElementType(),
Val)) ||
Ptr->getType()->getPointerElementType(), Val)) ||
OpNum + 4 != Record.size())
return error("Invalid record");
@@ -5391,8 +5385,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (!OpTy)
return error("Callee is not a pointer type");
if (!FTy) {
FTy = dyn_cast<FunctionType>(
cast<PointerType>(Callee->getType())->getElementType());
FTy =
dyn_cast<FunctionType>(Callee->getType()->getPointerElementType());
if (!FTy)
return error("Callee is not of pointer to function type");
} else if (!OpTy->isOpaqueOrPointeeTypeMatches(FTy))