mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-31 09:25:42 +00:00
As Chris and Evan pointed out, BreakCriticalMachineEdges doesn't really need
to be a pass of its own. Instead, move it out into a helper method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
//===----------- BreakCriticalMachineEdges - Break critical edges ---------===//
|
//===--------- BreakCriticalMachineEdges.h - Break critical edges ---------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@@ -7,44 +7,23 @@
|
|||||||
//
|
//
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// Break all of the critical edges in the CFG by inserting a dummy basic block.
|
// Helper function to break a critical machine edge.
|
||||||
// This pass may be "required" by passes that cannot deal with critical edges.
|
|
||||||
// Notice that this pass invalidates the CFG, because the same BasicBlock is
|
|
||||||
// used as parameter for the src MachineBasicBlock and the new dummy
|
|
||||||
// MachineBasicBlock.
|
|
||||||
//
|
//
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#ifndef LLVM_CODEGEN_ASMPRINTER_H
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#define LLVM_CODEGEN_ASMPRINTER_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
|
||||||
using namespace llvm;
|
namespace llvm {
|
||||||
|
|
||||||
namespace {
|
MachineBasicBlock* SplitCriticalMachineEdge(MachineBasicBlock* src,
|
||||||
struct VISIBILITY_HIDDEN BreakCriticalMachineEdges :
|
MachineBasicBlock* dst) {
|
||||||
public MachineFunctionPass {
|
|
||||||
static char ID; // Pass identification
|
|
||||||
BreakCriticalMachineEdges() : MachineFunctionPass((intptr_t)&ID) {}
|
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction& Fn);
|
|
||||||
void splitCriticalEdge(MachineBasicBlock* A, MachineBasicBlock* B);
|
|
||||||
};
|
|
||||||
|
|
||||||
char BreakCriticalMachineEdges::ID = 0;
|
|
||||||
RegisterPass<BreakCriticalMachineEdges> X("critical-machine-edges",
|
|
||||||
"Break critical machine code edges");
|
|
||||||
}
|
|
||||||
|
|
||||||
const PassInfo *llvm::BreakCriticalMachineEdgesID = X.getPassInfo();
|
|
||||||
|
|
||||||
void BreakCriticalMachineEdges::splitCriticalEdge(MachineBasicBlock* src,
|
|
||||||
MachineBasicBlock* dst) {
|
|
||||||
const BasicBlock* srcBB = src->getBasicBlock();
|
const BasicBlock* srcBB = src->getBasicBlock();
|
||||||
|
|
||||||
MachineBasicBlock* crit_mbb = new MachineBasicBlock(srcBB);
|
MachineBasicBlock* crit_mbb = new MachineBasicBlock(srcBB);
|
||||||
@@ -106,26 +85,10 @@ void BreakCriticalMachineEdges::splitCriticalEdge(MachineBasicBlock* src,
|
|||||||
mii->getOperand(u).getMachineBasicBlock() == src)
|
mii->getOperand(u).getMachineBasicBlock() == src)
|
||||||
mii->getOperand(u).setMachineBasicBlock(crit_mbb);
|
mii->getOperand(u).setMachineBasicBlock(crit_mbb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return crit_mbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BreakCriticalMachineEdges::runOnMachineFunction(MachineFunction& F) {
|
|
||||||
std::vector<MachineBasicBlock *> SourceBlocks;
|
|
||||||
std::vector<MachineBasicBlock *> DestBlocks;
|
|
||||||
|
|
||||||
for(MachineFunction::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
|
|
||||||
for(MachineBasicBlock::succ_iterator SI = FI->succ_begin(),
|
|
||||||
SE = FI->succ_end(); SI != SE; ++SI) {
|
|
||||||
// predecessor with multiple successors, successor with multiple
|
|
||||||
// predecessors.
|
|
||||||
if (FI->succ_size() > 1 && (*SI)->pred_size() > 1) {
|
|
||||||
SourceBlocks.push_back(FI);
|
|
||||||
DestBlocks.push_back(*SI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned u = 0; u < SourceBlocks.size(); u++)
|
|
||||||
splitCriticalEdge(SourceBlocks[u], DestBlocks[u]);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -58,10 +58,6 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
extern const PassInfo *SimpleRegisterCoalescingID;
|
extern const PassInfo *SimpleRegisterCoalescingID;
|
||||||
|
|
||||||
/// BreakCriticalMachineEdges pass. Breaks critical edges between
|
|
||||||
/// machine basic blocks.
|
|
||||||
extern const PassInfo *BreakCriticalMachineEdgesID;
|
|
||||||
|
|
||||||
/// TwoAddressInstruction pass - This pass reduces two-address instructions to
|
/// TwoAddressInstruction pass - This pass reduces two-address instructions to
|
||||||
/// use two operands. This destroys SSA information but it is desired by
|
/// use two operands. This destroys SSA information but it is desired by
|
||||||
/// register allocators.
|
/// register allocators.
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#define DEBUG_TYPE "strongphielim"
|
#define DEBUG_TYPE "strongphielim"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
|
#include "llvm/CodeGen/BreakCriticalMachineEdge.h"
|
||||||
#include "llvm/CodeGen/LiveVariables.h"
|
#include "llvm/CodeGen/LiveVariables.h"
|
||||||
#include "llvm/CodeGen/MachineDominators.h"
|
#include "llvm/CodeGen/MachineDominators.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
|
@@ -70,7 +70,6 @@ void TwoAddressInstructionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
AU.addRequired<LiveVariables>();
|
AU.addRequired<LiveVariables>();
|
||||||
AU.addPreserved<LiveVariables>();
|
AU.addPreserved<LiveVariables>();
|
||||||
AU.addPreservedID(PHIEliminationID);
|
AU.addPreservedID(PHIEliminationID);
|
||||||
AU.addPreservedID(BreakCriticalMachineEdgesID);
|
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user