Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -87,40 +87,33 @@ cl::Hidden); namespace { -/// \brief A custom IRBuilder inserter which prefixes all names if they are -/// preserved. -template -class IRBuilderPrefixedInserter - : public IRBuilderDefaultInserter { +/// \brief A custom IRBuilder inserter which prefixes all names, but only in +/// Assert builds. +class IRBuilderPrefixedInserter : public IRBuilderDefaultInserter { +#ifndef NDEBUG std::string Prefix; + const Twine getNameWithPrefix(const Twine &Name) const { + return Name.isTriviallyEmpty() ? Name : Prefix + Name; + } public: void SetNamePrefix(const Twine &P) { Prefix = P.str(); } +#else + const Twine getNameWithPrefix(const Twine &Name) const { return Name; } + void SetNamePrefix(const Twine &P) {} +#endif protected: void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const { - IRBuilderDefaultInserter::InsertHelper( - I, Name.isTriviallyEmpty() ? Name : Prefix + Name, BB, InsertPt); + IRBuilderDefaultInserter::InsertHelper(I, getNameWithPrefix(Name), BB, + InsertPt); } }; -// Specialization for not preserving the name is trivial. -template <> -class IRBuilderPrefixedInserter - : public IRBuilderDefaultInserter { -public: - void SetNamePrefix(const Twine &P) {} -}; - /// \brief Provide a typedef for IRBuilder that drops names in release builds. -#ifndef NDEBUG -typedef llvm::IRBuilder> - IRBuilderTy; -#else -typedef llvm::IRBuilder> - IRBuilderTy; -#endif +using IRBuilderTy = + llvm::IRBuilder; } namespace {