Index: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h =================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h @@ -38,7 +38,7 @@ MCContext *Ctx; /// Name-mangler for global names. - Mangler *Mang; + Mangler *Mang = nullptr; TargetLoweringObjectFile( const TargetLoweringObjectFile&) = delete; Index: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp =================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp @@ -43,6 +43,8 @@ void TargetLoweringObjectFile::Initialize(MCContext &ctx, const TargetMachine &TM) { Ctx = &ctx; + // `Initialize` can be called more than once. + if (Mang != nullptr) delete Mang; Mang = new Mangler(); InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(), TM.getCodeModel(), *Ctx);