For more context, see:
1. https://github.com/apple/swift/pull/29239 - original PR which introduced
the change, including an LLDB-side change.
2. The immediately preceding commit, which reverted this change.
3. https://github.com/apple/swift/pull/29350 which revealed some breakage
caused by the changes in PR 29239 (unrelated to printing).
Previously, when in the debugger and dumping out SIL code, the
printer would crash if it encountered a null operand. If you
are dumping a basic block, this means that the dump stops at
that instruction instead of showing you the whole block. Null
operands can happen when you call dropAllReferences() but have
yet to delete the instruction.
Now the printer is a bit more resilient. We probably don't catch
all the cases, but we handle a lot of them, e.g.:
%116 = apply <<NULL OPERAND>>(<<NULL OPERAND>>, <<NULL OPERAND>>) : <<NULL CALLEE>>
debug_value <<NULL OPERAND>>, let, name "c", argno 1 // id: %120
retain_value <<NULL OPERAND>> // id: %138
Since this is only relevant to invalid IR, this is just
a debugging aid, so no testcase.
introduce a common superclass, SILNode.
This is in preparation for allowing instructions to have multiple
results. It is also a somewhat more elegant representation for
instructions that have zero results. Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction. Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.
A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.
Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
With the option -sil-print-debuginfo the printing of debug locations and scopes can be enabled.
I made the default for the option “false”, because in 99% of the time I don’t need the debug info in the printed SIL and I prefer better readability.
Introduce a new SILPrintContext class which is the main handle passed to the SILModule's and SILFunction's print functions.
It also allows to let derived classes implement call backs on instruction printing.
NFC for now, but needed for the upcoming SIL-debuginfo change.