[llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp LLVMTargetMachine.cpp
Dale Johannesen
dalej at apple.com
Tue May 22 10:15:25 PDT 2007
Changes in directory llvm/lib/CodeGen:
BranchFolding.cpp updated: 1.54 -> 1.55
LLVMTargetMachine.cpp updated: 1.12 -> 1.13
---
Log message:
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.
---
Diffs of the changes: (+15 -6)
BranchFolding.cpp | 17 +++++++++++++----
LLVMTargetMachine.cpp | 4 ++--
2 files changed, 15 insertions(+), 6 deletions(-)
Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.54 llvm/lib/CodeGen/BranchFolding.cpp:1.55
--- llvm/lib/CodeGen/BranchFolding.cpp:1.54 Thu May 17 20:28:58 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp Tue May 22 12:14:46 2007
@@ -35,12 +35,19 @@
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 @@
bool MadeChange;
private:
// Tail Merging.
+ bool EnableTailMerge;
bool TailMergeBlocks(MachineFunction &MF);
bool TryMergeBlocks(MachineBasicBlock* SuccBB,
MachineBasicBlock* PredBB);
@@ -79,7 +87,8 @@
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.
Index: llvm/lib/CodeGen/LLVMTargetMachine.cpp
diff -u llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.12 llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.13
--- llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.12 Fri Mar 30 23:18:03 2007
+++ llvm/lib/CodeGen/LLVMTargetMachine.cpp Tue May 22 12:14:46 2007
@@ -78,7 +78,7 @@
// 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 @@
// 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));
More information about the llvm-commits
mailing list