[PATCH] D71038: [GlobalISel] Localizer: Allow targets not to run the pass conditionally

Volkan Keles via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 11:11:45 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfa3d260b823: [GlobalISel] Localizer: Allow targets not to run the pass conditionally (authored by volkan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71038/new/

https://reviews.llvm.org/D71038

Files:
  llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
  llvm/lib/CodeGen/GlobalISel/Localizer.cpp


Index: llvm/lib/CodeGen/GlobalISel/Localizer.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/Localizer.cpp
+++ llvm/lib/CodeGen/GlobalISel/Localizer.cpp
@@ -29,7 +29,11 @@
                     "Move/duplicate certain instructions close to their use",
                     false, false)
 
-Localizer::Localizer() : MachineFunctionPass(ID) { }
+Localizer::Localizer(std::function<bool(const MachineFunction &)> F)
+    : MachineFunctionPass(ID), DoNotRunPass(F) {}
+
+Localizer::Localizer()
+    : Localizer([](const MachineFunction &) { return false; }) {}
 
 void Localizer::init(MachineFunction &MF) {
   MRI = &MF.getRegInfo();
@@ -212,6 +216,10 @@
           MachineFunctionProperties::Property::FailedISel))
     return false;
 
+  // Don't run the pass if the target asked so.
+  if (DoNotRunPass(MF))
+    return false;
+
   LLVM_DEBUG(dbgs() << "Localize instructions for: " << MF.getName() << '\n');
 
   init(MF);
Index: llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
+++ llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
@@ -42,6 +42,10 @@
   static char ID;
 
 private:
+  /// An input function to decide if the pass should run or not
+  /// on the given MachineFunction.
+  std::function<bool(const MachineFunction &)> DoNotRunPass;
+
   /// MRI contains all the register class/bank information that this
   /// pass uses and updates.
   MachineRegisterInfo *MRI;
@@ -72,6 +76,7 @@
 
 public:
   Localizer();
+  Localizer(std::function<bool(const MachineFunction &)>);
 
   StringRef getPassName() const override { return "Localizer"; }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71038.232407.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191205/c503b442/attachment.bin>


More information about the llvm-commits mailing list