llvm.org GIT mirror llvm / a597103
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 Bob Wilson 10 years ago
6 changed file(s) with 19 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
126126 /// optimizations to delete branches to branches, eliminate branches to
127127 /// successor blocks (creating fall throughs), and eliminating branches over
128128 /// branches.
129 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge,
130 CodeGenOpt::Level OptLevel);
129 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
131130
132 /// IfConverter Pass - This pass performs machine code if-conversion.
133 FunctionPass *createIfConverterPass(CodeGenOpt::Level OptLevel);
131 /// IfConverter Pass - This pass performs machine code if conversion.
132 FunctionPass *createIfConverterPass();
134133
135134 /// Code Placement Pass - This pass optimize code placement and aligns loop
136135 /// headers to target specific alignment boundary.
4949
5050 char BranchFolderPass::ID = 0;
5151
52 FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge,
53 CodeGenOpt::Level OptLevel) {
54 return new BranchFolderPass(DefaultEnableTailMerge, OptLevel);
52 FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) {
53 return new BranchFolderPass(DefaultEnableTailMerge);
5554 }
5655
5756 bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
6362
6463
6564
66 BranchFolder::BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL) {
67 OptLevel = OL;
65 BranchFolder::BranchFolder(bool defaultEnableTailMerge) {
6866 switch (FlagEnableTailMerge) {
6967 case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
7068 case cl::BOU_TRUE: EnableTailMerge = true; break;
471469 I->second,
472470 TrialBBI1, TrialBBI2);
473471 // If we will have to split a block, there should be at least
474 // minCommonTailLength instructions in common; if not, and if we are not
475 // optimizing for performance at the expense of code size, at worst
472 // minCommonTailLength instructions in common; if not, at worst
476473 // we will be replacing a fallthrough into the common tail with a
477474 // branch, which at worst breaks even with falling through into
478475 // the duplicated common tail, so 1 instruction in common is enough.
480477 // tail if there is one.
481478 // (Empty blocks will get forwarded and need not be considered.)
482479 if (CommonTailLen >= minCommonTailLength ||
483 (OptLevel != CodeGenOpt::Aggressive &&
484 CommonTailLen > 0 &&
480 (CommonTailLen > 0 &&
485481 (TrialBBI1==CurMPIter->second->begin() ||
486482 TrialBBI2==I->second->begin()))) {
487483 if (CommonTailLen > maxCommonTailLength) {
1111
1212 #include "llvm/CodeGen/MachineBasicBlock.h"
1313 #include "llvm/CodeGen/MachineFunctionPass.h"
14 #include "llvm/Target/TargetMachine.h"
1514 #include
1615
1716 namespace llvm {
2322
2423 class BranchFolder {
2524 public:
26 explicit BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL);
25 explicit BranchFolder(bool defaultEnableTailMerge);
2726
2827 bool OptimizeFunction(MachineFunction &MF,
2928 const TargetInstrInfo *tii,
3736 typedef std::pair SameTailElt;
3837 std::vector SameTails;
3938
40 CodeGenOpt::Level OptLevel;
4139 bool EnableTailMerge;
4240 const TargetInstrInfo *TII;
4341 const TargetRegisterInfo *TRI;
7472 public BranchFolder {
7573 public:
7674 static char ID;
77 explicit BranchFolderPass(bool defaultEnableTailMerge,
78 CodeGenOpt::Level OptLevel)
79 : MachineFunctionPass(&ID),
80 BranchFolder(defaultEnableTailMerge, OptLevel) {}
75 explicit BranchFolderPass(bool defaultEnableTailMerge)
76 : MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {}
8177
8278 virtual bool runOnMachineFunction(MachineFunction &MF);
8379 virtual const char *getPassName() const { return "Control Flow Optimizer"; }
147147 const TargetInstrInfo *TII;
148148 bool MadeChange;
149149 int FnNum;
150 CodeGenOpt::Level OptLevel;
151150 public:
152151 static char ID;
153 IfConverter(CodeGenOpt::Level OL) :
154 MachineFunctionPass(&ID), FnNum(-1), OptLevel(OL) {}
152 IfConverter() : MachineFunctionPass(&ID), FnNum(-1) {}
155153
156154 virtual bool runOnMachineFunction(MachineFunction &MF);
157155 virtual const char *getPassName() const { return "If Converter"; }
220218 char IfConverter::ID = 0;
221219 }
222220
223 FunctionPass *llvm::createIfConverterPass(CodeGenOpt::Level OptLevel) {
224 return new IfConverter(OptLevel);
225 }
221 static RegisterPass
222 X("if-converter", "If Converter");
223
224 FunctionPass *llvm::createIfConverterPass() { return new IfConverter(); }
226225
227226 bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
228227 TLI = MF.getTarget().getTargetLowering();
362361 BBAnalysis.clear();
363362
364363 if (MadeChange) {
365 BranchFolder BF(false, OptLevel);
364 BranchFolder BF(false);
366365 BF.OptimizeFunction(MF, TII,
367366 MF.getTarget().getRegisterInfo(),
368367 getAnalysisIfAvailable());
328328
329329 // Branch folding must be run after regalloc and prolog/epilog insertion.
330330 if (OptLevel != CodeGenOpt::None) {
331 PM.add(createBranchFoldingPass(getEnableTailMergeDefault(), OptLevel));
331 PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
332332 printAndVerify(PM);
333333 }
334334
112112 CodeGenOpt::Level OptLevel) {
113113 // FIXME: temporarily disabling load / store optimization pass for Thumb1.
114114 if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
115 PM.add(createIfConverterPass(OptLevel));
115 PM.add(createIfConverterPass());
116116
117117 if (Subtarget.isThumb2()) {
118118 PM.add(createThumb2ITBlockPass());