diff --git a/lib/CodeGen/AsmPrinter/ByteStreamer.h b/lib/CodeGen/AsmPrinter/ByteStreamer.h index 05767206e6c..0cc829fffc5 100644 --- a/lib/CodeGen/AsmPrinter/ByteStreamer.h +++ b/lib/CodeGen/AsmPrinter/ByteStreamer.h @@ -72,26 +72,34 @@ class HashingByteStreamer : public ByteStreamer { class BufferByteStreamer : public ByteStreamer { private: SmallVectorImpl &Buffer; - // FIXME: This is actually only needed for textual asm output. SmallVectorImpl &Comments; + /// \brief Only verbose textual output needs comments. This will be set to + /// true for that case, and false otherwise. If false, comments passed in to + /// the emit methods will be ignored. + bool GenerateComments; + public: BufferByteStreamer(SmallVectorImpl &Buffer, - SmallVectorImpl &Comments) - : Buffer(Buffer), Comments(Comments) {} + SmallVectorImpl &Comments, + bool GenerateComments) + : Buffer(Buffer), Comments(Comments), GenerateComments(GenerateComments) {} void EmitInt8(uint8_t Byte, const Twine &Comment) override { Buffer.push_back(Byte); - Comments.push_back(Comment.str()); + if (GenerateComments) + Comments.push_back(Comment.str()); } void EmitSLEB128(uint64_t DWord, const Twine &Comment) override { raw_svector_ostream OSE(Buffer); encodeSLEB128(DWord, OSE); - Comments.push_back(Comment.str()); + if (GenerateComments) + Comments.push_back(Comment.str()); } void EmitULEB128(uint64_t DWord, const Twine &Comment) override { raw_svector_ostream OSE(Buffer); encodeULEB128(DWord, OSE); - Comments.push_back(Comment.str()); + if (GenerateComments) + Comments.push_back(Comment.str()); } }; diff --git a/lib/CodeGen/AsmPrinter/DebugLocStream.h b/lib/CodeGen/AsmPrinter/DebugLocStream.h index 818ea626bb2..3001da21b90 100644 --- a/lib/CodeGen/AsmPrinter/DebugLocStream.h +++ b/lib/CodeGen/AsmPrinter/DebugLocStream.h @@ -23,7 +23,6 @@ class MCSymbol; /// Stores a unified stream of .debug_loc entries. There's \a List for each /// variable/inlined-at pair, and an \a Entry for each \a DebugLocEntry. /// -/// FIXME: Why do we have comments even when it's an object stream? /// FIXME: Do we need all these temp symbols? /// FIXME: Why not output directly to the output stream? class DebugLocStream { @@ -52,7 +51,12 @@ private: SmallString<256> DWARFBytes; SmallVector Comments; + /// \brief Only verbose textual output needs comments. This will be set to + /// true for that case, and false otherwise. + bool GenerateComments; + public: + DebugLocStream(bool GenerateComments) : GenerateComments(GenerateComments) { } size_t getNumLists() const { return Lists.size(); } const List &getList(size_t LI) const { return Lists[LI]; } ArrayRef getLists() const { return Lists; } @@ -78,7 +82,7 @@ public: } BufferByteStreamer getStreamer() { - return BufferByteStreamer(DWARFBytes, Comments); + return BufferByteStreamer(DWARFBytes, Comments, GenerateComments); } ArrayRef getEntries(const List &L) const { diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 8c792ed53a6..7b7c8be372a 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -192,8 +192,8 @@ static LLVM_CONSTEXPR DwarfAccelTable::Atom TypeAtoms[] = { DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)}; DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) - : Asm(A), MMI(Asm->MMI), PrevLabel(nullptr), - InfoHolder(A, "info_string", DIEValueAllocator), + : Asm(A), MMI(Asm->MMI), DebugLocs(A->OutStreamer->isVerboseAsm()), + PrevLabel(nullptr), InfoHolder(A, "info_string", DIEValueAllocator), UsedNonDefaultText(false), SkeletonHolder(A, "skel_string", DIEValueAllocator), IsDarwin(Triple(A->getTargetTriple()).isOSDarwin()),