For a simple llvm IR as:
define i32 @test(i32 %X, i32 %Y) {
%Z = udiv i32 %X, %Y
ret i32 %Z
}
the SelectionDAG graph is more complex than I thought:
Why is CopyFromReg
needed, why not connect vreg0
and vreg1
to udiv
directly?
How should I read the graph, from EntryToken
to GraphRoot
or the opposite direction?
Function arguments are calling convention specific and they are lowered in the construction process of SelectionDAG (SelectionDAGISel::SelectAllBasicBlocks
calls SelectionDAGISel::LowerArguments
), the architecture specific LowerArguments usually creates CopyFromReg
to represent the arguments in virtual register as SDValue
and chain the CopyFromReg
to SelectionDAG.
The extra CopyFromReg is attached to maintain the Chain to EntryToken, and store other information which is designed not to be part of RegisterSDNode
, like DebugLoc
.
Here is an example that CopyFromReg is not attached (blue dotted arrows are missing):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With