mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Revert r85346 change to control tail merging by CodeGenOpt::Level.
I'm going to redo this using the OptimizeForSize function attribute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85426 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -127,11 +127,10 @@ namespace llvm {
|
|||||||
/// optimizations to delete branches to branches, eliminate branches to
|
/// optimizations to delete branches to branches, eliminate branches to
|
||||||
/// successor blocks (creating fall throughs), and eliminating branches over
|
/// successor blocks (creating fall throughs), and eliminating branches over
|
||||||
/// branches.
|
/// branches.
|
||||||
FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge,
|
FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
|
||||||
CodeGenOpt::Level OptLevel);
|
|
||||||
|
|
||||||
/// IfConverter Pass - This pass performs machine code if-conversion.
|
/// IfConverter Pass - This pass performs machine code if conversion.
|
||||||
FunctionPass *createIfConverterPass(CodeGenOpt::Level OptLevel);
|
FunctionPass *createIfConverterPass();
|
||||||
|
|
||||||
/// Code Placement Pass - This pass optimize code placement and aligns loop
|
/// Code Placement Pass - This pass optimize code placement and aligns loop
|
||||||
/// headers to target specific alignment boundary.
|
/// headers to target specific alignment boundary.
|
||||||
|
@ -50,9 +50,8 @@ TailMergeThreshold("tail-merge-threshold",
|
|||||||
|
|
||||||
char BranchFolderPass::ID = 0;
|
char BranchFolderPass::ID = 0;
|
||||||
|
|
||||||
FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge,
|
FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) {
|
||||||
CodeGenOpt::Level OptLevel) {
|
return new BranchFolderPass(DefaultEnableTailMerge);
|
||||||
return new BranchFolderPass(DefaultEnableTailMerge, OptLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
||||||
@ -64,8 +63,7 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
BranchFolder::BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL) {
|
BranchFolder::BranchFolder(bool defaultEnableTailMerge) {
|
||||||
OptLevel = OL;
|
|
||||||
switch (FlagEnableTailMerge) {
|
switch (FlagEnableTailMerge) {
|
||||||
case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
|
case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
|
||||||
case cl::BOU_TRUE: EnableTailMerge = true; break;
|
case cl::BOU_TRUE: EnableTailMerge = true; break;
|
||||||
@ -472,8 +470,7 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
|
|||||||
I->second,
|
I->second,
|
||||||
TrialBBI1, TrialBBI2);
|
TrialBBI1, TrialBBI2);
|
||||||
// If we will have to split a block, there should be at least
|
// If we will have to split a block, there should be at least
|
||||||
// minCommonTailLength instructions in common; if not, and if we are not
|
// minCommonTailLength instructions in common; if not, at worst
|
||||||
// optimizing for performance at the expense of code size, at worst
|
|
||||||
// we will be replacing a fallthrough into the common tail with a
|
// we will be replacing a fallthrough into the common tail with a
|
||||||
// branch, which at worst breaks even with falling through into
|
// branch, which at worst breaks even with falling through into
|
||||||
// the duplicated common tail, so 1 instruction in common is enough.
|
// the duplicated common tail, so 1 instruction in common is enough.
|
||||||
@ -481,8 +478,7 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
|
|||||||
// tail if there is one.
|
// tail if there is one.
|
||||||
// (Empty blocks will get forwarded and need not be considered.)
|
// (Empty blocks will get forwarded and need not be considered.)
|
||||||
if (CommonTailLen >= minCommonTailLength ||
|
if (CommonTailLen >= minCommonTailLength ||
|
||||||
(OptLevel != CodeGenOpt::Aggressive &&
|
(CommonTailLen > 0 &&
|
||||||
CommonTailLen > 0 &&
|
|
||||||
(TrialBBI1==CurMPIter->second->begin() ||
|
(TrialBBI1==CurMPIter->second->begin() ||
|
||||||
TrialBBI2==I->second->begin()))) {
|
TrialBBI2==I->second->begin()))) {
|
||||||
if (CommonTailLen > maxCommonTailLength) {
|
if (CommonTailLen > maxCommonTailLength) {
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -24,7 +23,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class BranchFolder {
|
class BranchFolder {
|
||||||
public:
|
public:
|
||||||
explicit BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL);
|
explicit BranchFolder(bool defaultEnableTailMerge);
|
||||||
|
|
||||||
bool OptimizeFunction(MachineFunction &MF,
|
bool OptimizeFunction(MachineFunction &MF,
|
||||||
const TargetInstrInfo *tii,
|
const TargetInstrInfo *tii,
|
||||||
@ -38,7 +37,6 @@ namespace llvm {
|
|||||||
typedef std::pair<MPIterator, MachineBasicBlock::iterator> SameTailElt;
|
typedef std::pair<MPIterator, MachineBasicBlock::iterator> SameTailElt;
|
||||||
std::vector<SameTailElt> SameTails;
|
std::vector<SameTailElt> SameTails;
|
||||||
|
|
||||||
CodeGenOpt::Level OptLevel;
|
|
||||||
bool EnableTailMerge;
|
bool EnableTailMerge;
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
const TargetRegisterInfo *TRI;
|
const TargetRegisterInfo *TRI;
|
||||||
@ -75,10 +73,8 @@ namespace llvm {
|
|||||||
public BranchFolder {
|
public BranchFolder {
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit BranchFolderPass(bool defaultEnableTailMerge,
|
explicit BranchFolderPass(bool defaultEnableTailMerge)
|
||||||
CodeGenOpt::Level OptLevel)
|
: MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {}
|
||||||
: MachineFunctionPass(&ID),
|
|
||||||
BranchFolder(defaultEnableTailMerge, OptLevel) {}
|
|
||||||
|
|
||||||
virtual bool runOnMachineFunction(MachineFunction &MF);
|
virtual bool runOnMachineFunction(MachineFunction &MF);
|
||||||
virtual const char *getPassName() const { return "Control Flow Optimizer"; }
|
virtual const char *getPassName() const { return "Control Flow Optimizer"; }
|
||||||
|
@ -148,11 +148,9 @@ namespace {
|
|||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
bool MadeChange;
|
bool MadeChange;
|
||||||
int FnNum;
|
int FnNum;
|
||||||
CodeGenOpt::Level OptLevel;
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
IfConverter(CodeGenOpt::Level OL) :
|
IfConverter() : MachineFunctionPass(&ID), FnNum(-1) {}
|
||||||
MachineFunctionPass(&ID), FnNum(-1), OptLevel(OL) {}
|
|
||||||
|
|
||||||
virtual bool runOnMachineFunction(MachineFunction &MF);
|
virtual bool runOnMachineFunction(MachineFunction &MF);
|
||||||
virtual const char *getPassName() const { return "If Converter"; }
|
virtual const char *getPassName() const { return "If Converter"; }
|
||||||
@ -221,9 +219,10 @@ namespace {
|
|||||||
char IfConverter::ID = 0;
|
char IfConverter::ID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *llvm::createIfConverterPass(CodeGenOpt::Level OptLevel) {
|
static RegisterPass<IfConverter>
|
||||||
return new IfConverter(OptLevel);
|
X("if-converter", "If Converter");
|
||||||
}
|
|
||||||
|
FunctionPass *llvm::createIfConverterPass() { return new IfConverter(); }
|
||||||
|
|
||||||
bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
TLI = MF.getTarget().getTargetLowering();
|
TLI = MF.getTarget().getTargetLowering();
|
||||||
@ -363,7 +362,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
BBAnalysis.clear();
|
BBAnalysis.clear();
|
||||||
|
|
||||||
if (MadeChange) {
|
if (MadeChange) {
|
||||||
BranchFolder BF(false, OptLevel);
|
BranchFolder BF(false);
|
||||||
BF.OptimizeFunction(MF, TII,
|
BF.OptimizeFunction(MF, TII,
|
||||||
MF.getTarget().getRegisterInfo(),
|
MF.getTarget().getRegisterInfo(),
|
||||||
getAnalysisIfAvailable<MachineModuleInfo>());
|
getAnalysisIfAvailable<MachineModuleInfo>());
|
||||||
|
@ -329,7 +329,7 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
|
|||||||
|
|
||||||
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
// Branch folding must be run after regalloc and prolog/epilog insertion.
|
||||||
if (OptLevel != CodeGenOpt::None) {
|
if (OptLevel != CodeGenOpt::None) {
|
||||||
PM.add(createBranchFoldingPass(getEnableTailMergeDefault(), OptLevel));
|
PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
|
||||||
printAndVerify(PM);
|
printAndVerify(PM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM,
|
|||||||
CodeGenOpt::Level OptLevel) {
|
CodeGenOpt::Level OptLevel) {
|
||||||
// FIXME: temporarily disabling load / store optimization pass for Thumb1.
|
// FIXME: temporarily disabling load / store optimization pass for Thumb1.
|
||||||
if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
|
if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
|
||||||
PM.add(createIfConverterPass(OptLevel));
|
PM.add(createIfConverterPass());
|
||||||
|
|
||||||
if (Subtarget.isThumb2()) {
|
if (Subtarget.isThumb2()) {
|
||||||
PM.add(createThumb2ITBlockPass());
|
PM.add(createThumb2ITBlockPass());
|
||||||
|
Reference in New Issue
Block a user