Skip to content

Commit

Permalink
Extract out a SelectionDAGBuilder::LowerAsStatepoint; NFC
Browse files Browse the repository at this point in the history
Summary:
This is a step towards implementing "direct" lowering of calls and
invokes with deopt operand bundles into STATEPOINT nodes (as opposed to
having them mandatorily pass through RewriteStatepointsForGC, which is
the case today).

This change extracts out a `SelectionDAGBuilder::LowerAsStatepoint`
helper function that is able to lower a "statepoint like thing", and
uses it to lower `gc.statepoint` calls.  This is an NFC now, but in a
later change we will use `LowerAsStatepoint` to directly lower calls and
invokes with operand bundles without going through an intermediate
`gc.statepoint` IR representation.

FYI: I expect `SelectionDAGBuilder::StatepointInfo` will evolve as I add
support for lowering non gc.statepoints, right now it is fairly tightly
coupled with an IR level `gc.statepoint`.

Reviewers: reames, pgavlin, JosephTremoulet

Subscribers: sanjoy, mcrosier, llvm-commits

Differential Revision: http://reviews.llvm.org/D18106

llvm-svn: 263671
  • Loading branch information
sanjoy committed Mar 16, 2016
1 parent 54bf9e1 commit 70697ff
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 144 deletions.
48 changes: 48 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Expand Up @@ -726,6 +726,54 @@ class SelectionDAGBuilder {
/// references that need to refer to the last resulting block.
void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last);

/// Describes a gc.statepoint or a gc.statepoint like thing for the purposes
/// of lowering into a STATEPOINT node. Right now it only abstracts an actual
/// gc.statepoint, but that will change in the future.
struct StatepointLoweringInfo {
/// Bases[i] is the base pointer for Ptrs[i]. Together they denote the set
/// of gc pointers this STATEPOINT has to relocate.
ArrayRef<const Value *> Bases;
ArrayRef<const Value *> Ptrs;

/// The set of gc.relocate calls associated with this gc.statepoint.
ArrayRef<const GCRelocateInst *> GCRelocates;

/// The full list of gc arguments to the gc.statepoint being lowered.
ArrayRef<const Use> GCArgs;

/// The gc.statepoint instruction.
const Instruction *StatepointInstr = nullptr;

/// The list of gc transition arguments present in the gc.statepoint being
/// lowered.
ArrayRef<const Use> GCTransitionArgs;

/// The ID that the resulting STATEPOINT instruction has to report.
unsigned ID = -1;

/// Information regarding the underlying call instruction.
TargetLowering::CallLoweringInfo CLI;

/// The deoptimization state associated with this gc.statepoint call, if
/// any.
ArrayRef<const Use> DeoptState;

/// Flags associated with the meta arguments being lowered.
uint64_t StatepointFlags = -1;

/// The number of patchable bytes the call needs to get lowered into.
unsigned NumPatchBytes = -1;

/// The exception handling unwind destination, in case this represents an
/// invoke of gc.statepoint.
const BasicBlock *EHPadBB = nullptr;

explicit StatepointLoweringInfo(SelectionDAG &DAG) : CLI(DAG) {}
};

/// Lower \p SLI into a STATEPOINT instruction.
SDValue LowerAsStatepoint(StatepointLoweringInfo &SLI);

// This function is responsible for the whole statepoint lowering process.
// It uniformly handles invoke and call statepoints.
void LowerStatepoint(ImmutableStatepoint Statepoint,
Expand Down

0 comments on commit 70697ff

Please sign in to comment.