aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2009-10-28 20:46:46 +0000
committerBob Wilson <bob.wilson@apple.com>2009-10-28 20:46:46 +0000
commita597103c328e29fb763e7a4864bd7c29a588fc9d (patch)
tree2702bfc45043f38e63b17dde5931cc522db8fd66 /lib/CodeGen
parent90f48e7c91a8faa875ba889ca66b137ffd46e34a (diff)
downloadexternal_llvm-a597103c328e29fb763e7a4864bd7c29a588fc9d.zip
external_llvm-a597103c328e29fb763e7a4864bd7c29a588fc9d.tar.gz
external_llvm-a597103c328e29fb763e7a4864bd7c29a588fc9d.tar.bz2
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/BranchFolding.cpp14
-rw-r--r--lib/CodeGen/BranchFolding.h10
-rw-r--r--lib/CodeGen/IfConversion.cpp13
-rw-r--r--lib/CodeGen/LLVMTargetMachine.cpp2
4 files changed, 15 insertions, 24 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index 11777d5..66c5aa5 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/lib/CodeGen/BranchFolding.cpp
@@ -50,9 +50,8 @@ TailMergeThreshold("tail-merge-threshold",
char BranchFolderPass::ID = 0;
-FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge,
- CodeGenOpt::Level OptLevel) {
- return new BranchFolderPass(DefaultEnableTailMerge, OptLevel);
+FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) {
+ return new BranchFolderPass(DefaultEnableTailMerge);
}
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
@@ -64,8 +63,7 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
-BranchFolder::BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL) {
- OptLevel = OL;
+BranchFolder::BranchFolder(bool defaultEnableTailMerge) {
switch (FlagEnableTailMerge) {
case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
case cl::BOU_TRUE: EnableTailMerge = true; break;
@@ -472,8 +470,7 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
I->second,
TrialBBI1, TrialBBI2);
// If we will have to split a block, there should be at least
- // minCommonTailLength instructions in common; if not, and if we are not
- // optimizing for performance at the expense of code size, at worst
+ // minCommonTailLength instructions in common; if not, at worst
// we will be replacing a fallthrough into the common tail with a
// branch, which at worst breaks even with falling through into
// 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.
// (Empty blocks will get forwarded and need not be considered.)
if (CommonTailLen >= minCommonTailLength ||
- (OptLevel != CodeGenOpt::Aggressive &&
- CommonTailLen > 0 &&
+ (CommonTailLen > 0 &&
(TrialBBI1==CurMPIter->second->begin() ||
TrialBBI2==I->second->begin()))) {
if (CommonTailLen > maxCommonTailLength) {
diff --git a/lib/CodeGen/BranchFolding.h b/lib/CodeGen/BranchFolding.h
index 5d35525..9763e33 100644
--- a/lib/CodeGen/BranchFolding.h
+++ b/lib/CodeGen/BranchFolding.h
@@ -12,7 +12,6 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/Target/TargetMachine.h"
#include <vector>
namespace llvm {
@@ -24,7 +23,7 @@ namespace llvm {
class BranchFolder {
public:
- explicit BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL);
+ explicit BranchFolder(bool defaultEnableTailMerge);
bool OptimizeFunction(MachineFunction &MF,
const TargetInstrInfo *tii,
@@ -38,7 +37,6 @@ namespace llvm {
typedef std::pair<MPIterator, MachineBasicBlock::iterator> SameTailElt;
std::vector<SameTailElt> SameTails;
- CodeGenOpt::Level OptLevel;
bool EnableTailMerge;
const TargetInstrInfo *TII;
const TargetRegisterInfo *TRI;
@@ -75,10 +73,8 @@ namespace llvm {
public BranchFolder {
public:
static char ID;
- explicit BranchFolderPass(bool defaultEnableTailMerge,
- CodeGenOpt::Level OptLevel)
- : MachineFunctionPass(&ID),
- BranchFolder(defaultEnableTailMerge, OptLevel) {}
+ explicit BranchFolderPass(bool defaultEnableTailMerge)
+ : MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {}
virtual bool runOnMachineFunction(MachineFunction &MF);
virtual const char *getPassName() const { return "Control Flow Optimizer"; }
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp
index be9e1f1..45f08b1 100644
--- a/lib/CodeGen/IfConversion.cpp
+++ b/lib/CodeGen/IfConversion.cpp
@@ -148,11 +148,9 @@ namespace {
const TargetInstrInfo *TII;
bool MadeChange;
int FnNum;
- CodeGenOpt::Level OptLevel;
public:
static char ID;
- IfConverter(CodeGenOpt::Level OL) :
- MachineFunctionPass(&ID), FnNum(-1), OptLevel(OL) {}
+ IfConverter() : MachineFunctionPass(&ID), FnNum(-1) {}
virtual bool runOnMachineFunction(MachineFunction &MF);
virtual const char *getPassName() const { return "If Converter"; }
@@ -221,9 +219,10 @@ namespace {
char IfConverter::ID = 0;
}
-FunctionPass *llvm::createIfConverterPass(CodeGenOpt::Level OptLevel) {
- return new IfConverter(OptLevel);
-}
+static RegisterPass<IfConverter>
+X("if-converter", "If Converter");
+
+FunctionPass *llvm::createIfConverterPass() { return new IfConverter(); }
bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
TLI = MF.getTarget().getTargetLowering();
@@ -363,7 +362,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
BBAnalysis.clear();
if (MadeChange) {
- BranchFolder BF(false, OptLevel);
+ BranchFolder BF(false);
BF.OptimizeFunction(MF, TII,
MF.getTarget().getRegisterInfo(),
getAnalysisIfAvailable<MachineModuleInfo>());
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp
index 1a2daef..e58a9ca 100644
--- a/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/lib/CodeGen/LLVMTargetMachine.cpp
@@ -329,7 +329,7 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
// Branch folding must be run after regalloc and prolog/epilog insertion.
if (OptLevel != CodeGenOpt::None) {
- PM.add(createBranchFoldingPass(getEnableTailMergeDefault(), OptLevel));
+ PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
printAndVerify(PM);
}