mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Add support for optimization reports.
Summary: This patch adds backend support for -Rpass=, which indicates the name of the optimization pass that should emit remarks stating when it made a transformation to the code. Pass names are taken from their DEBUG_NAME definitions. When emitting an optimization report diagnostic, the lack of debug information causes the diagnostic to use "<unknown>:0:0" as the location string. This is the back end counterpart for http://llvm-reviews.chandlerc.com/D3226 Reviewers: qcolombet CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3227 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205774 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,11 +14,13 @@
|
||||
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/DiagnosticInfo.h"
|
||||
#include "llvm/IR/DiagnosticPrinter.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/Atomic.h"
|
||||
#include <string>
|
||||
|
||||
@@ -64,3 +66,29 @@ void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {
|
||||
DP << getFileName() << ": ";
|
||||
DP << getMsg();
|
||||
}
|
||||
|
||||
bool DiagnosticInfoOptimizationRemark::isLocationAvailable() const {
|
||||
return getFunction().getParent()->getNamedMetadata("llvm.dbg.cu") != 0;
|
||||
}
|
||||
|
||||
void DiagnosticInfoOptimizationRemark::getLocation(StringRef *Filename,
|
||||
unsigned *Line,
|
||||
unsigned *Column) const {
|
||||
DILocation DIL(getDebugLoc().getAsMDNode(getFunction().getContext()));
|
||||
*Filename = DIL.getFilename();
|
||||
*Line = DIL.getLineNumber();
|
||||
*Column = DIL.getColumnNumber();
|
||||
}
|
||||
|
||||
const StringRef DiagnosticInfoOptimizationRemark::getLocationStr() const {
|
||||
StringRef Filename("<unknown>");
|
||||
unsigned Line = 0;
|
||||
unsigned Column = 0;
|
||||
if (isLocationAvailable())
|
||||
getLocation(&Filename, &Line, &Column);
|
||||
return Twine(Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
|
||||
}
|
||||
|
||||
void DiagnosticInfoOptimizationRemark::print(DiagnosticPrinter &DP) const {
|
||||
DP << getLocationStr() << ": " << getMsg();
|
||||
}
|
||||
|
Reference in New Issue
Block a user