[llvm] r245071 - Reverting patch r244235.

Kit Barton via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 09:54:32 PDT 2015


Author: kbarton
Date: Fri Aug 14 11:54:32 2015
New Revision: 245071

URL: http://llvm.org/viewvc/llvm-project?rev=245071&view=rev
Log:
Reverting patch r244235.

This patch will be redone in a different way. See
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150810/292978.html
for more details.

Modified:
    llvm/trunk/include/llvm/CodeGen/Passes.h
    llvm/trunk/lib/CodeGen/Passes.cpp
    llvm/trunk/lib/CodeGen/ShrinkWrap.cpp

Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=245071&r1=245070&r2=245071&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Aug 14 11:54:32 2015
@@ -120,6 +120,9 @@ protected:
   /// Default setting for -enable-tail-merge on this target.
   bool EnableTailMerge;
 
+  /// Default setting for -enable-shrink-wrap on this target.
+  bool EnableShrinkWrap;
+
 public:
   TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
   // Dummy constructor.
@@ -187,6 +190,9 @@ public:
   /// Return true if the optimized regalloc pipeline is enabled.
   bool getOptimizeRegAlloc() const;
 
+  /// Return true if shrink wrapping is enabled.
+  bool getEnableShrinkWrap() const;
+
   /// Return true if the default global register allocator is in use and
   /// has not be overriden on the command line with '-regalloc=...'
   bool usingDefaultRegAlloc() const;
@@ -355,14 +361,6 @@ protected:
   /// Add a pass to perform basic verification of the machine function if
   /// verification is enabled.
   void addVerifyPass(const std::string &Banner);
-
-  /// Create an instance of ShrinkWrap using the runShrinkWrap predicate
-  /// function.  
-  FunctionPass *createShrinkWrapPass();
-  
-  /// Predicate function passed to a ShrinkWrap object to determine if shrink
-  /// wrapping should be run on a MachineFunction.
-  virtual bool runShrinkWrap(const MachineFunction &Fn) const;
 };
 } // namespace llvm
 

Modified: llvm/trunk/lib/CodeGen/Passes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=245071&r1=245070&r2=245071&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/Passes.cpp (original)
+++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Aug 14 11:54:32 2015
@@ -56,6 +56,9 @@ static cl::opt<bool> DisableMachineLICM(
     cl::desc("Disable Machine LICM"));
 static cl::opt<bool> DisableMachineCSE("disable-machine-cse", cl::Hidden,
     cl::desc("Disable Machine Common Subexpression Elimination"));
+static cl::opt<cl::boolOrDefault>
+    EnableShrinkWrapOpt("enable-shrink-wrap", cl::Hidden,
+                        cl::desc("enable the shrink-wrapping pass"));
 static cl::opt<cl::boolOrDefault> OptimizeRegAlloc(
     "optimize-regalloc", cl::Hidden,
     cl::desc("Enable optimized register allocation compilation path."));
@@ -218,7 +221,7 @@ TargetPassConfig::TargetPassConfig(Targe
     : ImmutablePass(ID), PM(&pm), StartBefore(nullptr), StartAfter(nullptr),
       StopAfter(nullptr), Started(true), Stopped(false),
       AddingMachinePasses(false), TM(tm), Impl(nullptr), Initialized(false),
-      DisableVerify(false), EnableTailMerge(true) {
+      DisableVerify(false), EnableTailMerge(true), EnableShrinkWrap(false) {
 
   Impl = new PassConfigImpl();
 
@@ -540,8 +543,8 @@ void TargetPassConfig::addMachinePasses(
   addPostRegAlloc();
 
   // Insert prolog/epilog code.  Eliminate abstract frame index references...
-  if (getOptLevel() != CodeGenOpt::None)
-    addPass(createShrinkWrapPass());
+  if (getEnableShrinkWrap())
+    addPass(&ShrinkWrapID);
   addPass(&PrologEpilogCodeInserterID);
 
   /// Add passes that optimize machine instructions after register allocation.
@@ -620,6 +623,21 @@ void TargetPassConfig::addMachineSSAOpti
   addPass(&DeadMachineInstructionElimID);
 }
 
+bool TargetPassConfig::getEnableShrinkWrap() const {
+  switch (EnableShrinkWrapOpt) {
+  case cl::BOU_UNSET:
+    return EnableShrinkWrap && getOptLevel() != CodeGenOpt::None;
+  // If EnableShrinkWrap is set, it takes precedence on whatever the
+  // target sets. The rational is that we assume we want to test
+  // something related to shrink-wrapping.
+  case cl::BOU_TRUE:
+    return true;
+  case cl::BOU_FALSE:
+    return false;
+  }
+  llvm_unreachable("Invalid shrink-wrapping state");
+}
+
 //===---------------------------------------------------------------------===//
 /// Register Allocation Pass Configuration
 //===---------------------------------------------------------------------===//

Modified: llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShrinkWrap.cpp?rev=245071&r1=245070&r2=245071&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ShrinkWrap.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShrinkWrap.cpp Fri Aug 14 11:54:32 2015
@@ -68,16 +68,11 @@
 #include "llvm/Target/TargetInstrInfo.h"
 // To access TargetInstrInfo.
 #include "llvm/Target/TargetSubtargetInfo.h"
-#include "llvm/Support/CommandLine.h"
 
 #define DEBUG_TYPE "shrink-wrap"
 
 using namespace llvm;
 
-static cl::opt<cl::boolOrDefault>
-    EnableShrinkWrapOpt("enable-shrink-wrap", cl::Hidden,
-                        cl::desc("enable the shrink-wrapping pass"));
-
 STATISTIC(NumFunc, "Number of functions");
 STATISTIC(NumCandidates, "Number of shrink-wrapping candidates");
 STATISTIC(NumCandidatesDropped,
@@ -159,11 +154,6 @@ public:
   ShrinkWrap() : MachineFunctionPass(ID) {
     initializeShrinkWrapPass(*PassRegistry::getPassRegistry());
   }
-  
-  ShrinkWrap(std::function<bool(const MachineFunction &)> Ftor) :
-      MachineFunctionPass(ID), PredicateFtor(Ftor) {
-    initializeShrinkWrapPass(*PassRegistry::getPassRegistry());
-  }
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.setPreservesAll();
@@ -181,15 +171,6 @@ public:
   /// \brief Perform the shrink-wrapping analysis and update
   /// the MachineFrameInfo attached to \p MF with the results.
   bool runOnMachineFunction(MachineFunction &MF) override;
-
-private:
-  /// \brief Predicate function to determine if shrink wrapping should run.
-  ///
-  /// This function will be run at the beginning of shrink wrapping and
-  /// determine whether shrink wrapping should run on the given MachineFunction.
-  /// \arg MF The MachineFunction to run shrink wrapping on.
-  /// It returns true if shrink wrapping should be run, false otherwise.
-  std::function<bool(const MachineFunction &MF)> PredicateFtor;
 };
 } // End anonymous namespace.
 
@@ -338,12 +319,8 @@ void ShrinkWrap::updateSaveRestorePoints
 }
 
 bool ShrinkWrap::runOnMachineFunction(MachineFunction &MF) {
-  if (PredicateFtor && !PredicateFtor(MF)) 
+  if (MF.empty())
     return false;
-  
-  if (MF.empty() || skipOptnoneFunction(*MF.getFunction()))
-    return false;
-
   DEBUG(dbgs() << "**** Analysing " << MF.getName() << '\n');
 
   init(MF);
@@ -427,26 +404,3 @@ bool ShrinkWrap::runOnMachineFunction(Ma
   ++NumCandidates;
   return false;
 }
-
-/// If EnableShrinkWrap is set run shrink wrapping on the given Machine
-/// Function. Otherwise, shrink wrapping is disabled.
-/// This function can be overridden in each target-specific TargetPassConfig
-/// class to allow different predicate logic for each target. 
-bool TargetPassConfig::runShrinkWrap(const MachineFunction &Fn) const {
-  switch (EnableShrinkWrapOpt) {
-  case cl::BOU_TRUE:
-    return true;
-  case cl::BOU_UNSET:
-  case cl::BOU_FALSE:
-    return false;
-  }
-  llvm_unreachable("Invalid shrink-wrapping state");
-}
-
-/// Create a ShrinkWrap FunctionPass using the runShrinkWrap predicate
-/// function.
-FunctionPass *TargetPassConfig::createShrinkWrapPass() {
-  std::function<bool(const MachineFunction &Fn)> Ftor =
-    std::bind(&TargetPassConfig::runShrinkWrap, this, std::placeholders::_1);
-  return new ShrinkWrap(Ftor);
-}




More information about the llvm-commits mailing list