summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolkan Keles <vkeles@apple.com>2019-12-05 11:09:50 -0800
committerVolkan Keles <vkeles@apple.com>2019-12-05 11:09:50 -0800
commitbfa3d260b8238562b39f6a405e7ac366060401bc (patch)
tree848c6704b46f2522c775be29addd1419ce71c100
parentf688570d5c5493e969d5fca599d6eb8a796e27ca (diff)
downloadbcm5719-llvm-bfa3d260b8238562b39f6a405e7ac366060401bc.tar.gz
bcm5719-llvm-bfa3d260b8238562b39f6a405e7ac366060401bc.zip
[GlobalISel] Localizer: Allow targets not to run the pass conditionally
Summary: 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. Reviewers: qcolombet Reviewed By: qcolombet Subscribers: rovka, hiraditya, Petar.Avramovic, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71038
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/Localizer.h5
-rw-r--r--llvm/lib/CodeGen/GlobalISel/Localizer.cpp10
2 files changed, 14 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Localizer.h b/llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
index 06de5800b8b..ad1904725dc 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/Localizer.h
@@ -42,6 +42,10 @@ public:
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 @@ private:
public:
Localizer();
+ Localizer(std::function<bool(const MachineFunction &)>);
StringRef getPassName() const override { return "Localizer"; }
diff --git a/llvm/lib/CodeGen/GlobalISel/Localizer.cpp b/llvm/lib/CodeGen/GlobalISel/Localizer.cpp
index 5b13ea3abfd..1c4a668e5f3 100644
--- a/llvm/lib/CodeGen/GlobalISel/Localizer.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Localizer.cpp
@@ -29,7 +29,11 @@ INITIALIZE_PASS_END(Localizer, DEBUG_TYPE,
"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 @@ bool Localizer::runOnMachineFunction(MachineFunction &MF) {
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);
OpenPOWER on IntegriCloud