[ResetMachineFunction] Emit the diagnostic isel fallback when asked.

This pass is now able to report when the function is being reset.

llvm-svn: 280272
This commit is contained in:
Quentin Colombet 2016-08-31 18:43:01 +00:00
parent 0a243f47b0
commit 612cd1fdd6
2 changed files with 19 additions and 6 deletions

View File

@ -53,7 +53,11 @@ namespace llvm {
/// using the MIR serialization format.
MachineFunctionPass *createPrintMIRPass(raw_ostream &OS);
MachineFunctionPass *createResetMachineFunctionPass();
/// This pass resets a MachineFunction when it has the FailedISel property
/// as if it was just created.
/// If EmitFallbackDiag is true, the pass will emit a
/// DiagnosticInfoISelFallback for every MachineFunction it resets.
MachineFunctionPass *createResetMachineFunctionPass(bool EmitFallbackDiag);
/// createCodeGenPreparePass - Transform the code to expose more pattern
/// matching during instruction selection.

View File

@ -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);
}