Commit Graph

9 Commits

Author SHA1 Message Date
Erik Eckstein
7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00
Konrad `ktoso` Malawski
0d3a4b44b8 [Concurrency] if let value on async value should be banned (not crash)
The issue is that the shorthand if let syntax injects an implicit
expression: https://github.com/apple/swift/pull/40694/ in ParseStmt and
that the 'diagnoseUnhandledAsyncSite' explicitly avoids reporting errors
in implicit expressions.

This change is that we don't mark the implicit declref code emitted by
the `if let prop` as implicit anymore, and this way the reporting works
out as expected.

Added some tests covering this as well as properly erroring out for the
nonexistent syntax of shortand + awaiting which doesn't exist, and we
properly error on it.

Resolves rdar://126169564
2024-06-19 17:20:18 +09:00
Nate Chandler
10ce0c6b16 [SILGen] Used move_value for lexical lets.
Instead of using begin_borrow [lexical] + copy_value.
2023-12-14 13:35:26 -08:00
Adrian Prantl
329e42849a Compute VarDeclScopeMap up front.
The previous lazy discovery did not always work because sometimes a debug_value
is emitted before the first SIL instruction in the variable's scope.

rdar://110841130
2023-06-16 14:32:30 -07:00
Adrian Prantl
874ba0868b SILDebugScopes: Don't ignore ConditionalClauseInitializerScope.
ConditionalClauseInitializerScope often create redundant scopes, however, they
are needed to correctly represent the scopes in an expression such as:

  if case .something(let foo), let foo = foo.

This patch changes SILGen to lower them 1:1 from ASTScopes.

rdar://110841130
2023-06-16 07:52:15 -07:00
Adrian Prantl
b74cdf19e8 Derive the SILDebugScope for a variable declaration from its owning ASTScope.
The previous code made the assumption that the ASTScope for a variable
declaration should be the one of the declaration's source location. That is not
necessarily the case, in some cases it should be an ancestor scope. This patch
introduces a map from ValueDecl -> ASTScope that is derived from querying each
ASTScope for its locals, which matches also what happens in name lookup.  This
patch also fixes the nesting of SILDebugScopes created for guard statement
bodies, which are incorrectly nested in the ASTScope hierarchy.

rdar://108940570
2023-05-10 12:29:42 -07:00
Adrian Prantl
a0ec3f45cd Revert "Relax test"
This reverts commit be845f1e42.
2023-05-10 12:13:34 -07:00
Adrian Prantl
be845f1e42 Relax test 2023-05-02 13:45:56 -07:00
Adrian Prantl
dcd881e105 SILDebugScopes: Remove a stateful workaround for Property Wrappers.
In an earlier version of the ASTScope -> SILdebugScope translation a workaround
was put into place that would select the current debug scope if an ASTScope was
marked as ignoreInDebugInfo. Removing this workaround makes the translation more
predictable as it eliminated the dependency on the current SILBuilder state. The
property wrapper tests still pass without this.

This uncovers a situations with let bindings where the SIL instructions are
emitted RHS before LHS, which does violate the di-hole verifier. This is
addressed by relaxing the verifier for now.

rdar://108736443
2023-05-01 17:52:44 -07:00