[llvm] [NewPM][CodeGen] Port selection dag isel to new pass manager (PR #83567)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 05:46:20 PDT 2024
================
@@ -341,9 +341,50 @@ void TargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI,
// SelectionDAGISel code
//===----------------------------------------------------------------------===//
-SelectionDAGISel::SelectionDAGISel(char &ID, TargetMachine &tm,
- CodeGenOptLevel OL)
- : MachineFunctionPass(ID), TM(tm), FuncInfo(new FunctionLoweringInfo()),
+SelectionDAGISelLegacy::SelectionDAGISelLegacy(
+ char &ID, std::unique_ptr<SelectionDAGISel> S)
+ : MachineFunctionPass(ID), Selector(std::move(S)) {
+ initializeGCModuleInfoPass(*PassRegistry::getPassRegistry());
+ initializeBranchProbabilityInfoWrapperPassPass(
+ *PassRegistry::getPassRegistry());
+ initializeAAResultsWrapperPassPass(*PassRegistry::getPassRegistry());
+ initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
+}
+
+bool SelectionDAGISelLegacy::runOnMachineFunction(MachineFunction &MF) {
+ // If we already selected that function, we do not need to run SDISel.
+ if (MF.getProperties().hasProperty(
+ MachineFunctionProperties::Property::Selected))
+ return false;
+
+ // Do some sanity-checking on the command-line options.
+ assert((!EnableFastISelAbort || Selector->TM.Options.EnableFastISel) &&
+ "-fast-isel-abort > 0 requires -fast-isel");
+
+ // Decide what flavour of variable location debug-info will be used, before
+ // we change the optimisation level.
+ MF.setUseDebugInstrRef(MF.shouldUseDebugInstrRef());
+
+ // Reset the target options before resetting the optimization
+ // level below.
+ // FIXME: This is a horrible hack and should be processed via
+ // codegen looking at the optimization level explicitly when
+ // it wants to look at it.
+ Selector->TM.resetTargetOptions(MF.getFunction());
+ // Reset OptLevel to None for optnone functions.
+ CodeGenOptLevel NewOptLevel = Selector->OptLevel;
+ if (Selector->OptLevel != CodeGenOptLevel::None &&
+ skipFunction(MF.getFunction()))
+ NewOptLevel = CodeGenOptLevel::None;
----------------
arsenm wrote:
```suggestion
CodeGenOptLevel NewOptLevel = skipFunction(MF.getFunction()) ?
CodeGenOptLevel::None : Selector->OptLevel;
```
https://github.com/llvm/llvm-project/pull/83567
More information about the llvm-commits
mailing list