diff options
| author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2019-09-18 01:04:45 +0000 |
|---|---|---|
| committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2019-09-18 01:04:45 +0000 |
| commit | ba2e752c520b4ba31c30846269f8331cc217054f (patch) | |
| tree | 467b44cfa3beb638abbe90bf290ecaa571474ff1 /llvm/lib/CodeGen | |
| parent | 5f8a3270ae74d84599dc09c581c2a417d4bbfb5e (diff) | |
| download | bcm5719-llvm-ba2e752c520b4ba31c30846269f8331cc217054f.tar.gz bcm5719-llvm-ba2e752c520b4ba31c30846269f8331cc217054f.zip | |
[Remarks] Allow the RemarkStreamer to be used directly with a stream
The filename in the RemarkStreamer should be optional to allow clients
to stream remarks to memory or to existing streams.
This introduces a new overload of `setupOptimizationRemarks`, and avoids
enforcing the presence of a filename at different places.
llvm-svn: 372195
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index ca223f78c16..20c50bb8a2a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1349,15 +1349,18 @@ void AsmPrinter::emitRemarksSection(Module &M) { return; remarks::RemarkSerializer &RemarkSerializer = RS->getSerializer(); - StringRef FilenameRef = RS->getFilename(); - SmallString<128> Filename = FilenameRef; - sys::fs::make_absolute(Filename); - assert(!Filename.empty() && "The filename can't be empty."); + Optional<SmallString<128>> Filename; + if (Optional<StringRef> FilenameRef = RS->getFilename()) { + Filename = *FilenameRef; + sys::fs::make_absolute(*Filename); + assert(!Filename->empty() && "The filename can't be empty."); + } std::string Buf; raw_string_ostream OS(Buf); std::unique_ptr<remarks::MetaSerializer> MetaSerializer = - RemarkSerializer.metaSerializer(OS, StringRef(Filename)); + Filename ? RemarkSerializer.metaSerializer(OS, StringRef(*Filename)) + : RemarkSerializer.metaSerializer(OS); MetaSerializer->emit(); // Switch to the right section: .remarks/__remarks. |

