diff options
Diffstat (limited to 'llvm/lib/IR/IRBuilder.cpp')
-rw-r--r-- | llvm/lib/IR/IRBuilder.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 98f6ccf81973..27528a69be21 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -679,7 +679,7 @@ static CallInst *CreateGCStatepointCallCommon( const Twine &Name) { // Extract out the type of the callee. auto *FuncPtrType = cast<PointerType>(ActualCallee->getType()); - assert(isa<FunctionType>(FuncPtrType->getElementType()) && + assert(isa<FunctionType>(FuncPtrType->getPointerElementType()) && "actual callee must be a callable value"); Module *M = Builder->GetInsertBlock()->getParent()->getParent(); @@ -736,7 +736,7 @@ static InvokeInst *CreateGCStatepointInvokeCommon( ArrayRef<T3> GCArgs, const Twine &Name) { // Extract out the type of the callee. auto *FuncPtrType = cast<PointerType>(ActualInvokee->getType()); - assert(isa<FunctionType>(FuncPtrType->getElementType()) && + assert(isa<FunctionType>(FuncPtrType->getPointerElementType()) && "actual callee must be a callable value"); Module *M = Builder->GetInsertBlock()->getParent()->getParent(); @@ -984,10 +984,8 @@ CallInst *IRBuilderBase::CreateConstrainedFPCall( Value *IRBuilderBase::CreateSelect(Value *C, Value *True, Value *False, const Twine &Name, Instruction *MDFrom) { - if (auto *CC = dyn_cast<Constant>(C)) - if (auto *TC = dyn_cast<Constant>(True)) - if (auto *FC = dyn_cast<Constant>(False)) - return Insert(Folder.CreateSelect(CC, TC, FC), Name); + if (auto *V = Folder.FoldSelect(C, True, False)) + return V; SelectInst *Sel = SelectInst::Create(C, True, False); if (MDFrom) { @@ -1000,16 +998,17 @@ Value *IRBuilderBase::CreateSelect(Value *C, Value *True, Value *False, return Insert(Sel, Name); } -Value *IRBuilderBase::CreatePtrDiff(Value *LHS, Value *RHS, +Value *IRBuilderBase::CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS, const Twine &Name) { assert(LHS->getType() == RHS->getType() && "Pointer subtraction operand types must match!"); - auto *ArgType = cast<PointerType>(LHS->getType()); + assert(cast<PointerType>(LHS->getType()) + ->isOpaqueOrPointeeTypeMatches(ElemTy) && + "Pointer type must match element type"); Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context)); Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context)); Value *Difference = CreateSub(LHS_int, RHS_int); - return CreateExactSDiv(Difference, - ConstantExpr::getSizeOf(ArgType->getElementType()), + return CreateExactSDiv(Difference, ConstantExpr::getSizeOf(ElemTy), Name); } |