summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-opt-report/OptReport.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-03-19 18:21:43 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-03-19 18:21:43 +0000
commit064774f753a093f484b524eb5b3847da48dcad8d (patch)
tree6465a9303f05be43b19400c589a63b98c0e2045f /llvm/tools/llvm-opt-report/OptReport.cpp
parent9ef60a2539b268f40052f61149aab6c2442732aa (diff)
downloadbcm5719-llvm-064774f753a093f484b524eb5b3847da48dcad8d.tar.gz
bcm5719-llvm-064774f753a093f484b524eb5b3847da48dcad8d.zip
Revert "[Remarks] Add a new Remark / RemarkParser abstraction"
This reverts commit 51dc6a8c84cd6a58562e320e1828a0158dbbf750. Breaks http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/20034/steps/build%20stage%201/logs/stdio. llvm-svn: 356492
Diffstat (limited to 'llvm/tools/llvm-opt-report/OptReport.cpp')
-rw-r--r--llvm/tools/llvm-opt-report/OptReport.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp
index 3ea71fc47ef..43718eaedc0 100644
--- a/llvm/tools/llvm-opt-report/OptReport.cpp
+++ b/llvm/tools/llvm-opt-report/OptReport.cpp
@@ -15,7 +15,6 @@
#include "llvm-c/Remarks.h"
#include "llvm/Demangle/Demangle.h"
-#include "llvm/Remarks/RemarkParser.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
@@ -152,44 +151,40 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
return false;
}
- remarks::Parser Parser((*Buf)->getBuffer());
-
- while (true) {
- Expected<const remarks::Remark *> RemarkOrErr = Parser.getNext();
- if (!RemarkOrErr) {
- handleAllErrors(RemarkOrErr.takeError(), [&](const ErrorInfoBase &PE) {
- PE.log(WithColor::error());
- });
- return false;
- }
- if (!*RemarkOrErr) // End of file.
- break;
-
- const remarks::Remark &Remark = **RemarkOrErr;
-
- bool Transformed = Remark.RemarkType == remarks::Type::Passed;
+ StringRef Buffer = (*Buf)->getBuffer();
+ LLVMRemarkParserRef Parser =
+ LLVMRemarkParserCreate(Buffer.data(), Buffer.size());
+
+ LLVMRemarkEntry *Remark = nullptr;
+ while ((Remark = LLVMRemarkParserGetNext(Parser))) {
+ bool Transformed =
+ StringRef(Remark->RemarkType.Str, Remark->RemarkType.Len) == "!Passed";
+ StringRef Pass(Remark->PassName.Str, Remark->PassName.Len);
+ StringRef File(Remark->DebugLoc.SourceFile.Str,
+ Remark->DebugLoc.SourceFile.Len);
+ StringRef Function(Remark->FunctionName.Str, Remark->FunctionName.Len);
+ uint32_t Line = Remark->DebugLoc.SourceLineNumber;
+ uint32_t Column = Remark->DebugLoc.SourceColumnNumber;
+ ArrayRef<LLVMRemarkArg> Args(Remark->Args, Remark->NumArgs);
int VectorizationFactor = 1;
int InterleaveCount = 1;
int UnrollCount = 1;
- for (const remarks::Argument &Arg : Remark.Args) {
- if (Arg.Key == "VectorizationFactor")
- Arg.Val.getAsInteger(10, VectorizationFactor);
- else if (Arg.Key == "InterleaveCount")
- Arg.Val.getAsInteger(10, InterleaveCount);
- else if (Arg.Key == "UnrollCount")
- Arg.Val.getAsInteger(10, UnrollCount);
+ for (const LLVMRemarkArg &Arg : Args) {
+ StringRef ArgKeyName(Arg.Key.Str, Arg.Key.Len);
+ StringRef ArgValue(Arg.Value.Str, Arg.Value.Len);
+ if (ArgKeyName == "VectorizationFactor")
+ ArgValue.getAsInteger(10, VectorizationFactor);
+ else if (ArgKeyName == "InterleaveCount")
+ ArgValue.getAsInteger(10, InterleaveCount);
+ else if (ArgKeyName == "UnrollCount")
+ ArgValue.getAsInteger(10, UnrollCount);
}
- const Optional<remarks::RemarkLocation> &Loc = Remark.Loc;
- if (!Loc)
+ if (Line < 1 || File.empty())
continue;
- StringRef File = Loc->SourceFilePath;
- unsigned Line = Loc->SourceLine;
- unsigned Column = Loc->SourceColumn;
-
// We track information on both actual and potential transformations. This
// way, if there are multiple possible things on a line that are, or could
// have been transformed, we can indicate that explicitly in the output.
@@ -199,22 +194,27 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
LLII.Transformed = true;
};
- if (Remark.PassName == "inline") {
- auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column];
+ if (Pass == "inline") {
+ auto &LI = LocationInfo[File][Line][Function][Column];
UpdateLLII(LI.Inlined);
- } else if (Remark.PassName == "loop-unroll") {
- auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column];
+ } else if (Pass == "loop-unroll") {
+ auto &LI = LocationInfo[File][Line][Function][Column];
LI.UnrollCount = UnrollCount;
UpdateLLII(LI.Unrolled);
- } else if (Remark.PassName == "loop-vectorize") {
- auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column];
+ } else if (Pass == "loop-vectorize") {
+ auto &LI = LocationInfo[File][Line][Function][Column];
LI.VectorizationFactor = VectorizationFactor;
LI.InterleaveCount = InterleaveCount;
UpdateLLII(LI.Vectorized);
}
}
- return true;
+ bool HasError = LLVMRemarkParserHasError(Parser);
+ if (HasError)
+ WithColor::error() << LLVMRemarkParserGetErrorMessage(Parser) << "\n";
+
+ LLVMRemarkParserDispose(Parser);
+ return !HasError;
}
static bool writeReport(LocationInfoTy &LocationInfo) {
OpenPOWER on IntegriCloud