|
@@ -43,6 +43,8 @@
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
+cl::opt<bool> UseStringTable("remarks-yaml-string-table", cl::init(false));
|
|
|
+
|
|
|
int llvm::getNextAvailablePluginDiagnosticKind() {
|
|
|
static std::atomic<int> PluginKindID(DK_FirstPluginKind);
|
|
|
return ++PluginKindID;
|
|
@@ -373,6 +375,20 @@ std::string DiagnosticInfoOptimizationBase::getMsg() const {
|
|
|
void OptimizationRemarkAnalysisFPCommute::anchor() {}
|
|
|
void OptimizationRemarkAnalysisAliasing::anchor() {}
|
|
|
|
|
|
+template <typename T>
|
|
|
+static void mapRemarkHeader(
|
|
|
+ yaml::IO &io, T PassName, T RemarkName, DiagnosticLocation DL,
|
|
|
+ T FunctionName, Optional<uint64_t> Hotness,
|
|
|
+ SmallVectorImpl<DiagnosticInfoOptimizationBase::Argument> &Args) {
|
|
|
+ io.mapRequired("Pass", PassName);
|
|
|
+ io.mapRequired("Name", RemarkName);
|
|
|
+ if (!io.outputting() || DL.isValid())
|
|
|
+ io.mapOptional("DebugLoc", DL);
|
|
|
+ io.mapRequired("Function", FunctionName);
|
|
|
+ io.mapOptional("Hotness", Hotness);
|
|
|
+ io.mapOptional("Args", Args);
|
|
|
+}
|
|
|
+
|
|
|
namespace llvm {
|
|
|
namespace yaml {
|
|
|
|
|
@@ -413,13 +429,18 @@ void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
|
|
|
GlobalValue::dropLLVMManglingEscape(OptDiag->getFunction().getName());
|
|
|
|
|
|
StringRef PassName(OptDiag->PassName);
|
|
|
- io.mapRequired("Pass", PassName);
|
|
|
- io.mapRequired("Name", OptDiag->RemarkName);
|
|
|
- if (!io.outputting() || DL.isValid())
|
|
|
- io.mapOptional("DebugLoc", DL);
|
|
|
- io.mapRequired("Function", FN);
|
|
|
- io.mapOptional("Hotness", OptDiag->Hotness);
|
|
|
- io.mapOptional("Args", OptDiag->Args);
|
|
|
+ if (UseStringTable) {
|
|
|
+ remarks::StringTable &StrTab =
|
|
|
+ reinterpret_cast<RemarkStreamer *>(io.getContext())->getStringTable();
|
|
|
+ unsigned PassID = StrTab.add(PassName).first;
|
|
|
+ unsigned NameID = StrTab.add(OptDiag->RemarkName).first;
|
|
|
+ unsigned FunctionID = StrTab.add(FN).first;
|
|
|
+ mapRemarkHeader(io, PassID, NameID, DL, FunctionID, OptDiag->Hotness,
|
|
|
+ OptDiag->Args);
|
|
|
+ } else {
|
|
|
+ mapRemarkHeader(io, PassName, OptDiag->RemarkName, DL, FN, OptDiag->Hotness,
|
|
|
+ OptDiag->Args);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
template <> struct MappingTraits<DiagnosticLocation> {
|
|
@@ -430,7 +451,15 @@ template <> struct MappingTraits<DiagnosticLocation> {
|
|
|
unsigned Line = DL.getLine();
|
|
|
unsigned Col = DL.getColumn();
|
|
|
|
|
|
- io.mapRequired("File", File);
|
|
|
+ if (UseStringTable) {
|
|
|
+ remarks::StringTable &StrTab =
|
|
|
+ reinterpret_cast<RemarkStreamer *>(io.getContext())->getStringTable();
|
|
|
+ unsigned FileID = StrTab.add(File).first;
|
|
|
+ io.mapRequired("File", FileID);
|
|
|
+ } else {
|
|
|
+ io.mapRequired("File", File);
|
|
|
+ }
|
|
|
+
|
|
|
io.mapRequired("Line", Line);
|
|
|
io.mapRequired("Column", Col);
|
|
|
}
|
|
@@ -459,12 +488,18 @@ template <> struct BlockScalarTraits<StringBlockVal> {
|
|
|
template <> struct MappingTraits<DiagnosticInfoOptimizationBase::Argument> {
|
|
|
static void mapping(IO &io, DiagnosticInfoOptimizationBase::Argument &A) {
|
|
|
assert(io.outputting() && "input not yet implemented");
|
|
|
- // Emit a string block scalar for multiline strings, to preserve newlines.
|
|
|
- if (StringRef(A.Val).count('\n') > 1) {
|
|
|
+
|
|
|
+ if (UseStringTable) {
|
|
|
+ remarks::StringTable &StrTab =
|
|
|
+ reinterpret_cast<RemarkStreamer *>(io.getContext())->getStringTable();
|
|
|
+ auto ValueID = StrTab.add(A.Val).first;
|
|
|
+ io.mapRequired(A.Key.data(), ValueID);
|
|
|
+ } else if (StringRef(A.Val).count('\n') > 1) {
|
|
|
StringBlockVal S(A.Val);
|
|
|
io.mapRequired(A.Key.data(), S);
|
|
|
- } else
|
|
|
+ } else {
|
|
|
io.mapRequired(A.Key.data(), A.Val);
|
|
|
+ }
|
|
|
if (A.Loc.isValid())
|
|
|
io.mapOptional("DebugLoc", A.Loc);
|
|
|
}
|