[llvm-branch-commits] [llvm-branch] r85348 - in /llvm/branches/Apple/Leela: 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

Bill Wendling isanbard at gmail.com
Tue Oct 27 16:56:21 PDT 2009


Author: void
Date: Tue Oct 27 18:56:21 2009
New Revision: 85348

URL: http://llvm.org/viewvc/llvm-project?rev=85348&view=rev
Log:
$ svn merge -c 85346 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r85346 into '.':
U    include/llvm/CodeGen/Passes.h
U    lib/CodeGen/LLVMTargetMachine.cpp
U    lib/CodeGen/BranchFolding.cpp
U    lib/CodeGen/IfConversion.cpp
U    lib/CodeGen/BranchFolding.h
U    lib/Target/ARM/ARMTargetMachine.cpp


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

Modified: llvm/branches/Apple/Leela/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/CodeGen/Passes.h?rev=85348&r1=85347&r2=85348&view=diff

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

Modified: llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp?rev=85348&r1=85347&r2=85348&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp Tue Oct 27 18:56:21 2009
@@ -50,8 +50,9 @@
 
 char BranchFolderPass::ID = 0;
 
-FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { 
-  return new BranchFolderPass(DefaultEnableTailMerge);
+FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge,
+                                            CodeGenOpt::Level OptLevel) { 
+  return new BranchFolderPass(DefaultEnableTailMerge, OptLevel);
 }
 
 bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
@@ -63,7 +64,8 @@
 
 
 
-BranchFolder::BranchFolder(bool defaultEnableTailMerge) {
+BranchFolder::BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL) {
+  OptLevel = OL;
   switch (FlagEnableTailMerge) {
   case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
   case cl::BOU_TRUE: EnableTailMerge = true; break;
@@ -470,7 +472,8 @@
                                         I->second,
                                         TrialBBI1, TrialBBI2);
       // If we will have to split a block, there should be at least
-      // minCommonTailLength instructions in common; if not, at worst
+      // minCommonTailLength instructions in common; if not, and if we are not
+      // optimizing for performance at the expense of code size, 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.
@@ -478,7 +481,8 @@
       // tail if there is one.
       // (Empty blocks will get forwarded and need not be considered.)
       if (CommonTailLen >= minCommonTailLength ||
-          (CommonTailLen > 0 &&
+          (OptLevel != CodeGenOpt::Aggressive &&
+           CommonTailLen > 0 &&
            (TrialBBI1==CurMPIter->second->begin() ||
             TrialBBI2==I->second->begin()))) {
         if (CommonTailLen > maxCommonTailLength) {

Modified: llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.h?rev=85348&r1=85347&r2=85348&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.h (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.h Tue Oct 27 18:56:21 2009
@@ -12,6 +12,7 @@
 
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/Target/TargetMachine.h"
 #include <vector>
 
 namespace llvm {
@@ -23,7 +24,7 @@
 
   class BranchFolder {
   public:
-    explicit BranchFolder(bool defaultEnableTailMerge);
+    explicit BranchFolder(bool defaultEnableTailMerge, CodeGenOpt::Level OL);
 
     bool OptimizeFunction(MachineFunction &MF,
                           const TargetInstrInfo *tii,
@@ -37,6 +38,7 @@
     typedef std::pair<MPIterator, MachineBasicBlock::iterator> SameTailElt;
     std::vector<SameTailElt> SameTails;
 
+    CodeGenOpt::Level OptLevel;
     bool EnableTailMerge;
     const TargetInstrInfo *TII;
     const TargetRegisterInfo *TRI;
@@ -73,8 +75,10 @@
                            public BranchFolder {
   public:
     static char ID;
-    explicit BranchFolderPass(bool defaultEnableTailMerge)
-      :  MachineFunctionPass(&ID), BranchFolder(defaultEnableTailMerge) {}
+    explicit BranchFolderPass(bool defaultEnableTailMerge,
+                              CodeGenOpt::Level OptLevel)
+      :  MachineFunctionPass(&ID),
+      BranchFolder(defaultEnableTailMerge, OptLevel) {}
 
     virtual bool runOnMachineFunction(MachineFunction &MF);
     virtual const char *getPassName() const { return "Control Flow Optimizer"; }

Modified: llvm/branches/Apple/Leela/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/IfConversion.cpp?rev=85348&r1=85347&r2=85348&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/IfConversion.cpp Tue Oct 27 18:56:21 2009
@@ -148,9 +148,11 @@
     const TargetInstrInfo *TII;
     bool MadeChange;
     int FnNum;
+    CodeGenOpt::Level OptLevel;
   public:
     static char ID;
-    IfConverter() : MachineFunctionPass(&ID), FnNum(-1) {}
+    IfConverter(CodeGenOpt::Level OL) :
+      MachineFunctionPass(&ID), FnNum(-1), OptLevel(OL) {}
 
     virtual bool runOnMachineFunction(MachineFunction &MF);
     virtual const char *getPassName() const { return "If Converter"; }
@@ -219,10 +221,9 @@
   char IfConverter::ID = 0;
 }
 
-static RegisterPass<IfConverter>
-X("if-converter", "If Converter");
-
-FunctionPass *llvm::createIfConverterPass() { return new IfConverter(); }
+FunctionPass *llvm::createIfConverterPass(CodeGenOpt::Level OptLevel) {
+  return new IfConverter(OptLevel);
+}
 
 bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
   TLI = MF.getTarget().getTargetLowering();
@@ -362,7 +363,7 @@
   BBAnalysis.clear();
 
   if (MadeChange) {
-    BranchFolder BF(false);
+    BranchFolder BF(false, OptLevel);
     BF.OptimizeFunction(MF, TII,
                         MF.getTarget().getRegisterInfo(),
                         getAnalysisIfAvailable<MachineModuleInfo>());

Modified: llvm/branches/Apple/Leela/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/LLVMTargetMachine.cpp?rev=85348&r1=85347&r2=85348&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/LLVMTargetMachine.cpp Tue Oct 27 18:56:21 2009
@@ -329,7 +329,7 @@
 
   // Branch folding must be run after regalloc and prolog/epilog insertion.
   if (OptLevel != CodeGenOpt::None) {
-    PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
+    PM.add(createBranchFoldingPass(getEnableTailMergeDefault(), OptLevel));
     printAndVerify(PM);
   }
 

Modified: llvm/branches/Apple/Leela/lib/Target/ARM/ARMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Target/ARM/ARMTargetMachine.cpp?rev=85348&r1=85347&r2=85348&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Target/ARM/ARMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Target/ARM/ARMTargetMachine.cpp Tue Oct 27 18:56:21 2009
@@ -114,7 +114,7 @@
                                           CodeGenOpt::Level OptLevel) {
   // FIXME: temporarily disabling load / store optimization pass for Thumb1.
   if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
-    PM.add(createIfConverterPass());
+    PM.add(createIfConverterPass(OptLevel));
 
   if (Subtarget.isThumb2()) {
     PM.add(createThumb2ITBlockPass());





More information about the llvm-branch-commits mailing list