[llvm] Revert "[NewPM][CodeGen] Port selection dag isel to new pass manager" (PR #94146)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 1 23:30:03 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-powerpc
Author: None (paperchalice)
<details>
<summary>Changes</summary>
This reverts commit de37c06f01772e02465ccc9f538894c76d89a7a1 to de37c06f01772e02465ccc9f538894c76d89a7a1
It still breaks EXPENSIVE_CHECKS build. Sorry.
---
Patch is 136.59 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94146.diff
122 Files Affected:
- (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (-12)
- (modified) llvm/include/llvm/CodeGen/SelectionDAGISel.h (+5-38)
- (modified) llvm/include/llvm/CodeGen/StackProtector.h (-2)
- (modified) llvm/include/llvm/Passes/CodeGenPassBuilder.h (+2-7)
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+55-175)
- (modified) llvm/lib/Target/AArch64/AArch64.h (+1-1)
- (modified) llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp (+6-13)
- (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.h (+1-1)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPassBuilder.cpp (+2-6)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp (+10-21)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h (+8-16)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def (-6)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+1-2)
- (modified) llvm/lib/Target/AMDGPU/R600ISelDAGToDAG.cpp (+1-12)
- (modified) llvm/lib/Target/AMDGPU/SIISelLowering.cpp (+6-13)
- (modified) llvm/lib/Target/ARC/ARC.h (+1-1)
- (modified) llvm/lib/Target/ARC/ARCISelDAGToDAG.cpp (+6-12)
- (modified) llvm/lib/Target/ARC/ARCTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/ARM/ARM.h (+1-1)
- (modified) llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp (+6-12)
- (modified) llvm/lib/Target/ARM/ARMTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/AVR/AVR.h (+1-1)
- (modified) llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp (+6-12)
- (modified) llvm/lib/Target/AVR/AVRTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/BPF/BPF.h (+1-1)
- (modified) llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp (+6-11)
- (modified) llvm/lib/Target/BPF/BPFTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/CSKY/CSKY.h (+1-1)
- (modified) llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp (+6-13)
- (modified) llvm/lib/Target/CSKY/CSKYTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/Hexagon/Hexagon.h (+1-1)
- (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp (+3-8)
- (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h (+3-9)
- (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/Lanai/Lanai.h (+1-1)
- (modified) llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp (+10-11)
- (modified) llvm/lib/Target/Lanai/LanaiTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/LoongArch/LoongArch.h (+1-1)
- (modified) llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp (+3-8)
- (modified) llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.h (+3-7)
- (modified) llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/M68k/M68k.h (+1-1)
- (modified) llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp (+6-11)
- (modified) llvm/lib/Target/M68k/M68kTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/MSP430/MSP430.h (+1-1)
- (modified) llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (+6-12)
- (modified) llvm/lib/Target/MSP430/MSP430TargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/Mips/Mips.h (+1-1)
- (modified) llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp (+1-5)
- (modified) llvm/lib/Target/Mips/Mips16ISelDAGToDAG.h (-5)
- (modified) llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp (+4-8)
- (modified) llvm/lib/Target/Mips/MipsISelDAGToDAG.h (+5-8)
- (modified) llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp (+3-7)
- (modified) llvm/lib/Target/Mips/MipsSEISelDAGToDAG.h (+2-6)
- (modified) llvm/lib/Target/Mips/MipsTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/NVPTX/NVPTX.h (+1-1)
- (modified) llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp (+4-9)
- (modified) llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h (+2-7)
- (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPC.h (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (+6-12)
- (modified) llvm/lib/Target/PowerPC/PPCTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/RISCV/RISCV.h (+1-1)
- (modified) llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp (+3-8)
- (modified) llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h (+3-8)
- (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/Sparc/Sparc.h (+1-1)
- (modified) llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp (+6-12)
- (modified) llvm/lib/Target/Sparc/SparcTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/SystemZ/SystemZ.h (+1-1)
- (modified) llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp (+6-13)
- (modified) llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/VE/VE.h (+1-1)
- (modified) llvm/lib/Target/VE/VEISelDAGToDAG.cpp (+6-11)
- (modified) llvm/lib/Target/VE/VETargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/WebAssembly/WebAssembly.h (+1-1)
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp (+6-14)
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/X86/X86.h (+1-1)
- (modified) llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp (+1-10)
- (modified) llvm/lib/Target/X86/X86ISelDAGToDAG.cpp (+9-19)
- (removed) llvm/lib/Target/X86/X86ISelDAGToDAG.h (-25)
- (removed) llvm/lib/Target/X86/X86PassRegistry.def (-19)
- (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/X86/X86TargetMachine.h (-3)
- (modified) llvm/lib/Target/XCore/XCore.h (+1-1)
- (modified) llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp (+6-13)
- (modified) llvm/lib/Target/XCore/XCoreTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/Xtensa/XtensaISelDAGToDAG.cpp (+9-16)
- (modified) llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-no-rtn.ll (-4)
- (modified) llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-rtn.ll (+1-4)
- (modified) llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f64.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-no-rtn.ll (-3)
- (modified) llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-rtn.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/buffer-intrinsics-mmo-offsets.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/bug-v4f64-subvector.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/carryout-selection.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/dagcombine-fma-crash.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-abs.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-bitreverse.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-ctlz-cttz.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-ctpop.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-min-max.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-negsubinlineconst.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-not-isel.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/divergence-driven-xnor.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/extract_subvector_vec4_vec3.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/flat-atomic-fadd.f32.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/flat-atomic-fadd.f64.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/fneg-fabs-divergence-driven-isel.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/global-atomic-fadd.v2f16-no-rtn.ll (-3)
- (modified) llvm/test/CodeGen/AMDGPU/global-atomic-fadd.v2f16-rtn.ll (-2)
- (modified) llvm/test/CodeGen/AMDGPU/img-nouse-adjust.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/implicit-def-muse.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/legalize-fp-load-invariant.ll (-1)
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.make.buffer.rsrc.ll (-1)
- (modified) llvm/test/CodeGen/X86/apx/no-rex2-general.ll (-2)
- (modified) llvm/test/CodeGen/X86/apx/no-rex2-pseudo-amx.ll (-1)
- (modified) llvm/test/CodeGen/X86/apx/no-rex2-pseudo-x87.ll (-1)
- (modified) llvm/test/CodeGen/X86/apx/no-rex2-special.ll (-1)
- (modified) llvm/test/tools/llc/new-pm/start-stop.ll (+2-2)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 48cb0cdf851cf..6d28273029bd0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -29,7 +29,6 @@
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineMemOperand.h"
-#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGenTypes/MachineValueType.h"
@@ -231,7 +230,6 @@ class SelectionDAG {
const TargetLibraryInfo *LibInfo = nullptr;
const FunctionVarLocs *FnVarLocs = nullptr;
MachineFunction *MF;
- MachineFunctionAnalysisManager *MFAM = nullptr;
Pass *SDAGISelPass = nullptr;
LLVMContext *Context;
CodeGenOptLevel OptLevel;
@@ -461,15 +459,6 @@ class SelectionDAG {
UniformityInfo *UA, ProfileSummaryInfo *PSIin,
BlockFrequencyInfo *BFIin, FunctionVarLocs const *FnVarLocs);
- void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
- MachineFunctionAnalysisManager &AM,
- const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA,
- ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin,
- FunctionVarLocs const *FnVarLocs) {
- init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, FnVarLocs);
- MFAM = &AM;
- }
-
void setFunctionLoweringInfo(FunctionLoweringInfo * FuncInfo) {
FLI = FuncInfo;
}
@@ -480,7 +469,6 @@ class SelectionDAG {
MachineFunction &getMachineFunction() const { return *MF; }
const Pass *getPass() const { return SDAGISelPass; }
- MachineFunctionAnalysisManager *getMFAM() { return MFAM; }
CodeGenOptLevel getOptLevel() const { return OptLevel; }
const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 4972af927cf1e..837f8bf7263ea 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -15,7 +15,6 @@
#define LLVM_CODEGEN_SELECTIONDAGISEL_H
#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/IR/BasicBlock.h"
#include <memory>
@@ -25,7 +24,6 @@ class AAResults;
class AssumptionCache;
class TargetInstrInfo;
class TargetMachine;
-class SSPLayoutInfo;
class SelectionDAGBuilder;
class SDValue;
class MachineRegisterInfo;
@@ -33,7 +31,6 @@ class MachineFunction;
class OptimizationRemarkEmitter;
class TargetLowering;
class TargetLibraryInfo;
-class TargetTransformInfo;
class FunctionLoweringInfo;
class SwiftErrorValueTracking;
class GCFunctionInfo;
@@ -41,7 +38,7 @@ class ScheduleDAGSDNodes;
/// SelectionDAGISel - This is the common base class used for SelectionDAG-based
/// pattern-matching instruction selectors.
-class SelectionDAGISel {
+class SelectionDAGISel : public MachineFunctionPass {
public:
TargetMachine &TM;
const TargetLibraryInfo *LibInfo;
@@ -54,10 +51,6 @@ class SelectionDAGISel {
AAResults *AA = nullptr;
AssumptionCache *AC = nullptr;
GCFunctionInfo *GFI = nullptr;
- SSPLayoutInfo *SP = nullptr;
-#ifndef NDEBUG
- TargetTransformInfo *TTI = nullptr;
-#endif
CodeGenOptLevel OptLevel;
const TargetInstrInfo *TII;
const TargetLowering *TLI;
@@ -74,18 +67,16 @@ class SelectionDAGISel {
/// functions. Storing the filter result here so that we only need to do the
/// filtering once.
bool MatchFilterFuncName = false;
- StringRef FuncName;
- explicit SelectionDAGISel(TargetMachine &tm,
+ explicit SelectionDAGISel(char &ID, TargetMachine &tm,
CodeGenOptLevel OL = CodeGenOptLevel::Default);
- virtual ~SelectionDAGISel();
+ ~SelectionDAGISel() override;
const TargetLowering *getTargetLowering() const { return TLI; }
- void initializeAnalysisResults(MachineFunctionAnalysisManager &MFAM);
- void initializeAnalysisResults(MachineFunctionPass &MFP);
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
- virtual bool runOnMachineFunction(MachineFunction &mf);
+ bool runOnMachineFunction(MachineFunction &MF) override;
virtual void emitFunctionEntryCode() {}
@@ -526,30 +517,6 @@ class SelectionDAGISel {
bool isMorphNodeTo);
};
-class SelectionDAGISelLegacy : public MachineFunctionPass {
- std::unique_ptr<SelectionDAGISel> Selector;
-
-public:
- SelectionDAGISelLegacy(char &ID, std::unique_ptr<SelectionDAGISel> S);
-
- ~SelectionDAGISelLegacy() override = default;
-
- void getAnalysisUsage(AnalysisUsage &AU) const override;
-
- bool runOnMachineFunction(MachineFunction &MF) override;
-};
-
-class SelectionDAGISelPass : public PassInfoMixin<SelectionDAGISelPass> {
- std::unique_ptr<SelectionDAGISel> Selector;
-
-protected:
- SelectionDAGISelPass(std::unique_ptr<SelectionDAGISel> Selector)
- : Selector(std::move(Selector)) {}
-
-public:
- PreservedAnalyses run(MachineFunction &MF,
- MachineFunctionAnalysisManager &MFAM);
-};
}
#endif /* LLVM_CODEGEN_SELECTIONDAGISEL_H */
diff --git a/llvm/include/llvm/CodeGen/StackProtector.h b/llvm/include/llvm/CodeGen/StackProtector.h
index dfafc781067d7..eb5d9d0caebc6 100644
--- a/llvm/include/llvm/CodeGen/StackProtector.h
+++ b/llvm/include/llvm/CodeGen/StackProtector.h
@@ -109,8 +109,6 @@ class StackProtector : public FunctionPass {
StackProtector();
- SSPLayoutInfo &getLayoutInfo() { return LayoutInfo; }
-
void getAnalysisUsage(AnalysisUsage &AU) const override;
// Return true if StackProtector is supposed to be handled by SelectionDAG.
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index afe066101c753..17bea5da48ce1 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -140,9 +140,6 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
}
protected:
- template <typename PassT>
- using has_required_t = decltype(std::declval<PassT &>().isRequired());
-
template <typename PassT>
using is_module_pass_t = decltype(std::declval<PassT &>().run(
std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
@@ -173,10 +170,8 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
static_assert((is_detected<is_function_pass_t, PassT>::value ||
is_detected<is_module_pass_t, PassT>::value) &&
"Only module pass and function pass are supported.");
- bool Required = false;
- if constexpr (is_detected<has_required_t, PassT>::value)
- Required = PassT::isRequired();
- if (!PB.runBeforeAdding(Name) && !Required)
+
+ if (!PB.runBeforeAdding(Name))
return;
// Add Function Pass
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 2c1e557ca1099..8addaf1ae3e54 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -341,49 +341,9 @@ void TargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI,
// SelectionDAGISel code
//===----------------------------------------------------------------------===//
-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.
- if (EnableFastISelAbort && !Selector->TM.Options.EnableFastISel)
- report_fatal_error("-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 = skipFunction(MF.getFunction())
- ? CodeGenOptLevel::None
- : Selector->OptLevel;
-
- Selector->MF = &MF;
- OptLevelChanger OLC(*Selector, NewOptLevel);
- Selector->initializeAnalysisResults(*this);
- return Selector->runOnMachineFunction(MF);
-}
-
-SelectionDAGISel::SelectionDAGISel(TargetMachine &tm, CodeGenOptLevel OL)
- : TM(tm), FuncInfo(new FunctionLoweringInfo()),
+SelectionDAGISel::SelectionDAGISel(char &ID, TargetMachine &tm,
+ CodeGenOptLevel OL)
+ : MachineFunctionPass(ID), TM(tm), FuncInfo(new FunctionLoweringInfo()),
SwiftError(new SwiftErrorValueTracking()),
CurDAG(new SelectionDAG(tm, OL)),
SDB(std::make_unique<SelectionDAGBuilder>(*CurDAG, *FuncInfo, *SwiftError,
@@ -401,17 +361,14 @@ SelectionDAGISel::~SelectionDAGISel() {
delete SwiftError;
}
-void SelectionDAGISelLegacy::getAnalysisUsage(AnalysisUsage &AU) const {
- CodeGenOptLevel OptLevel = Selector->OptLevel;
+void SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) const {
if (OptLevel != CodeGenOptLevel::None)
AU.addRequired<AAResultsWrapperPass>();
AU.addRequired<GCModuleInfo>();
AU.addRequired<StackProtector>();
AU.addPreserved<GCModuleInfo>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
-#ifndef NDEBUG
AU.addRequired<TargetTransformInfoWrapperPass>();
-#endif
AU.addRequired<AssumptionCacheTracker>();
if (UseMBPI && OptLevel != CodeGenOptLevel::None)
AU.addRequired<BranchProbabilityInfoWrapperPass>();
@@ -449,129 +406,65 @@ static void computeUsesMSVCFloatingPoint(const Triple &TT, const Function &F,
}
}
-PreservedAnalyses
-SelectionDAGISelPass::run(MachineFunction &MF,
- MachineFunctionAnalysisManager &MFAM) {
+bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
// If we already selected that function, we do not need to run SDISel.
- if (MF.getProperties().hasProperty(
+ if (mf.getProperties().hasProperty(
MachineFunctionProperties::Property::Selected))
- return PreservedAnalyses::all();
-
+ return false;
// Do some sanity-checking on the command-line options.
- if (EnableFastISelAbort && !Selector->TM.Options.EnableFastISel)
- report_fatal_error("-fast-isel-abort > 0 requires -fast-isel");
+ assert((!EnableFastISelAbort || TM.Options.EnableFastISel) &&
+ "-fast-isel-abort > 0 requires -fast-isel");
+
+ const Function &Fn = mf.getFunction();
+ MF = &mf;
+
+#ifndef NDEBUG
+ StringRef FuncName = Fn.getName();
+ MatchFilterFuncName = isFunctionInPrintList(FuncName);
+#else
+ (void)MatchFilterFuncName;
+#endif
// Decide what flavour of variable location debug-info will be used, before
// we change the optimisation level.
- MF.setUseDebugInstrRef(MF.shouldUseDebugInstrRef());
+ bool InstrRef = mf.shouldUseDebugInstrRef();
+ mf.setUseDebugInstrRef(InstrRef);
// 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.
- // TODO: Add a function analysis to handle this.
- Selector->MF = &MF;
+ TM.resetTargetOptions(Fn);
// Reset OptLevel to None for optnone functions.
- CodeGenOptLevel NewOptLevel = MF.getFunction().hasOptNone()
- ? CodeGenOptLevel::None
- : Selector->OptLevel;
-
- OptLevelChanger OLC(*Selector, NewOptLevel);
- Selector->initializeAnalysisResults(MFAM);
- Selector->runOnMachineFunction(MF);
-
- return getMachineFunctionPassPreservedAnalyses();
-}
-
-void SelectionDAGISel::initializeAnalysisResults(
- MachineFunctionAnalysisManager &MFAM) {
- auto &FAM = MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(*MF)
- .getManager();
- auto &MAMP = MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(*MF);
- Function &Fn = MF->getFunction();
-#ifndef NDEBUG
- FuncName = Fn.getName();
- MatchFilterFuncName = isFunctionInPrintList(FuncName);
-#else
- (void)MatchFilterFuncName;
-#endif
+ CodeGenOptLevel NewOptLevel = OptLevel;
+ if (OptLevel != CodeGenOptLevel::None && skipFunction(Fn))
+ NewOptLevel = CodeGenOptLevel::None;
+ OptLevelChanger OLC(*this, NewOptLevel);
TII = MF->getSubtarget().getInstrInfo();
TLI = MF->getSubtarget().getTargetLowering();
RegInfo = &MF->getRegInfo();
- LibInfo = &FAM.getResult<TargetLibraryAnalysis>(Fn);
- GFI = Fn.hasGC() ? &FAM.getResult<GCFunctionAnalysis>(Fn) : nullptr;
+ LibInfo = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(Fn);
+ GFI = Fn.hasGC() ? &getAnalysis<GCModuleInfo>().getFunctionInfo(Fn) : nullptr;
ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
- AC = &FAM.getResult<AssumptionAnalysis>(Fn);
- auto *PSI = MAMP.getCachedResult<ProfileSummaryAnalysis>(*Fn.getParent());
+ AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(mf.getFunction());
+ auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
BlockFrequencyInfo *BFI = nullptr;
- FAM.getResult<BlockFrequencyAnalysis>(Fn);
if (PSI && PSI->hasProfileSummary() && OptLevel != CodeGenOptLevel::None)
- BFI = &FAM.getResult<BlockFrequencyAnalysis>(Fn);
+ BFI = &getAnalysis<LazyBlockFrequencyInfoPass>().getBFI();
FunctionVarLocs const *FnVarLocs = nullptr;
if (isAssignmentTrackingEnabled(*Fn.getParent()))
- FnVarLocs = &FAM.getResult<DebugAssignmentTrackingAnalysis>(Fn);
+ FnVarLocs = getAnalysis<AssignmentTrackingAnalysis>().getResults();
- auto *UA = FAM.getCachedResult<UniformityInfoAnalysis>(Fn);
- CurDAG->init(*MF, *ORE, MFAM, LibInfo, UA, PSI, BFI, FnVarLocs);
- SwiftError->setFunction(*MF);
-
- // Now get the optional analyzes if we want to.
- // This is based on the possibly changed OptLevel (after optnone is taken
- // into account). That's unfortunate but OK because it just means we won't
- // ask for passes that have been required anyway.
-
- if (UseMBPI && OptLevel != CodeGenOptLevel::None)
- FuncInfo->BPI = &FAM.getResult<BranchProbabilityAnalysis>(Fn);
- else
- FuncInfo->BPI = nullptr;
-
- if (OptLevel != CodeGenOptLevel::None)
- AA = &FAM.getResult<AAManager>(Fn);
- else
- AA = nullptr;
-
- SP = &FAM.getResult<SSPLayoutAnalysis>(Fn);
-
-#ifndef NDEBUG
- TTI = &FAM.getResult<TargetIRAnalysis>(Fn);
-#endif
-}
-
-void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) {
- Function &Fn = MF->getFunction();
-#ifndef NDEBUG
- FuncName = Fn.getName();
- MatchFilterFuncName = isFunctionInPrintList(FuncName);
-#else
- (void)MatchFilterFuncName;
-#endif
-
- TII = MF->getSubtarget().getInstrInfo();
- TLI = MF->getSubtarget().getTargetLowering();
- RegInfo = &MF->getRegInfo();
- LibInfo = &MFP.getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(Fn);
- GFI = Fn.hasGC() ? &MFP.getAnalysis<GCModuleInfo>().getFunctionInfo(Fn)
- : nullptr;
- ORE = std::make_unique<OptimizationRemarkEmitter>(&Fn);
- AC = &MFP.getAnalysis<AssumptionCacheTracker>().getAssumptionCache(Fn);
- auto *PSI = &MFP.getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
- BlockFrequencyInfo *BFI = nullptr;
- if (PSI && PSI->hasProfileSummary() && OptLevel != CodeGenOptLevel::None)
- BFI = &MFP.getAnalysis<LazyBlockFrequencyInfoPass>().getBFI();
-
- FunctionVarLocs const *FnVarLocs = nullptr;
- if (isAssignmentTrackingEnabled(*Fn.getParent()))
- FnVarLocs = MFP.getAnalysis<AssignmentTrackingAnalysis>().getResults();
+ ISEL_DUMP(dbgs() << "\n\n\n=== " << FuncName << "\n");
UniformityInfo *UA = nullptr;
- if (auto *UAPass = MFP.getAnalysisIfAvailable<UniformityInfoWrapperPass>())
+ if (auto *UAPass = getAnalysisIfAvailable<UniformityInfoWrapperPass>())
UA = &UAPass->getUniformityInfo();
- CurDAG->init(*MF, *ORE, &MFP, LibInfo, UA, PSI, BFI, FnVarLocs);
+ CurDAG->init(*MF, *ORE, this, LibInfo, UA, PSI, BFI, FnVarLocs);
+ FuncInfo->set(Fn, *MF, CurDAG);
SwiftError->setFunction(*MF);
// Now get the optional analyzes if we want to.
@@ -580,32 +473,15 @@ void SelectionDAGISel::initializeAnalysisResults(MachineFunctionPass &MFP) {
// ask for passes that have been required anyway.
if (UseMBPI && OptLevel != CodeGenOptLevel::None)
- FuncInfo->BPI =
- &MFP.getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
+ FuncInfo->BPI = &getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
else
FuncInfo->BPI = nullptr;
if (OptLevel != CodeGenOptLevel::None)
- AA = &MFP.getAnalysis<AAResultsWrapperPass>().getAAResults();
+ AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
else
AA = nullptr;
- SP = &MFP.getAnalysis<StackProtector>().getLayoutInfo();
-
-#ifndef NDEBUG
- TTI = &MFP.getAnalysis<TargetTransformInfoWrapperPass>().getTTI(Fn);
-#endif
-}
-
-bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
- const Function &Fn = mf.getFunction();
-
- bool InstrRef = mf.shouldUseDebugInstrRef();
-
- FuncInfo->set(MF->getFunction(), *MF, CurDAG);
-
- ISEL_DUMP(dbgs() << "\n\n\n=== " << FuncName << '\n');
-
SDB->init(GFI, AA, AC, LibInfo);
MF->setHasInlineAsm(false);
@@ -900,8 +776,11 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
StringRef GroupName = "sdag";
StringRef GroupDescription = "Instruction Selection and Scheduling";
std::string BlockName;
- bool MatchFilterBB = false;
- (void)MatchFilterBB;
+ bool MatchFilterBB = false; (void)MatchFilterBB;
+#ifndef NDEBUG
+ TargetTransformInfo &TTI =
+ getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*FuncInfo->Fn);
+#endif
// Pre-type legalization allow creation of any node types.
CurDAG->NewNodesMustHaveLegalTypes = false;
@@ -926,7 +805,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- if (TTI->hasBranchDivergence())
+ if (TTI.hasBranchDivergence())
CurDAG->VerifyDAGDivergence();
#endif
@@ -946,7 +825,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- if (TTI->hasBranchDivergence())
+ if (TTI.hasBranchDivergence())
CurDAG->VerifyDAGDivergence();
#endif
@@ -968,7 +847,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- if (TTI->hasBranchDivergence())
+ if (TTI.hasBranchDivergence())
CurDAG->VerifyDAGDivergence();
#endif
@@ -992,7 +871,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- if (TTI->hasBranchDivergence())
+ if (TTI.hasBranchDivergence())
CurDAG->VerifyDAGDivergence();
#endif
}
@@ -1010,7 +889,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- if (TTI->hasBranchDivergence())
+ if (TTI.hasBranchDivergence())
CurDAG->VerifyDAGDivergence();
#endif
@@ -1026,7 +905,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- if (TTI->hasBranchDivergence())
+ if (TTI.hasBranchDivergence())
CurDAG->VerifyDAGDivergence();
#endif
@@ -1046,7 +925,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->dump());
#ifndef NDEBUG
- ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/94146
More information about the llvm-commits
mailing list