diff options
| author | Matthias Braun <matze@braunis.de> | 2016-10-24 23:23:02 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2016-10-24 23:23:02 +0000 |
| commit | 8b38ffaa986a06a6bdbd243b26eacc46ce9e5889 (patch) | |
| tree | 74ef1fc94e95b29cce86186146e509c5e6946b49 /llvm/lib | |
| parent | 9834fcd7ce1f743df6c11a9c0104f4f71482a085 (diff) | |
| download | bcm5719-llvm-8b38ffaa986a06a6bdbd243b26eacc46ce9e5889.tar.gz bcm5719-llvm-8b38ffaa986a06a6bdbd243b26eacc46ce9e5889.zip | |
CodeGen/Passes: Pass MachineFunction as functor arg; NFC
Passing a MachineFunction as argument is more natural and avoids an
unnecessary round-trip through the logic determining the correct
Subtarget because MachineFunction already has a reference anyway.
llvm-svn: 285039
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/IfConversion.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MachineInstrBundle.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMTargetMachine.cpp | 8 |
3 files changed, 14 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index 025eea229cc..e81af66c3b3 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -184,11 +184,11 @@ namespace { bool PreRegAlloc; bool MadeChange; int FnNum; - std::function<bool(const Function &)> PredicateFtor; + std::function<bool(const MachineFunction &)> PredicateFtor; public: static char ID; - IfConverter(std::function<bool(const Function &)> Ftor = nullptr) + IfConverter(std::function<bool(const MachineFunction &)> Ftor = nullptr) : MachineFunctionPass(ID), FnNum(-1), PredicateFtor(std::move(Ftor)) { initializeIfConverterPass(*PassRegistry::getPassRegistry()); } @@ -321,8 +321,7 @@ INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo) INITIALIZE_PASS_END(IfConverter, "if-converter", "If Converter", false, false) bool IfConverter::runOnMachineFunction(MachineFunction &MF) { - if (skipFunction(*MF.getFunction()) || - (PredicateFtor && !PredicateFtor(*MF.getFunction()))) + if (skipFunction(*MF.getFunction()) || (PredicateFtor && !PredicateFtor(MF))) return false; const TargetSubtargetInfo &ST = MF.getSubtarget(); @@ -2295,6 +2294,6 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) { } FunctionPass * -llvm::createIfConverter(std::function<bool(const Function &)> Ftor) { +llvm::createIfConverter(std::function<bool(const MachineFunction &)> Ftor) { return new IfConverter(std::move(Ftor)); } diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index e4686b3c5c4..b5621a09c6f 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -24,7 +24,8 @@ namespace { class UnpackMachineBundles : public MachineFunctionPass { public: static char ID; // Pass identification - UnpackMachineBundles(std::function<bool(const Function &)> Ftor = nullptr) + UnpackMachineBundles( + std::function<bool(const MachineFunction &)> Ftor = nullptr) : MachineFunctionPass(ID), PredicateFtor(std::move(Ftor)) { initializeUnpackMachineBundlesPass(*PassRegistry::getPassRegistry()); } @@ -32,7 +33,7 @@ namespace { bool runOnMachineFunction(MachineFunction &MF) override; private: - std::function<bool(const Function &)> PredicateFtor; + std::function<bool(const MachineFunction &)> PredicateFtor; }; } // end anonymous namespace @@ -42,7 +43,7 @@ INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundles", "Unpack machine instruction bundles", false, false) bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) { - if (PredicateFtor && !PredicateFtor(*MF.getFunction())) + if (PredicateFtor && !PredicateFtor(MF)) return false; bool Changed = false; @@ -78,7 +79,8 @@ bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) { } FunctionPass * -llvm::createUnpackMachineBundles(std::function<bool(const Function &)> Ftor) { +llvm::createUnpackMachineBundles( + std::function<bool(const MachineFunction &)> Ftor) { return new UnpackMachineBundles(std::move(Ftor)); } diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp index 0e74ab0a499..4ef882a7bc8 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -443,8 +443,8 @@ void ARMPassConfig::addPreSched2() { return this->TM->getSubtarget<ARMSubtarget>(F).restrictIT(); })); - addPass(createIfConverter([this](const Function &F) { - return !this->TM->getSubtarget<ARMSubtarget>(F).isThumb1Only(); + addPass(createIfConverter([](const MachineFunction &MF) { + return !MF.getSubtarget<ARMSubtarget>().isThumb1Only(); })); } addPass(createThumb2ITBlockPass()); @@ -454,8 +454,8 @@ void ARMPassConfig::addPreEmitPass() { addPass(createThumb2SizeReductionPass()); // Constant island pass work on unbundled instructions. - addPass(createUnpackMachineBundles([this](const Function &F) { - return this->TM->getSubtarget<ARMSubtarget>(F).isThumb2(); + addPass(createUnpackMachineBundles([](const MachineFunction &MF) { + return MF.getSubtarget<ARMSubtarget>().isThumb2(); })); // Don't optimize barriers at -O0. |

