Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -939,14 +939,15 @@ if (const MCSection *S = MAI->getNonexecutableStackSection(OutContext)) OutStreamer.SwitchSection(S); - // Allow the target to emit any magic that it wants at the end of the file, - // after everything else has gone out. - EmitEndOfAsmFile(M); - delete Mang; Mang = 0; MMI = 0; OutStreamer.Finish(); + + // Allow the target to emit any magic that it wants at the end of the file, + // after everything else has gone out. + EmitEndOfAsmFile(M); + OutStreamer.reset(); return false;