llvm.org GIT mirror llvm / 75fdc3a
[CodeGen] Teach opt remarks how to print MI instructions. This will be used with GISel opt remarks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296012 91177308-0d34-0410-b5e6-96231b3b80d8 Ahmed Bougacha 3 years ago
2 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2121 namespace llvm {
2222 class MachineBasicBlock;
2323 class MachineBlockFrequencyInfo;
24 class MachineInstr;
2425
2526 /// \brief Common features for diagnostics dealing with optimization remarks
2627 /// that are used by machine passes.
3233 : DiagnosticInfoOptimizationBase(Kind, DS_Remark, PassName, RemarkName,
3334 *MBB->getParent()->getFunction(), DLoc),
3435 MBB(MBB) {}
36
37 /// MI-specific kinds of diagnostic Arguments.
38 struct MachineArgument : public DiagnosticInfoOptimizationBase::Argument {
39 /// Print an entire MachineInstr.
40 MachineArgument(StringRef Key, const MachineInstr &MI);
41 };
3542
3643 static bool classof(const DiagnosticInfo *DI) {
3744 return DI->getKind() >= DK_FirstMachineRemark &&
114121 return OptimizationRemarkAnalysis::isEnabled(getPassName());
115122 }
116123 };
124
125 /// Extend llvm::ore:: with MI-specific helper names.
126 namespace ore {
127 using MNV = DiagnosticInfoMIROptimization::MachineArgument;
128 }
117129
118130 /// The optimization diagnostic interface.
119131 ///
1414
1515 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
1616 #include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h"
17 #include "llvm/CodeGen/MachineInstr.h"
1718 #include "llvm/IR/DebugInfo.h"
1819 #include "llvm/IR/DiagnosticInfo.h"
1920 #include "llvm/IR/LLVMContext.h"
2021
2122 using namespace llvm;
23
24 DiagnosticInfoMIROptimization::MachineArgument::MachineArgument(
25 StringRef MKey, const MachineInstr &MI)
26 : Argument() {
27 Key = MKey;
28
29 raw_string_ostream OS(Val);
30 MI.print(OS, /*SkipOpers=*/false, /*SkipDebugLoc=*/true);
31 }
2232
2333 Optional
2434 MachineOptimizationRemarkEmitter::computeHotness(const MachineBasicBlock &MBB) {