summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-10-28 11:10:07 -0700
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-10-28 12:50:46 -0700
commit209d5a12c55fe674686b5dbff8ba59cad665a56a (patch)
treedf84e93967d8462a58b08c9bd04217d6c7e60d9f /llvm/lib/IR
parenta51fc8ddf8800ed2f28d1e18b995e6c42f0bd3af (diff)
downloadbcm5719-llvm-209d5a12c55fe674686b5dbff8ba59cad665a56a.tar.gz
bcm5719-llvm-209d5a12c55fe674686b5dbff8ba59cad665a56a.zip
[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=<bool> to override the defaults.
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/RemarkStreamer.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/IR/RemarkStreamer.cpp b/llvm/lib/IR/RemarkStreamer.cpp
index 0fcc06b961f..9ad1243fc68 100644
--- a/llvm/lib/IR/RemarkStreamer.cpp
+++ b/llvm/lib/IR/RemarkStreamer.cpp
@@ -21,6 +21,13 @@
using namespace llvm;
+static cl::opt<cl::boolOrDefault> EnableRemarksSection(
+ "remarks-section",
+ cl::desc(
+ "Emit a section containing remark diagnostics metadata. By default, "
+ "this is enabled for the following formats: yaml-strtab, bitstream."),
+ cl::init(cl::BOU_UNSET), cl::Hidden);
+
RemarkStreamer::RemarkStreamer(
std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer,
Optional<StringRef> FilenameIn)
@@ -104,6 +111,31 @@ void RemarkStreamer::emit(const DiagnosticInfoOptimizationBase &Diag) {
RemarkSerializer->emit(R);
}
+bool RemarkStreamer::needsSection() const {
+ if (EnableRemarksSection == cl::BOU_TRUE)
+ return true;
+
+ if (EnableRemarksSection == cl::BOU_FALSE)
+ return false;
+
+ assert(EnableRemarksSection == cl::BOU_UNSET);
+
+ // We only need a section if we're in separate mode.
+ if (RemarkSerializer->Mode != remarks::SerializerMode::Separate)
+ return false;
+
+ // Only some formats need a section:
+ // * bitstream
+ // * yaml-strtab
+ switch (RemarkSerializer->SerializerFormat) {
+ case remarks::Format::YAMLStrTab:
+ case remarks::Format::Bitstream:
+ return true;
+ default:
+ return false;
+ }
+}
+
char RemarkSetupFileError::ID = 0;
char RemarkSetupPatternError::ID = 0;
char RemarkSetupFormatError::ID = 0;
OpenPOWER on IntegriCloud