summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Remarks/RemarkFormat.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-09-10 15:48:55 -0700
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-10-31 15:26:55 -0700
commite72e59e90287c50539cb2c0afbf197aa0101a023 (patch)
tree0c7481dcc08c20c59d650247175f8d0547790c0c /llvm/lib/Remarks/RemarkFormat.cpp
parentf9061049c1542579f661c3ec25528439ab9d0588 (diff)
downloadbcm5719-llvm-e72e59e90287c50539cb2c0afbf197aa0101a023.tar.gz
bcm5719-llvm-e72e59e90287c50539cb2c0afbf197aa0101a023.zip
[Remarks] Add support for linking remarks
Remarks are usually emitted per-TU, and for generating a standalone remark file that can be shipped with the linked binary we need some kind of tool to merge everything together. The remarks::RemarkLinker class takes care of this and: * Deduplicates remarks * Filters remarks with no debug location * Merges string tables from all the entries As an output, it provides an iterator range that can be used to serialize the remarks to a file. Differential Revision: https://reviews.llvm.org/D69141
Diffstat (limited to 'llvm/lib/Remarks/RemarkFormat.cpp')
-rw-r--r--llvm/lib/Remarks/RemarkFormat.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Remarks/RemarkFormat.cpp b/llvm/lib/Remarks/RemarkFormat.cpp
index f2d0331ec6a..c7fce151eff 100644
--- a/llvm/lib/Remarks/RemarkFormat.cpp
+++ b/llvm/lib/Remarks/RemarkFormat.cpp
@@ -12,6 +12,7 @@
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Remarks/BitstreamRemarkContainer.h"
using namespace llvm;
using namespace llvm::remarks;
@@ -30,3 +31,17 @@ Expected<Format> llvm::remarks::parseFormat(StringRef FormatStr) {
return Result;
}
+
+Expected<Format> llvm::remarks::magicToFormat(StringRef Magic) {
+ auto Result =
+ StringSwitch<Format>(Magic)
+ .StartsWith("--- ", Format::YAML) // This is only an assumption.
+ .StartsWith(remarks::Magic, Format::YAMLStrTab)
+ .StartsWith(remarks::ContainerMagic, Format::Bitstream)
+ .Default(Format::Unknown);
+
+ if (Result == Format::Unknown)
+ return createStringError(std::make_error_code(std::errc::invalid_argument),
+ "Unknown remark magic: '%s'", Magic.data());
+ return Result;
+}
OpenPOWER on IntegriCloud