diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index a0066c8885c..b0b8138e711 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -298,6 +298,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, emitLatency(DC, Inst); emitComments(DC, FormattedOS); + OS.flush(); assert(OutStringSize != 0 && "Output buffer cannot be zero size"); size_t OutputSize = std::min(OutStringSize-1, InsnStr.size()); diff --git a/lib/MC/MCExternalSymbolizer.cpp b/lib/MC/MCExternalSymbolizer.cpp index ca368b27e19..dae3f522a4f 100644 --- a/lib/MC/MCExternalSymbolizer.cpp +++ b/lib/MC/MCExternalSymbolizer.cpp @@ -13,6 +13,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/Support/raw_ostream.h" #include +#include using namespace llvm; @@ -56,6 +57,14 @@ bool MCExternalSymbolizer::tryAddingSymbolicOperand(MCInst &MI, if (Name) { SymbolicOp.AddSymbol.Name = Name; SymbolicOp.AddSymbol.Present = true; + // If Name is a C++ symbol name put the human readable name in a comment. + if (strncmp(Name, "__Z", 3) == 0) { + char *demangled = abi::__cxa_demangle(Name + 1, 0, 0, 0); + if (demangled) { + cStream << demangled; + free(demangled); + } + } } // For branches always create an MCExpr so it gets printed as hex address. else if (IsBranch) {