Second of two patches to enable salvaging of dbg.value intrinsics that have
multiple location ops pre-LSR.
This second patch adds the core implementation. Much is shared with the
original, single-op SCEV-based salvaging. Each
optimised away location op is assigned a SCEVDbgValuebuilder that generates a
DIExpression and location ops that enable recovery of the location value. Most
of the complexity lies in creating the final location op DIArglist, because the
number of locations that will be optimised away is not known until after LSR,
and and the number of new locations that will be required to recover the
missing locations is not known until each SCEVDbgValueBuilder has generated a
recovery expression. The final DIArglist is organised as follows:
DIArglist(Induction Variable, [non optimised-out locations], [locations required for recovery expressions])
The final DIExpression is initialised empty. Its contents are formed by parsing
the original (pre-LSR) expression left-to-right, pushing each element onto the
new expression. When a DW_OP_LLVM_arg reference to an optimised-out location is
encountered, the SCEVDbgValueBuilder that recovers that location's value is
used to append both its recovery expression and values onto the final
expression and DIArglist (list contents shown above). If a reference to a
non-optimised out location is encountered, the argument index is adjusted using
a map of old to new location op indexes.
Using this method avoids any inserts and forms both the final location list and
expression with appends.
I suppose with the variable rename it may make sense to rename this function?