From 209d5a12c55fe674686b5dbff8ba59cad665a56a Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Mon, 28 Oct 2019 11:10:07 -0700 Subject: [Remarks] Emit the remarks section by default for certain formats Emit a remarks section by default for the following formats: * bitstream * yaml-strtab while still providing -remarks-section= to override the defaults. --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 3692a03c268..b784d2980cb 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -146,11 +146,6 @@ static const char *const CodeViewLineTablesGroupDescription = STATISTIC(EmittedInsts, "Number of machine instrs printed"); -static cl::opt EnableRemarksSection( - "remarks-section", - cl::desc("Emit a section containing remark diagnostics metadata"), - cl::init(false)); - char AsmPrinter::ID = 0; using gcp_map_type = DenseMap>; @@ -1365,14 +1360,14 @@ void AsmPrinter::emitGlobalIndirectSymbol(Module &M, } } -void AsmPrinter::emitRemarksSection(Module &M) { - RemarkStreamer *RS = M.getContext().getRemarkStreamer(); - if (!RS) +void AsmPrinter::emitRemarksSection(RemarkStreamer &RS) { + if (!RS.needsSection()) return; - remarks::RemarkSerializer &RemarkSerializer = RS->getSerializer(); + + remarks::RemarkSerializer &RemarkSerializer = RS.getSerializer(); Optional> Filename; - if (Optional FilenameRef = RS->getFilename()) { + if (Optional FilenameRef = RS.getFilename()) { Filename = *FilenameRef; sys::fs::make_absolute(*Filename); assert(!Filename->empty() && "The filename can't be empty."); @@ -1427,8 +1422,8 @@ bool AsmPrinter::doFinalization(Module &M) { // Emit the remarks section contents. // FIXME: Figure out when is the safest time to emit this section. It should // not come after debug info. - if (EnableRemarksSection) - emitRemarksSection(M); + if (RemarkStreamer *RS = M.getContext().getRemarkStreamer()) + emitRemarksSection(*RS); const TargetLoweringObjectFile &TLOF = getObjFileLowering(); -- cgit v1.2.3