[OpaquePtr] Remove some uses of PointerType::getElementType()

This commit is contained in:
Arthur Eubanks 2021-05-31 16:11:03 -07:00
parent db26cd30b6
commit 372237487e
5 changed files with 10 additions and 11 deletions

View File

@ -1442,8 +1442,7 @@ public:
/// type. /// type.
void setCalledFunction(FunctionType *FTy, Value *Fn) { void setCalledFunction(FunctionType *FTy, Value *Fn) {
this->FTy = FTy; this->FTy = FTy;
assert(FTy == cast<FunctionType>( assert(cast<PointerType>(Fn->getType())->isOpaqueOrPointeeTypeMatches(FTy));
cast<PointerType>(Fn->getType())->getElementType()));
// This function doesn't mutate the return type, only the function // This function doesn't mutate the return type, only the function
// type. Seems broken, but I'm just gonna stick an assert in for now. // type. Seems broken, but I'm just gonna stick an assert in for now.
assert(getType() == FTy->getReturnType()); assert(getType() == FTy->getReturnType());

View File

@ -1017,8 +1017,8 @@ public:
void setResultElementType(Type *Ty) { ResultElementType = Ty; } void setResultElementType(Type *Ty) { ResultElementType = Ty; }
Type *getResultElementType() const { Type *getResultElementType() const {
assert(ResultElementType == assert(cast<PointerType>(getType()->getScalarType())
cast<PointerType>(getType()->getScalarType())->getElementType()); ->isOpaqueOrPointeeTypeMatches(ResultElementType));
return ResultElementType; return ResultElementType;
} }
@ -1160,8 +1160,8 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,
Values, InsertBefore), Values, InsertBefore),
SourceElementType(PointeeType), SourceElementType(PointeeType),
ResultElementType(getIndexedType(PointeeType, IdxList)) { ResultElementType(getIndexedType(PointeeType, IdxList)) {
assert(ResultElementType == assert(cast<PointerType>(getType()->getScalarType())
cast<PointerType>(getType()->getScalarType())->getElementType()); ->isOpaqueOrPointeeTypeMatches(ResultElementType));
init(Ptr, IdxList, NameStr); init(Ptr, IdxList, NameStr);
} }
@ -1174,8 +1174,8 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,
Values, InsertAtEnd), Values, InsertAtEnd),
SourceElementType(PointeeType), SourceElementType(PointeeType),
ResultElementType(getIndexedType(PointeeType, IdxList)) { ResultElementType(getIndexedType(PointeeType, IdxList)) {
assert(ResultElementType == assert(cast<PointerType>(getType()->getScalarType())
cast<PointerType>(getType()->getScalarType())->getElementType()); ->isOpaqueOrPointeeTypeMatches(ResultElementType));
init(Ptr, IdxList, NameStr); init(Ptr, IdxList, NameStr);
} }

View File

@ -441,7 +441,7 @@ bool AtomicExpand::expandAtomicLoadToCmpXchg(LoadInst *LI) {
Order = AtomicOrdering::Monotonic; Order = AtomicOrdering::Monotonic;
Value *Addr = LI->getPointerOperand(); Value *Addr = LI->getPointerOperand();
Type *Ty = cast<PointerType>(Addr->getType())->getElementType(); Type *Ty = LI->getType();
Constant *DummyVal = Constant::getNullValue(Ty); Constant *DummyVal = Constant::getNullValue(Ty);
Value *Pair = Builder.CreateAtomicCmpXchg( Value *Pair = Builder.CreateAtomicCmpXchg(

View File

@ -1017,7 +1017,7 @@ void Interpreter::SwitchToNewBasicBlock(BasicBlock *Dest, ExecutionContext &SF){
void Interpreter::visitAllocaInst(AllocaInst &I) { void Interpreter::visitAllocaInst(AllocaInst &I) {
ExecutionContext &SF = ECStack.back(); ExecutionContext &SF = ECStack.back();
Type *Ty = I.getType()->getElementType(); // Type to be allocated Type *Ty = I.getAllocatedType(); // Type to be allocated
// Get the number of elements being allocated by the array... // Get the number of elements being allocated by the array...
unsigned NumElements = unsigned NumElements =

View File

@ -369,7 +369,7 @@ static void createResumeEntryBlock(Function &F, coro::Shape &Shape) {
coro::Shape::SwitchFieldIndex::Resume, coro::Shape::SwitchFieldIndex::Resume,
"ResumeFn.addr"); "ResumeFn.addr");
auto *NullPtr = ConstantPointerNull::get(cast<PointerType>( auto *NullPtr = ConstantPointerNull::get(cast<PointerType>(
cast<PointerType>(GepIndex->getType())->getElementType())); FrameTy->getTypeAtIndex(coro::Shape::SwitchFieldIndex::Resume)));
Builder.CreateStore(NullPtr, GepIndex); Builder.CreateStore(NullPtr, GepIndex);
} else { } else {
auto *GepIndex = Builder.CreateStructGEP( auto *GepIndex = Builder.CreateStructGEP(