[llvm-commits] [llvm] r85426 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp lib/CodeGen/LLVMTargetMachine.cpp lib/Target/ARM/ARMTargetMachine.cpp

Bob Wilson bob.wilson at apple.com
Wed Oct 28 13:46:46 PDT 2009


Author: bwilson
Date: Wed Oct 28 15:46:46 2009
New Revision: 85426

URL: http://llvm.org/viewvc/llvm-project?rev=85426&view=rev
Log:
Revert r85346 change to control tail merging by CodeGenOpt::Level.
I'm going to redo this using the OptimizeForSize function attribute.

Modified:
    llvm/trunk/include/llvm/CodeGen/Passes.h
    llvm/trunk/lib/CodeGen/BranchFolding.cpp
    llvm/trunk/lib/CodeGen/BranchFolding.h
    llvm/trunk/lib/CodeGen/IfConversion.cpp
    llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
    llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp

Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=85426&r1=85425&r2=85426&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Wed Oct 28 15:46:46 2009
@@ -127,11 +127,10 @@
   /// optimizations to delete branches to branches, eliminate branches to
   /// successor blocks (creating fall throughs), and eliminating branches over
   /// branches.
-  FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge,
-                                        CodeGenOpt::Level OptLevel);
+  FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
 
-  /// IfConverter Pass - This pass performs machine code if-conversion.
-  FunctionPass *createIfConverterPass(CodeGenOpt::Level OptLevel);
+  /// IfConverter Pass - This pass performs machine code if conversion.
+  FunctionPass *createIfConverterPass();
 
   /// Code Placement Pass - This pass optimize code placement and aligns loop
   /// headers to target specific alignment boundary.

Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=85426&r1=85425&r2=85426&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Oct 28 15:46:46 2009
@@ -50,9 +50,8 @@
 
 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 @@
 
 
 
-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 @@
                                         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 @@
       // 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) {

Modified: llvm/trunk/lib/CodeGen/BranchFolding.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=85426&r1=85425&r2=85426&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.h (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.h Wed Oct 28 15:46:46 2009
@@ -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 @@
 
   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 @@
     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 @@
                            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"; }

Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=85426&r1=85425&r2=85426&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Wed Oct 28 15:46:46 2009
@@ -148,11 +148,9 @@
     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 @@
   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 @@
   BBAnalysis.clear();
 
   if (MadeChange) {
-    BranchFolder BF(false, OptLevel);
+    BranchFolder BF(false);
     BF.OptimizeFunction(MF, TII,
                         MF.getTarget().getRegisterInfo(),
                         getAnalysisIfAvailable<MachineModuleInfo>());

Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=85426&r1=85425&r2=85426&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Wed Oct 28 15:46:46 2009
@@ -329,7 +329,7 @@
 
   // 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);
   }
 

Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=85426&r1=85425&r2=85426&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Wed Oct 28 15:46:46 2009
@@ -113,7 +113,7 @@
                                           CodeGenOpt::Level OptLevel) {
   // FIXME: temporarily disabling load / store optimization pass for Thumb1.
   if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
-    PM.add(createIfConverterPass(OptLevel));
+    PM.add(createIfConverterPass());
 
   if (Subtarget.isThumb2()) {
     PM.add(createThumb2ITBlockPass());





More information about the llvm-commits mailing list