From bfa3d260b8238562b39f6a405e7ac366060401bc Mon Sep 17 00:00:00 2001 From: Volkan Keles Date: Thu, 5 Dec 2019 11:09:50 -0800 Subject: [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 --- llvm/lib/CodeGen/GlobalISel/Localizer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/GlobalISel/Localizer.cpp') 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 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); -- cgit v1.2.3