[llvm] r296012 - [CodeGen] Teach opt remarks how to print MI instructions.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 13:05:33 PST 2017
Author: ab
Date: Thu Feb 23 15:05:33 2017
New Revision: 296012
URL: http://llvm.org/viewvc/llvm-project?rev=296012&view=rev
Log:
[CodeGen] Teach opt remarks how to print MI instructions.
This will be used with GISel opt remarks.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h
llvm/trunk/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h?rev=296012&r1=296011&r2=296012&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h Thu Feb 23 15:05:33 2017
@@ -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
Modified: llvm/trunk/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp?rev=296012&r1=296011&r2=296012&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp Thu Feb 23 15:05:33 2017
@@ -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)
More information about the llvm-commits
mailing list