diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1415,7 +1415,10 @@ }); R << "BasicBlock: " << ore::NV("BasicBlock", MBB.getName()) << "\n"; for (auto &KV : MnemonicVec) { - auto Name = (Twine("INST_") + KV.first.trim()).str(); + auto Name = (Twine("INST_") + KV.first.trim().take_until([](char c) { + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || + c == '\f' || c == '\r'; + })).str(); R << KV.first << ": " << ore::NV(Name, KV.second) << "\n"; } ORE->emit(R); diff --git a/llvm/test/CodeGen/PowerPC/instruction-mix-remarks-BCTRL_LWZinto_toc.ll b/llvm/test/CodeGen/PowerPC/instruction-mix-remarks-BCTRL_LWZinto_toc.ll --- a/llvm/test/CodeGen/PowerPC/instruction-mix-remarks-BCTRL_LWZinto_toc.ll +++ b/llvm/test/CodeGen/PowerPC/instruction-mix-remarks-BCTRL_LWZinto_toc.ll @@ -6,8 +6,7 @@ ; CHECK: - String: "\n" ; CHECK: - String: "bctrl\n\tld 2, " ; CHECK: - String: ': ' -; CHECK: - INST_bctrl -; CHECK: ld 2,: '1' +; CHECK: - INST_bctrl: '1' ; CHECK: - String: "\n"