Index: lib/Transforms/IPO/MergeSimilarFunctions.cpp =================================================================== --- lib/Transforms/IPO/MergeSimilarFunctions.cpp +++ lib/Transforms/IPO/MergeSimilarFunctions.cpp @@ -273,7 +273,7 @@ /// IntPtrType (get it from DataLayout). This is guaranteed to generate no-op /// casts, otherwise it will assert. static Value *createCastIfNeeded(Value *V, Type *DstType, - Value *InstrOrBB, Type *IntPtrType) { + Value *InstrOrBB, Type *IntPtrType, const DataLayout *DL) { if (V->getType() == DstType) return V; @@ -297,7 +297,7 @@ = Builder.CreateExtractValue(V, ArrayRef(I)); Value *Element = createCastIfNeeded(ExtractedValue, DstType->getStructElementType(I), - InstrOrBB, IntPtrType); + InstrOrBB, IntPtrType, DL); Result = Builder.CreateInsertValue(Result, Element, ArrayRef(I)); } @@ -325,7 +325,7 @@ llvm_unreachable("Can only cast int -> ptr or ptr -> (ptr or int)"); } - assert(cast(Result)->isNoopCast(IntPtrType) && + assert(cast(Result)->isNoopCast(*DL) && "Cast is not a no-op cast. Potential loss of precision"); return Result; @@ -1391,7 +1391,7 @@ FunctionType *FFTy = F->getFunctionType(); Type *IntPtrTy = DL->getIntPtrType(FFTy->getContext()); for (auto &AI : Thunk->args()) { - Value *Cast = createCastIfNeeded(&AI, FFTy->getParamType(i), BB, IntPtrTy); + Value *Cast = createCastIfNeeded(&AI, FFTy->getParamType(i), BB, IntPtrTy, DL); Args.push_back(Cast); ++i; } @@ -1412,7 +1412,7 @@ else if (CI->getType()->isPointerTy() && RetTy->isIntegerTy()) Builder.CreateRet(Builder.CreatePtrToInt(CI, RetTy)); else { - Value *Cast = createCastIfNeeded(CI, RetTy, BB, IntPtrTy); + Value *Cast = createCastIfNeeded(CI, RetTy, BB, IntPtrTy, DL); Builder.CreateRet(Cast); } } @@ -1546,7 +1546,7 @@ Instruction *F1InstInNewF, const std::vector &F2Insts, Function *NewF, ValueToValueMapTy &F1toNewF, const SmallVectorImpl &Comps, - Type *IntPtrTy) { + Type *IntPtrTy, const DataLayout *DL) { assert(F2Insts.size() == Comps.size() && "Mis-match between F2Insts & Comps!"); @@ -1594,7 +1594,7 @@ Value *Cast = createCastIfNeeded(F2NewFOperand, F2OrigOperand->getType(), F2InstInNewF, - IntPtrTy); + IntPtrTy, DL); F2InstInNewF->setOperand(OpId, Cast); } } @@ -1617,7 +1617,7 @@ F2Ret->setOperand(0, createCastIfNeeded(F2Ret->getReturnValue(), F1Ret->getReturnValue()->getType(), - F2Ret, IntPtrTy)); + F2Ret, IntPtrTy, DL)); } } else if (!F1InstInNewF->use_empty()) { // If the instructions have uses, we need to insert a PHI node. @@ -1645,7 +1645,7 @@ createCastIfNeeded(F2InstInNewF, F1IType, Terminators[FnI+1], - IntPtrTy)); + IntPtrTy, DL)); } Phi->addIncoming(F2InstInNewF, F2InstInNewF->getParent()); @@ -1738,7 +1738,7 @@ const DataLayout *FTD = Fns[FnI]->getDataLayout(); Type *IntPtrTy = FTD ? FTD->getIntPtrType(Ctx) : NULL; F2InValNewF = createCastIfNeeded(F2InValNewF, F1InValNewF->getType(), - InsertPt, IntPtrTy); + InsertPt, IntPtrTy, FTD); // Create compare & select Value *ChoiceArg = getLastArg(NewF); @@ -1966,7 +1966,7 @@ continue; // we already handled these above insertCondAndRemapInstructions(F1InstInNewF, F2Insts, - NewF, VMap, Fns, IntPtrType); + NewF, VMap, Fns, IntPtrType, DL); } // Replace functions with thunks Index: lib/Transforms/Utils/CloneFunction.cpp =================================================================== --- lib/Transforms/Utils/CloneFunction.cpp +++ lib/Transforms/Utils/CloneFunction.cpp @@ -162,7 +162,7 @@ // Create a new basic block and copy instructions into it! BasicBlock *CBB = CloneBasicBlock(&BB, VMap, NameSuffix, NewFunc, CodeInfo, - ModuleLevelChanges ? &DIFinder : nullptr); + CT == CloneType::ModuleLevelChanges ? &DIFinder : nullptr); // Add basic block mapping. VMap[&BB] = CBB;