diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -550,8 +550,7 @@ F.hasFnAttribute(Attribute::NoRecurse), F.returnDoesNotAlias(), // FIXME: refactor this to use the same code that inliner is using. // Don't try to import functions with noinline attribute. - F.getAttributes().hasFnAttribute(Attribute::NoInline), - F.hasFnAttribute(Attribute::AlwaysInline)}; + F.getAttributes().hasFnAttribute(Attribute::NoInline)}; auto FuncSummary = std::make_unique( Flags, NumInsts, FunFlags, /*EntryCount=*/0, std::move(Refs), CallGraphEdges.takeVector(), TypeTests.takeVector(), diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5785,11 +5785,9 @@ } const uint64_t Version = Record[0]; const bool IsOldProfileFormat = Version == 1; - if (Version < 1 || Version > ModuleSummaryIndex::BitcodeSummaryVersion) + if (Version < 1 || Version > 7) return error("Invalid summary version " + Twine(Version) + - ". Version should be in the range [1-" + - Twine(ModuleSummaryIndex::BitcodeSummaryVersion) + - "]."); + ". Version should be in the range [1-7]."); Record.clear(); // Keep around the last seen summary to be used when we see an optional @@ -5904,6 +5902,11 @@ std::move(PendingTypeCheckedLoadVCalls), std::move(PendingTypeTestAssumeConstVCalls), std::move(PendingTypeCheckedLoadConstVCalls)); + PendingTypeTests.clear(); + PendingTypeTestAssumeVCalls.clear(); + PendingTypeCheckedLoadVCalls.clear(); + PendingTypeTestAssumeConstVCalls.clear(); + PendingTypeCheckedLoadConstVCalls.clear(); auto VIAndOriginalGUID = getValueInfoFromValueId(ValueID); FS->setModulePath(getThisModule()->first()); FS->setOriginalName(VIAndOriginalGUID.second); @@ -6046,6 +6049,11 @@ std::move(PendingTypeCheckedLoadVCalls), std::move(PendingTypeTestAssumeConstVCalls), std::move(PendingTypeCheckedLoadConstVCalls)); + PendingTypeTests.clear(); + PendingTypeTestAssumeVCalls.clear(); + PendingTypeCheckedLoadVCalls.clear(); + PendingTypeTestAssumeConstVCalls.clear(); + PendingTypeCheckedLoadConstVCalls.clear(); LastSeenSummary = FS.get(); LastSeenGUID = VI.getGUID(); FS->setModulePath(ModuleIdMap[ModuleId]); diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3737,6 +3737,11 @@ NameVals.clear(); } +// Current version for the summary. +// This is bumped whenever we introduce changes in the way some record are +// interpreted, like flags for instance. +static const uint64_t INDEX_VERSION = 7; + /// Emit the per-module summary section alongside the rest of /// the module's bitcode. void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() { diff --git a/llvm/lib/Transforms/IPO/MergeSimilarFunctions.cpp b/llvm/lib/Transforms/IPO/MergeSimilarFunctions.cpp --- a/llvm/lib/Transforms/IPO/MergeSimilarFunctions.cpp +++ b/llvm/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; @@ -1395,7 +1395,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; } @@ -1416,7 +1416,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); } } @@ -1550,7 +1550,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!"); @@ -1598,7 +1598,7 @@ Value *Cast = createCastIfNeeded(F2NewFOperand, F2OrigOperand->getType(), F2InstInNewF, - IntPtrTy); + IntPtrTy, DL); F2InstInNewF->setOperand(OpId, Cast); } } @@ -1621,7 +1621,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. @@ -1649,7 +1649,7 @@ createCastIfNeeded(F2InstInNewF, F1IType, Terminators[FnI+1], - IntPtrTy)); + IntPtrTy, DL)); } Phi->addIncoming(F2InstInNewF, F2InstInNewF->getParent()); @@ -1742,7 +1742,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); @@ -1970,7 +1970,7 @@ continue; // we already handled these above insertCondAndRemapInstructions(F1InstInNewF, F2Insts, - NewF, VMap, Fns, IntPtrType); + NewF, VMap, Fns, IntPtrType, DL); } // Replace functions with thunks diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/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;