forked from OSchip/llvm-project
[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:
parent
0a243f47b0
commit
612cd1fdd6
|
@ -53,7 +53,11 @@ namespace llvm {
|
||||||
/// using the MIR serialization format.
|
/// using the MIR serialization format.
|
||||||
MachineFunctionPass *createPrintMIRPass(raw_ostream &OS);
|
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
|
/// createCodeGenPreparePass - Transform the code to expose more pattern
|
||||||
/// matching during instruction selection.
|
/// matching during instruction selection.
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
|
#include "llvm/IR/DiagnosticInfo.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -20,11 +21,14 @@ using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class ResetMachineFunction : public MachineFunctionPass {
|
class ResetMachineFunction : public MachineFunctionPass {
|
||||||
|
/// Tells whether or not this pass should emit a fallback
|
||||||
|
/// diagnostic when it resets a function.
|
||||||
|
bool EmitFallbackDiag;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
ResetMachineFunction() :
|
ResetMachineFunction(bool EmitFallbackDiag = false)
|
||||||
MachineFunctionPass(ID) {
|
: MachineFunctionPass(ID), EmitFallbackDiag(EmitFallbackDiag) {}
|
||||||
}
|
|
||||||
|
|
||||||
const char *getPassName() const override {
|
const char *getPassName() const override {
|
||||||
return "ResetMachineFunction";
|
return "ResetMachineFunction";
|
||||||
|
@ -35,6 +39,11 @@ namespace {
|
||||||
MachineFunctionProperties::Property::FailedISel)) {
|
MachineFunctionProperties::Property::FailedISel)) {
|
||||||
DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n');
|
DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n');
|
||||||
MF.reset();
|
MF.reset();
|
||||||
|
if (EmitFallbackDiag) {
|
||||||
|
const Function &F = *MF.getFunction();
|
||||||
|
DiagnosticInfoISelFallback DiagFallback(F);
|
||||||
|
F.getContext().diagnose(DiagFallback);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,6 +57,6 @@ INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE,
|
||||||
"reset machine function if ISel failed", false, false)
|
"reset machine function if ISel failed", false, false)
|
||||||
|
|
||||||
MachineFunctionPass *
|
MachineFunctionPass *
|
||||||
llvm::createResetMachineFunctionPass() {
|
llvm::createResetMachineFunctionPass(bool EmitFallbackDiag = false) {
|
||||||
return new ResetMachineFunction();
|
return new ResetMachineFunction(EmitFallbackDiag);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue