aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-05-22 17:14:46 +0000
committerDale Johannesen <dalej@apple.com>2007-05-22 17:14:46 +0000
commit81da02b553b86868637f27b89c6e919c31ed5b51 (patch)
treea5026c04264ed6e37a5d7da17c8e0b9d4935d8d6 /lib/CodeGen
parent9621921acb971aa5c30a4800dd99538361c45eba (diff)
Make tail merging the default, except on powerPC. There was no prior art
for a target-dependent default with a command-line override; this way should be generally usable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/BranchFolding.cpp17
-rw-r--r--lib/CodeGen/LLVMTargetMachine.cpp4
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index d8ec340692..7cc4c2db79 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/lib/CodeGen/BranchFolding.cpp
@@ -35,12 +35,19 @@ using namespace llvm;
STATISTIC(NumDeadBlocks, "Number of dead blocks removed");
STATISTIC(NumBranchOpts, "Number of branches optimized");
STATISTIC(NumTailMerge , "Number of block tails merged");
-static cl::opt<bool> EnableTailMerge("enable-tail-merge", cl::Hidden);
-
+static cl::opt<cl::boolOrDefault> FlagEnableTailMerge("enable-tail-merge",
+ cl::init(cl::BOU_UNSET), cl::Hidden);
namespace {
struct BranchFolder : public MachineFunctionPass {
static char ID;
- BranchFolder() : MachineFunctionPass((intptr_t)&ID) {}
+ BranchFolder(bool defaultEnableTailMerge) :
+ MachineFunctionPass((intptr_t)&ID) {
+ switch (FlagEnableTailMerge) {
+ case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
+ case cl::BOU_TRUE: EnableTailMerge = true; break;
+ case cl::BOU_FALSE: EnableTailMerge = false; break;
+ }
+ }
virtual bool runOnMachineFunction(MachineFunction &MF);
virtual const char *getPassName() const { return "Control Flow Optimizer"; }
@@ -49,6 +56,7 @@ namespace {
bool MadeChange;
private:
// Tail Merging.
+ bool EnableTailMerge;
bool TailMergeBlocks(MachineFunction &MF);
bool TryMergeBlocks(MachineBasicBlock* SuccBB,
MachineBasicBlock* PredBB);
@@ -79,7 +87,8 @@ static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
bool isCond,
MachineFunction::iterator FallThru);
-FunctionPass *llvm::createBranchFoldingPass() { return new BranchFolder(); }
+FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) {
+ return new BranchFolder(DefaultEnableTailMerge); }
/// RemoveDeadBlock - Remove the specified dead machine basic block from the
/// function, updating the CFG.
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp
index 34c45f3135..41f7e199a0 100644
--- a/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/lib/CodeGen/LLVMTargetMachine.cpp
@@ -78,7 +78,7 @@ LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM,
// Branch folding must be run after regalloc and prolog/epilog insertion.
if (!Fast)
- PM.add(createBranchFoldingPass());
+ PM.add(createBranchFoldingPass(DoTailMergeDefault()));
// Fold redundant debug labels.
PM.add(createDebugLabelFoldingPass());
@@ -181,7 +181,7 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
// Branch folding must be run after regalloc and prolog/epilog insertion.
if (!Fast)
- PM.add(createBranchFoldingPass());
+ PM.add(createBranchFoldingPass(DoTailMergeDefault()));
if (addPreEmitPass(PM, Fast) && PrintMachineCode)
PM.add(createMachineFunctionPrinterPass(cerr));