1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[CodeGen] Teach opt remarks how to print MI instructions.

This will be used with GISel opt remarks.

llvm-svn: 296012
This commit is contained in:
Ahmed Bougacha 2017-02-23 21:05:33 +00:00
parent 66d4daa6cf
commit c860642291
2 changed files with 22 additions and 0 deletions

View File

@ -22,6 +22,7 @@
namespace llvm {
class MachineBasicBlock;
class MachineBlockFrequencyInfo;
class MachineInstr;
/// \brief Common features for diagnostics dealing with optimization remarks
/// that are used by machine passes.
@ -34,6 +35,12 @@ public:
*MBB->getParent()->getFunction(), DLoc),
MBB(MBB) {}
/// MI-specific kinds of diagnostic Arguments.
struct MachineArgument : public DiagnosticInfoOptimizationBase::Argument {
/// Print an entire MachineInstr.
MachineArgument(StringRef Key, const MachineInstr &MI);
};
static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() >= DK_FirstMachineRemark &&
DI->getKind() <= DK_LastMachineRemark;
@ -116,6 +123,11 @@ public:
}
};
/// Extend llvm::ore:: with MI-specific helper names.
namespace ore {
using MNV = DiagnosticInfoMIROptimization::MachineArgument;
}
/// The optimization diagnostic interface.
///
/// It allows reporting when optimizations are performed and when they are not

View File

@ -15,12 +15,22 @@
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
#include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/LLVMContext.h"
using namespace llvm;
DiagnosticInfoMIROptimization::MachineArgument::MachineArgument(
StringRef MKey, const MachineInstr &MI)
: Argument() {
Key = MKey;
raw_string_ostream OS(Val);
MI.print(OS, /*SkipOpers=*/false, /*SkipDebugLoc=*/true);
}
Optional<uint64_t>
MachineOptimizationRemarkEmitter::computeHotness(const MachineBasicBlock &MBB) {
if (!MBFI)