[PATCH] D34484: DAG: Provide access to Pass instance from SelectionDAG
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 11:10:43 PDT 2017
Matt Arsenault via Phabricator <reviews at reviews.llvm.org> writes:
> arsenm created this revision.
> Herald added a subscriber: wdng.
>
> This allows accessing an analysis pass during lowering.
>
> As asked about here:
> http://lists.llvm.org/pipermail/llvm-dev/2017-June/114067.html
>
>
> https://reviews.llvm.org/D34484
>
> Files:
> include/llvm/CodeGen/SelectionDAG.h
> lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
>
> Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> @@ -414,7 +414,7 @@
>
> SplitCriticalSideEffectEdges(const_cast<Function &>(Fn), DT, LI);
>
> - CurDAG->init(*MF, *ORE);
> + CurDAG->init(*MF, *ORE, this);
If we're doing this we should definitely be getting at the ORE via the
pass - it makes no sense to pass it through in two ways.
> FuncInfo->set(Fn, *MF, CurDAG);
>
> // Now get the optional analyzes if we want to.
> Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> @@ -891,8 +891,10 @@
> }
>
> void SelectionDAG::init(MachineFunction &NewMF,
> - OptimizationRemarkEmitter &NewORE) {
> + OptimizationRemarkEmitter &NewORE,
> + Pass *PassPtr) {
> MF = &NewMF;
> + SDAGISelPass = PassPtr;
> ORE = &NewORE;
> TLI = getSubtarget().getTargetLowering();
> TSI = getSubtarget().getSelectionDAGInfo();
> Index: include/llvm/CodeGen/SelectionDAG.h
> ===================================================================
> --- include/llvm/CodeGen/SelectionDAG.h
> +++ include/llvm/CodeGen/SelectionDAG.h
> @@ -211,6 +211,7 @@
> const SelectionDAGTargetInfo *TSI = nullptr;
> const TargetLowering *TLI = nullptr;
> MachineFunction *MF;
> + Pass *SDAGISelPass = nullptr;
> LLVMContext *Context;
> CodeGenOpt::Level OptLevel;
>
> @@ -366,13 +367,16 @@
> ~SelectionDAG();
>
> /// Prepare this SelectionDAG to process code in the given MachineFunction.
> - void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE);
> + void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
> + Pass *PassPtr);
>
> /// Clear state and free memory necessary to make this
> /// SelectionDAG ready to process a new block.
> void clear();
>
> MachineFunction &getMachineFunction() const { return *MF; }
> + const Pass *getPass() const { return SDAGISelPass; }
> +
> const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
> const TargetMachine &getTarget() const { return TM; }
> const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
>
>
> Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> @@ -414,7 +414,7 @@
>
> SplitCriticalSideEffectEdges(const_cast<Function &>(Fn), DT, LI);
>
> - CurDAG->init(*MF, *ORE);
> + CurDAG->init(*MF, *ORE, this);
> FuncInfo->set(Fn, *MF, CurDAG);
>
> // Now get the optional analyzes if we want to.
> Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> @@ -891,8 +891,10 @@
> }
>
> void SelectionDAG::init(MachineFunction &NewMF,
> - OptimizationRemarkEmitter &NewORE) {
> + OptimizationRemarkEmitter &NewORE,
> + Pass *PassPtr) {
> MF = &NewMF;
> + SDAGISelPass = PassPtr;
> ORE = &NewORE;
> TLI = getSubtarget().getTargetLowering();
> TSI = getSubtarget().getSelectionDAGInfo();
> Index: include/llvm/CodeGen/SelectionDAG.h
> ===================================================================
> --- include/llvm/CodeGen/SelectionDAG.h
> +++ include/llvm/CodeGen/SelectionDAG.h
> @@ -211,6 +211,7 @@
> const SelectionDAGTargetInfo *TSI = nullptr;
> const TargetLowering *TLI = nullptr;
> MachineFunction *MF;
> + Pass *SDAGISelPass = nullptr;
> LLVMContext *Context;
> CodeGenOpt::Level OptLevel;
>
> @@ -366,13 +367,16 @@
> ~SelectionDAG();
>
> /// Prepare this SelectionDAG to process code in the given MachineFunction.
> - void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE);
> + void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
> + Pass *PassPtr);
>
> /// Clear state and free memory necessary to make this
> /// SelectionDAG ready to process a new block.
> void clear();
>
> MachineFunction &getMachineFunction() const { return *MF; }
> + const Pass *getPass() const { return SDAGISelPass; }
> +
> const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
> const TargetMachine &getTarget() const { return TM; }
> const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
More information about the llvm-commits
mailing list