From 612cd1fdd64cc7593b38115abd0e1bfb6f552b9d Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Wed, 31 Aug 2016 18:43:01 +0000 Subject: [ResetMachineFunction] Emit the diagnostic isel fallback when asked. This pass is now able to report when the function is being reset. llvm-svn: 280272 --- llvm/lib/CodeGen/ResetMachineFunctionPass.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/ResetMachineFunctionPass.cpp') diff --git a/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp b/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp index 3b7729a0540..07a8259a70c 100644 --- a/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp +++ b/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp @@ -13,6 +13,7 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/IR/DiagnosticInfo.h" #include "llvm/Support/Debug.h" using namespace llvm; @@ -20,11 +21,14 @@ using namespace llvm; namespace { class ResetMachineFunction : public MachineFunctionPass { + /// Tells whether or not this pass should emit a fallback + /// diagnostic when it resets a function. + bool EmitFallbackDiag; + public: static char ID; // Pass identification, replacement for typeid - ResetMachineFunction() : - MachineFunctionPass(ID) { - } + ResetMachineFunction(bool EmitFallbackDiag = false) + : MachineFunctionPass(ID), EmitFallbackDiag(EmitFallbackDiag) {} const char *getPassName() const override { return "ResetMachineFunction"; @@ -35,6 +39,11 @@ namespace { MachineFunctionProperties::Property::FailedISel)) { DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n'); MF.reset(); + if (EmitFallbackDiag) { + const Function &F = *MF.getFunction(); + DiagnosticInfoISelFallback DiagFallback(F); + F.getContext().diagnose(DiagFallback); + } return true; } return false; @@ -48,6 +57,6 @@ INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE, "reset machine function if ISel failed", false, false) MachineFunctionPass * -llvm::createResetMachineFunctionPass() { - return new ResetMachineFunction(); +llvm::createResetMachineFunctionPass(bool EmitFallbackDiag = false) { + return new ResetMachineFunction(EmitFallbackDiag); } -- cgit v1.2.3