Index: include/llvm/Analysis/MemoryBuiltins.h =================================================================== --- include/llvm/Analysis/MemoryBuiltins.h +++ include/llvm/Analysis/MemoryBuiltins.h @@ -198,7 +198,7 @@ class ObjectSizeOffsetEvaluator : public InstVisitor { - typedef IRBuilder BuilderTy; + typedef IRBuilder BuilderTy; typedef std::pair WeakEvalType; typedef DenseMap CacheMapTy; typedef SmallPtrSet PtrSetTy; Index: include/llvm/Analysis/ScalarEvolutionExpander.h =================================================================== --- include/llvm/Analysis/ScalarEvolutionExpander.h +++ include/llvm/Analysis/ScalarEvolutionExpander.h @@ -80,7 +80,7 @@ /// already in "expanded" form. bool LSRMode; - typedef IRBuilder BuilderType; + typedef IRBuilder BuilderType; BuilderType Builder; #ifndef NDEBUG Index: include/llvm/IR/IRBuilder.h =================================================================== --- include/llvm/IR/IRBuilder.h +++ include/llvm/IR/IRBuilder.h @@ -38,14 +38,12 @@ /// IRBuilder and needs to be inserted. /// /// By default, this inserts the instruction at the insertion point. -template class IRBuilderDefaultInserter { protected: void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const { if (BB) BB->getInstList().insert(InsertPt, I); - if (preserveNames) - I->setName(Name); + I->setName(Name); } }; @@ -537,14 +535,12 @@ /// created. Convenience state exists to specify fast-math flags and fp-math /// tags. /// -/// The first template argument handles whether or not to preserve names in the -/// final instruction output. This defaults to on. The second template argument -/// specifies a class to use for creating constants. This defaults to creating -/// minimally folded constants. The third template argument allows clients to -/// specify custom insertion hooks that are called on every newly created -/// insertion. -template > +/// The first template argument specifies a class to use for creating constants. +/// This defaults to creating minimally folded constants. The second template +/// argument allows clients to specify custom insertion hooks that are called on +/// every newly created insertion. +template class IRBuilder : public IRBuilderBase, public Inserter { T Folder; @@ -594,10 +590,6 @@ /// \brief Get the constant folder being used. const T &getFolder() { return Folder; } - /// \brief Return true if this builder is configured to actually add the - /// requested names to IR created through it. - bool isNamePreserving() const { return preserveNames; } - /// \brief Insert and return the specified instruction. template InstTy *Insert(InstTy *I, const Twine &Name = "") const { Index: lib/Target/XCore/XCoreLowerThreadLocal.cpp =================================================================== --- lib/Target/XCore/XCoreLowerThreadLocal.cpp +++ lib/Target/XCore/XCoreLowerThreadLocal.cpp @@ -76,7 +76,7 @@ static Instruction * createReplacementInstr(ConstantExpr *CE, Instruction *Instr) { - IRBuilder Builder(Instr); + IRBuilder Builder(Instr); unsigned OpCode = CE->getOpcode(); switch (OpCode) { case Instruction::GetElementPtr: { Index: lib/Transforms/IPO/MergeFunctions.cpp =================================================================== --- lib/Transforms/IPO/MergeFunctions.cpp +++ lib/Transforms/IPO/MergeFunctions.cpp @@ -1646,7 +1646,7 @@ // Helper for writeThunk, // Selects proper bitcast operation, // but a bit simpler then CastInst::getCastOpcode. -static Value *createCast(IRBuilder &Builder, Value *V, Type *DestTy) { +static Value *createCast(IRBuilder<> &Builder, Value *V, Type *DestTy) { Type *SrcTy = V->getType(); if (SrcTy->isStructTy()) { assert(DestTy->isStructTy()); @@ -1689,7 +1689,7 @@ Function *NewG = Function::Create(G->getFunctionType(), G->getLinkage(), "", G->getParent()); BasicBlock *BB = BasicBlock::Create(F->getContext(), "", NewG); - IRBuilder Builder(BB); + IRBuilder<> Builder(BB); SmallVector Args; unsigned i = 0; Index: lib/Transforms/InstCombine/InstCombineInternal.h =================================================================== --- lib/Transforms/InstCombine/InstCombineInternal.h +++ lib/Transforms/InstCombine/InstCombineInternal.h @@ -138,7 +138,7 @@ /// \brief An IRBuilder inserter that adds new instructions to the instcombine /// worklist. class LLVM_LIBRARY_VISIBILITY InstCombineIRInserter - : public IRBuilderDefaultInserter { + : public IRBuilderDefaultInserter { InstCombineWorklist &Worklist; AssumptionCache *AC; @@ -148,7 +148,7 @@ void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const { - IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt); + IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt); Worklist.Add(I); using namespace llvm::PatternMatch; @@ -171,7 +171,7 @@ /// \brief An IRBuilder that automatically inserts new instructions into the /// worklist. - typedef IRBuilder BuilderTy; + typedef IRBuilder BuilderTy; BuilderTy *Builder; private: Index: lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- lib/Transforms/InstCombine/InstructionCombining.cpp +++ lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3054,7 +3054,7 @@ /// Builder - This is an IRBuilder that automatically inserts new /// instructions into the worklist when they are created. - IRBuilder Builder( + IRBuilder Builder( F.getContext(), TargetFolder(DL), InstCombineIRInserter(Worklist, &AC)); // Lower dbg.declare intrinsics otherwise their value may be clobbered Index: lib/Transforms/Instrumentation/BoundsChecking.cpp =================================================================== --- lib/Transforms/Instrumentation/BoundsChecking.cpp +++ lib/Transforms/Instrumentation/BoundsChecking.cpp @@ -36,7 +36,7 @@ STATISTIC(ChecksSkipped, "Bounds checks skipped"); STATISTIC(ChecksUnable, "Bounds checks unable to add"); -typedef IRBuilder BuilderTy; +typedef IRBuilder BuilderTy; namespace { struct BoundsChecking : public FunctionPass { Index: lib/Transforms/Scalar/LoadCombine.cpp =================================================================== --- lib/Transforms/Scalar/LoadCombine.cpp +++ lib/Transforms/Scalar/LoadCombine.cpp @@ -68,7 +68,7 @@ const char *getPassName() const override { return "LoadCombine"; } static char ID; - typedef IRBuilder BuilderTy; + typedef IRBuilder BuilderTy; private: BuilderTy *Builder; @@ -226,7 +226,7 @@ AA = &getAnalysis().getAAResults(); - IRBuilder TheBuilder( + IRBuilder TheBuilder( BB.getContext(), TargetFolder(BB.getModule()->getDataLayout())); Builder = &TheBuilder; Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -89,7 +89,7 @@ namespace { /// \brief A custom IRBuilder inserter which prefixes all names, but only in /// Assert builds. -class IRBuilderPrefixedInserter : public IRBuilderDefaultInserter { +class IRBuilderPrefixedInserter : public IRBuilderDefaultInserter { #ifndef NDEBUG std::string Prefix; const Twine getNameWithPrefix(const Twine &Name) const { @@ -106,14 +106,13 @@ protected: void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const { - IRBuilderDefaultInserter::InsertHelper(I, getNameWithPrefix(Name), BB, - InsertPt); + IRBuilderDefaultInserter::InsertHelper(I, getNameWithPrefix(Name), BB, + InsertPt); } }; /// \brief Provide a typedef for IRBuilder that drops names in release builds. -using IRBuilderTy = - llvm::IRBuilder; +using IRBuilderTy = llvm::IRBuilder; } namespace { Index: lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- lib/Transforms/Utils/SimplifyCFG.cpp +++ lib/Transforms/Utils/SimplifyCFG.cpp @@ -1199,7 +1199,7 @@ NT->takeName(I1); } - IRBuilder Builder(NT); + IRBuilder Builder(NT); // Hoisting one of the terminators from our successor is a great thing. // Unfortunately, the successors of the if/else blocks may have PHI nodes in // them. If they do, all PHI entries for BB1/BB2 must agree for all PHI @@ -1640,7 +1640,7 @@ // Insert a select of the value of the speculated store. if (SpeculatedStoreValue) { - IRBuilder Builder(BI); + IRBuilder Builder(BI); Value *TrueV = SpeculatedStore->getValueOperand(); Value *FalseV = SpeculatedStoreValue; if (Invert) @@ -1660,7 +1660,7 @@ ThenBB->begin(), std::prev(ThenBB->end())); // Insert selects and rewrite the PHI operands. - IRBuilder Builder(BI); + IRBuilder Builder(BI); for (BasicBlock::iterator I = EndBB->begin(); PHINode *PN = dyn_cast(I); ++I) { unsigned OrigI = PN->getBasicBlockIndex(BB); @@ -1920,7 +1920,7 @@ // If we can still promote the PHI nodes after this gauntlet of tests, // do all of the PHI's now. Instruction *InsertPt = DomBlock->getTerminator(); - IRBuilder Builder(InsertPt); + IRBuilder Builder(InsertPt); // Move all 'aggressive' instructions, which are defined in the // conditional parts of the if's up to the dominating block. @@ -2831,7 +2831,7 @@ // Make sure we get to CommonDest on True&True directions. Value *PBICond = PBI->getCondition(); - IRBuilder Builder(PBI); + IRBuilder Builder(PBI); if (PBIOp) PBICond = Builder.CreateNot(PBICond, PBICond->getName()+".not"); Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -3791,8 +3791,8 @@ Instruction *InsertAfter = cast(BuildVectorSlice.back()); unsigned VecIdx = 0; for (auto &V : BuildVectorSlice) { - IRBuilder Builder( - InsertAfter->getParent(), ++BasicBlock::iterator(InsertAfter)); + IRBuilder Builder(InsertAfter->getParent(), + ++BasicBlock::iterator(InsertAfter)); InsertElementInst *IE = cast(V); Instruction *Extract = cast(Builder.CreateExtractElement( VectorizedRoot, Builder.getInt32(VecIdx++))); Index: unittests/IR/IRBuilderTest.cpp =================================================================== --- unittests/IR/IRBuilderTest.cpp +++ unittests/IR/IRBuilderTest.cpp @@ -252,7 +252,7 @@ } TEST_F(IRBuilderTest, WrapFlags) { - IRBuilder Builder(BB); + IRBuilder Builder(BB); // Test instructions. GlobalVariable *G = new GlobalVariable(*M, Builder.getInt32Ty(), true, Index: unittests/IR/PatternMatch.cpp =================================================================== --- unittests/IR/PatternMatch.cpp +++ unittests/IR/PatternMatch.cpp @@ -35,7 +35,7 @@ std::unique_ptr M; Function *F; BasicBlock *BB; - IRBuilder IRB; + IRBuilder IRB; PatternMatchTest() : M(new Module("PatternMatchTestModule", Ctx)),