Commit Graph

19 Commits

Author SHA1 Message Date
Min-Yih Hsu
d00a6cc0e3 [SIL][Frontend] Simplify debug info generation flow for SIL files
- If any of the `-g<kind>` flag is given -- except `-gnone`, debug
   info will be printed into every generated SIL files.
 - The `-gsil` is deprecated in favor of `-sil-based-debuginfo`. The
   SILDebugInfoGenerator Pass now generates intermediate SIL file with
   name "<output file>.sil_dbg_<n>.sil". Other functionalities of that
   Pass remain the same.
2021-06-30 17:21:58 -07:00
Erik Eckstein
011358edd6 SIL: let SingleValueInstruction only inherit from a single SILNode.
This removes the ambiguity when casting from a SingleValueInstruction to SILNode, which makes the code simpler. E.g. the "isRepresentativeSILNode" logic is not needed anymore.
Also, it reduces the size of the most used instruction class - SingleValueInstruction - by one pointer.

Conceptually, SILInstruction is still a SILNode. But implementation-wise SILNode is not a base class of SILInstruction anymore.
Only the two sub-classes of SILInstruction - SingleValueInstruction and NonSingleValueInstruction - inherit from SILNode. SingleValueInstruction's SILNode is embedded into a ValueBase and its relative offset in the class is the same as in NonSingleValueInstruction (see SILNodeOffsetChecker).
This makes it possible to cast from a SILInstruction to a SILNode without knowing which SILInstruction sub-class it is.
Casting to SILNode cannot be done implicitly, but only with an LLVM `cast` or with SILInstruction::asSILNode(). But this is a rare case anyway.
2021-01-27 16:40:15 +01:00
Eric Miotto
8e7f9c9cbd Revert "SIL: let SingleValueInstruction only inherit from a single SILNode." 2021-01-26 10:02:24 -08:00
Erik Eckstein
ff1991740a SIL: let SingleValueInstruction only inherit from a single SILNode.
This removes the ambiguity when casting from a SingleValueInstruction to SILNode, which makes the code simpler. E.g. the "isRepresentativeSILNode" logic is not needed anymore.
Also, it reduces the size of the most used instruction class - SingleValueInstruction - by one pointer.

Conceptually, SILInstruction is still a SILNode. But implementation-wise SILNode is not a base class of SILInstruction anymore.
Only the two sub-classes of SILInstruction - SingleValueInstruction and NonSingleValueInstruction - inherit from SILNode. SingleValueInstruction's SILNode is embedded into a ValueBase and its relative offset in the class is the same as in NonSingleValueInstruction (see SILNodeOffsetChecker).
This makes it possible to cast from a SILInstruction to a SILNode without knowing which SILInstruction sub-class it is.
Casting to SILNode cannot be done implicitly, but only with an LLVM `cast` or with SILInstruction::asSILNode(). But this is a rare case anyway.
2021-01-25 09:30:04 +01:00
Varun Gandhi
983399c1e7 [Printer] Conditionally print Clang types in emitted SIL. 2020-09-16 10:34:43 -07:00
Varun Gandhi
f6643af650 [Printer] Update printSIL to make sure LLDB doesn't break.
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).
2020-01-22 09:05:39 -08:00
Varun Gandhi
d9a7a7d49e Revert "[Printer] Conditionally print Clang types in emitted SIL."
This reverts commit a27c5f0a16.
2020-01-22 09:04:52 -08:00
Varun Gandhi
a27c5f0a16 [Printer] Conditionally print Clang types in emitted SIL.
Hopefully, this helps us debug Clang type mismatches better.
2020-01-17 16:22:39 -08:00
moatom
2e95a0d265 Fix include guards 2019-06-02 12:10:43 +09:00
Chris Lattner
00e961e5f2 Teach the SILPrinter to be more resilient to null operands.
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.
2017-12-21 14:29:56 -08:00
John McCall
ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
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.
2017-09-25 02:06:26 -04:00
Erik Eckstein
24b684b22d SILPrinter: allow also basic blocks to be a context.
Plus a small refactoring to simplify the code: remove the inner SILPrintFunctionContext struct
2017-08-23 09:15:00 -07:00
Erik Eckstein
d4db9b8099 SILPrinter: make the printing of debug info optional.
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.
2017-04-20 09:18:08 -07:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
Andrew Trick
7ea54c8927 SILPrintContext: support for printing consistent block numbers. 2017-04-05 19:59:15 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
a942bb76d0 [gardening] Fix formatting of recently introduced headers. 2016-03-19 00:37:37 +01:00
Erik Eckstein
8f78085e8b Refactor SILPrinter.
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.
2016-03-18 14:01:38 -07:00