mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Hidden options to help debugging ifcvt issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37523 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -19,11 +19,27 @@
|
|||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Target/TargetLowering.h"
|
#include "llvm/Target/TargetLowering.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/ADT/DepthFirstIterator.h"
|
#include "llvm/ADT/DepthFirstIterator.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Hidden options for help debugging.
|
||||||
|
cl::opt<int> IfCvtFnStart("ifcvt-fn-start", cl::init(-1), cl::Hidden);
|
||||||
|
cl::opt<int> IfCvtFnStop("ifcvt-fn-stop", cl::init(-1), cl::Hidden);
|
||||||
|
cl::opt<int> IfCvtLimit("ifcvt-limit", cl::init(-1), cl::Hidden);
|
||||||
|
cl::opt<bool> DisableSimple("disable-ifcvt-simple",
|
||||||
|
cl::init(false), cl::Hidden);
|
||||||
|
cl::opt<bool> DisableSimpleFalse("disable-ifcvt-simple-false",
|
||||||
|
cl::init(false), cl::Hidden);
|
||||||
|
cl::opt<bool> DisableTriangle("disable-ifcvt-triangle",
|
||||||
|
cl::init(false), cl::Hidden);
|
||||||
|
cl::opt<bool> DisableDiamond("disable-ifcvt-diamond",
|
||||||
|
cl::init(false), cl::Hidden);
|
||||||
|
}
|
||||||
|
|
||||||
STATISTIC(NumSimple, "Number of simple if-conversions performed");
|
STATISTIC(NumSimple, "Number of simple if-conversions performed");
|
||||||
STATISTIC(NumSimpleRev, "Number of simple (reversed) if-conversions performed");
|
STATISTIC(NumSimpleRev, "Number of simple (reversed) if-conversions performed");
|
||||||
STATISTIC(NumTriangle, "Number of triangle if-conversions performed");
|
STATISTIC(NumTriangle, "Number of triangle if-conversions performed");
|
||||||
@@ -139,7 +155,15 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
TII = MF.getTarget().getInstrInfo();
|
TII = MF.getTarget().getInstrInfo();
|
||||||
if (!TII) return false;
|
if (!TII) return false;
|
||||||
|
|
||||||
DOUT << "\nIfcvt: function \'" << MF.getFunction()->getName() << "\'\n";
|
static int FnNum = -1;
|
||||||
|
DOUT << "\nIfcvt: function (" << ++FnNum << ") \'"
|
||||||
|
<< MF.getFunction()->getName() << "\'";
|
||||||
|
|
||||||
|
if (FnNum < IfCvtFnStart || (IfCvtFnStop != -1 && FnNum > IfCvtFnStop)) {
|
||||||
|
DOUT << " skipped\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DOUT << "\n";
|
||||||
|
|
||||||
MF.RenumberBlocks();
|
MF.RenumberBlocks();
|
||||||
BBAnalysis.resize(MF.getNumBlockIDs());
|
BBAnalysis.resize(MF.getNumBlockIDs());
|
||||||
@@ -151,7 +175,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
|
|
||||||
std::vector<BBInfo*> Candidates;
|
std::vector<BBInfo*> Candidates;
|
||||||
MadeChange = false;
|
MadeChange = false;
|
||||||
while (true) {
|
while (IfCvtLimit == -1 || (int)NumIfConvBBs < IfCvtLimit) {
|
||||||
// Do an intial analysis for each basic block and finding all the potential
|
// Do an intial analysis for each basic block and finding all the potential
|
||||||
// candidates to perform if-convesion.
|
// candidates to perform if-convesion.
|
||||||
bool Change = AnalyzeBlocks(MF, Candidates);
|
bool Change = AnalyzeBlocks(MF, Candidates);
|
||||||
@@ -171,6 +195,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
case ICSimple:
|
case ICSimple:
|
||||||
case ICSimpleFalse: {
|
case ICSimpleFalse: {
|
||||||
bool isRev = BBI.Kind == ICSimpleFalse;
|
bool isRev = BBI.Kind == ICSimpleFalse;
|
||||||
|
if ((isRev && DisableSimpleFalse) || (!isRev && DisableSimple)) break;
|
||||||
DOUT << "Ifcvt (Simple" << (BBI.Kind == ICSimpleFalse ? " false" : "")
|
DOUT << "Ifcvt (Simple" << (BBI.Kind == ICSimpleFalse ? " false" : "")
|
||||||
<< "): BB#" << BBI.BB->getNumber() << " ("
|
<< "): BB#" << BBI.BB->getNumber() << " ("
|
||||||
<< ((BBI.Kind == ICSimpleFalse)
|
<< ((BBI.Kind == ICSimpleFalse)
|
||||||
@@ -183,6 +208,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ICTriangle:
|
case ICTriangle:
|
||||||
|
if (DisableTriangle) break;
|
||||||
DOUT << "Ifcvt (Triangle): BB#" << BBI.BB->getNumber() << " (T:"
|
DOUT << "Ifcvt (Triangle): BB#" << BBI.BB->getNumber() << " (T:"
|
||||||
<< BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber()
|
<< BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber()
|
||||||
<< ") ";
|
<< ") ";
|
||||||
@@ -191,6 +217,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
if (RetVal) NumTriangle++;
|
if (RetVal) NumTriangle++;
|
||||||
break;
|
break;
|
||||||
case ICDiamond:
|
case ICDiamond:
|
||||||
|
if (DisableDiamond) break;
|
||||||
DOUT << "Ifcvt (Diamond): BB#" << BBI.BB->getNumber() << " (T:"
|
DOUT << "Ifcvt (Diamond): BB#" << BBI.BB->getNumber() << " (T:"
|
||||||
<< BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber();
|
<< BBI.TrueBB->getNumber() << ",F:" << BBI.FalseBB->getNumber();
|
||||||
if (BBI.TailBB)
|
if (BBI.TailBB)
|
||||||
@@ -202,6 +229,9 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Change |= RetVal;
|
Change |= RetVal;
|
||||||
|
|
||||||
|
if (IfCvtLimit != -1 && (int)NumIfConvBBs > IfCvtLimit)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Change)
|
if (!Change)
|
||||||
|
Reference in New Issue
Block a user