diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index 5b106c2005443e..802b913aa9f452 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1442,8 +1442,7 @@ class CallBase : public Instruction { /// type. void setCalledFunction(FunctionType *FTy, Value *Fn) { this->FTy = FTy; - assert(FTy == cast( - cast(Fn->getType())->getElementType())); + assert(cast(Fn->getType())->isOpaqueOrPointeeTypeMatches(FTy)); // 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. assert(getType() == FTy->getReturnType()); diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index a94f5406f3b255..0a1af1026be6a5 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -1017,8 +1017,8 @@ class GetElementPtrInst : public Instruction { void setResultElementType(Type *Ty) { ResultElementType = Ty; } Type *getResultElementType() const { - assert(ResultElementType == - cast(getType()->getScalarType())->getElementType()); + assert(cast(getType()->getScalarType()) + ->isOpaqueOrPointeeTypeMatches(ResultElementType)); return ResultElementType; } @@ -1160,8 +1160,8 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr, Values, InsertBefore), SourceElementType(PointeeType), ResultElementType(getIndexedType(PointeeType, IdxList)) { - assert(ResultElementType == - cast(getType()->getScalarType())->getElementType()); + assert(cast(getType()->getScalarType()) + ->isOpaqueOrPointeeTypeMatches(ResultElementType)); init(Ptr, IdxList, NameStr); } @@ -1174,8 +1174,8 @@ GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr, Values, InsertAtEnd), SourceElementType(PointeeType), ResultElementType(getIndexedType(PointeeType, IdxList)) { - assert(ResultElementType == - cast(getType()->getScalarType())->getElementType()); + assert(cast(getType()->getScalarType()) + ->isOpaqueOrPointeeTypeMatches(ResultElementType)); init(Ptr, IdxList, NameStr); } diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp index 1474573bb41de2..c8a7aa31133f32 100644 --- a/llvm/lib/CodeGen/AtomicExpandPass.cpp +++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp @@ -441,7 +441,7 @@ bool AtomicExpand::expandAtomicLoadToCmpXchg(LoadInst *LI) { Order = AtomicOrdering::Monotonic; Value *Addr = LI->getPointerOperand(); - Type *Ty = cast(Addr->getType())->getElementType(); + Type *Ty = LI->getType(); Constant *DummyVal = Constant::getNullValue(Ty); Value *Pair = Builder.CreateAtomicCmpXchg( diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp index 62e1ea6e0f0afe..770fc93490835d 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -1017,7 +1017,7 @@ void Interpreter::SwitchToNewBasicBlock(BasicBlock *Dest, ExecutionContext &SF){ void Interpreter::visitAllocaInst(AllocaInst &I) { 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... unsigned NumElements = diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp index fb3f3cf3fc256f..bc83be3c2cc03f 100644 --- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp @@ -369,7 +369,7 @@ static void createResumeEntryBlock(Function &F, coro::Shape &Shape) { coro::Shape::SwitchFieldIndex::Resume, "ResumeFn.addr"); auto *NullPtr = ConstantPointerNull::get(cast( - cast(GepIndex->getType())->getElementType())); + FrameTy->getTypeAtIndex(coro::Shape::SwitchFieldIndex::Resume))); Builder.CreateStore(NullPtr, GepIndex); } else { auto *GepIndex = Builder.CreateStructGEP(