[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
Wed Dec 4 16:04:24 PST 2019


volkan created this revision.
volkan added a reviewer: qcolombet.
Herald added subscribers: Petar.Avramovic, hiraditya, rovka.
Herald added a project: LLVM.

Previously, it was not possible to skip running the localizer pass
conditionally. This patch adds an input function to the pass which
decides if the pass should run on the given MachineFunction or not.

No test case as there is no upstream target needs this functionality.


Repository:
  rG LLVM Github Monorepo

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.232231.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191205/17bf798b/attachment.bin>


More information about the llvm-commits mailing list