Commit Graph

41 Commits

Author SHA1 Message Date
Felipe de Azevedo Piovezan
a321b0afe0 [DebugInfo] Update tests to expect new LLVM debug format 2024-07-23 11:06:12 -07:00
Adrian Prantl
d65b8baa76 Update IRGenDebugInfo for LLVM D95617.
In https://reviews.llvm.org/D95617 LLVM stopped to emit debug values without a
location as an optimization for inlined functions. Because Swift is emitting
dbg.values(undef) for sizeless variables even at -Onone, we need to make sure
all local variables are preserved even at -Onone.

rdar://82038523
(cherry picked from commit c40b8f38b8)
2021-08-20 13:22:40 -07:00
Vedant Kumar
60ec3f1b90 Fix debug description for cases with multiple items (#32282)
* [SILGenFunction] Don't create redundant nested debug scopes

Instead of emitting:

```
sil_scope 4 { loc "main.swift":6:19 parent 3 }
sil_scope 5 { loc "main.swift":7:3 parent 4 }
sil_scope 6 { loc "main.swift":7:3 parent 5 }
sil_scope 7 { loc "main.swift":7:3 parent 5 }
sil_scope 8 { loc "main.swift":9:5 parent 4 }
```

Emit:

```
sil_scope 4 { loc "main.swift":6:19 parent 3 }
sil_scope 5 { loc "main.swift":7:3 parent 4 }
sil_scope 6 { loc "main.swift":9:5 parent 5 }
```

* [IRGenSIL] Diagnose conflicting shadow copies

If we attempt to store a value with the wrong type into a slot reserved
for a shadow copy, diagnose what went wrong.

* [SILGenPattern] Defer debug description of case variables

Create unique nested debug scopes for a switch, each of its case labels,
and each of its case bodies. This looks like:

```
  switch ... { // Enter scope 1.
    case ... : // Enter scope 2, nested within scope 1.
      <body-1> // Enter scope 3, nested within scope 2.

    case ... : // Enter scope 4, nested within scope 1.
      <body-2> // Enter scope 5, nested within scope 4.
  }
```

Use the new scope structure to defer emitting debug descriptions of case
bindings. Specifically, defer the work until we can nest the scope for a
case body under the scope for a pattern match.

This fixes SR-7973, a problem where it was impossible to inspect a case
binding in lldb when stopped at a case with multiple items.

Previously, we would emit the debug descriptions too early (in the
pattern match), leading to duplicate/conflicting descriptions. The only
reason that the ambiguous description was allowed to compile was because
the debug scopes were nested incorrectly.

rdar://41048339

* Update tests
2020-06-10 13:31:10 -07:00
Robert Widmann
426fe886dc [SR-8272] Drop the last remnants of LogicValue
Removes the _getBuiltinLogicValue intrinsic in favor of an open-coded
struct_extract in SIL.  This removes Sema's last non-literal use of builtin
integer types and unblocks a bunch of cleanup.

This patch would be NFC, but it improves line information for conditional expression codegen.
2018-12-19 23:14:59 -05:00
Adrian Prantl
c74ae5f375 Remove the redundant SILLocation::getCompilerGenerated interface (NFC) 2018-01-17 11:09:23 -08:00
Vedant Kumar
b27ed065b6 [DebugInfo] Avoid applying a misleading cleanup loc in case blocks
Switch cases without a trailing curly brace have ambiguous cleanup
locations. Here's what the current stepping behavior looks like:

  switch x {
    case ...:
      if true { foo() } // Step
      else    { bar() } // Step
  }

The second step can be misleading, because users might think that the
else branch is taken.

rdar://35628620
2018-01-12 17:19:45 -08:00
Adrian Prantl
b998c103fc Debug Info: Associate a function call with the beginning of the expression.
Before this change, stepping through the code
  1 foo(x,
  2     f(a)
  3     f(b)
  4   )

would visit the code in the order 2, 3, 4, with the function call
being on line 4.  After this patch the order is 2, 3, 1 with the
function call being on line 1. This is both closer to what clang
generates for simialar C code and more useful to the programmer since
it is easier to understand which function is being called in a nested
expression.

rdar://problem/35430708
2017-11-10 14:37:47 -08:00
Adrian Prantl
84d9238315 Emit llvm.dbg.declare intrisics immediately after the described alloca.
This cleanup change doesn't change the semantics, but it makes the
resulting IR much easier to read and debug.
2017-05-24 09:13:41 -07:00
Arnold Schwaighofer
39fa2f0228 Use the swift calling convention for swift functions
Use the generic type lowering algorithm described in
"docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion
type to the type expected by the ABI.

Change IRGen to use the swift calling convention (swiftcc) for native swift
functions.

Use the 'swiftself' attribute on self parameters and for closures contexts.

Use the 'swifterror' parameter for swift error parameters.

Change functions in the runtime that are called as native swift functions to use
the swift calling convention.

rdar://19978563
2017-02-14 12:17:57 -08:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Adrian Prantl
bffda8a78d Debugging: Extend the live ranges of local values at -Onone.
For many local values we can avoid a shadow alloca by directly
describing them with a dbg.value. This also enables precise liveness
so variables don't show up in the debugger before they are
initialized. Unfortunately this also means that values will disappear
when they are no longer needed.

This patch inserts an empty inline assembler expression depending on
the llvm::Value that is being described in the blocks dominated by it.
This uses less stack space than full shadow copies *and* allows us to
track the liveness of the variable completely. It may cause values to
be spilled onto the stack, though.

<rdar://problem/26627376>
2016-06-24 10:35:45 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Adrian Prantl
053d7cf277 Debug Info: Don't emit shadow stack copies for local variables.
The effect of this tiny change is that local variables will be described
by llvm.dbg.values, which will get lowered into an accurate location list
instead of a stack slot that is valid for the entire scope of the variable.
This means the debugger can now accurately track the liveness of variables
knowing exactly when they are initialized and when there values go away.
Function arguments are still kept in stack slots because (1) they are
already initialized at the function entry and (2) LLDB really needs self
to be available at all times for the expression evaluator.

This was made possible by recent advancements in LLVM such as the live
debug variables pass and various related bugfixes.

<rdar://problem/15746520>
2016-03-08 11:10:02 -08:00
Xin Tong
6d006adbcc Revert "Debug Info: Don't emit shadow stack copies for local variables."
This reverts commit 1cb9c24b2f.

Broke OSX incremental build and others.
2016-03-02 07:55:33 -08:00
Adrian Prantl
1cb9c24b2f Debug Info: Don't emit shadow stack copies for local variables.
The effect of this tiny change is that local variables will be described
by llvm.dbg.values, which will get lowered into an accurate location list
instead of a stack slot that is valid for the entire scope of the variable.
This means the debugger can now accurately track the liveness of variables
knowing exactly when they are initialized and when there values go away.
Function arguments are still kept in stack slots because (1) they are
already initialized at the function entry and (2) LLDB really needs self
to be available at all times for the expression evaluator.

This was made possible by recent advancements in LLVM such as the live
debug variables pass and various related bugfixes.

<rdar://problem/15746520>
2016-03-01 18:47:34 -08:00
David Farler
8a5ed405bf Make var parameters an error for Swift 3
This finishes up revisions to SE-0003 - only var function parameters
are disallowed for Swift 3.
2016-01-30 12:39:17 -08:00
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Daniel Duan
239c6629e9 Remove trailing semi-colons in .swift files 2015-12-20 21:12:11 -08:00
Adrian Prantl
098c07957e Debug Info: Don't skip updating IRGenDebugInfo's current location for SILLocations that are marked as prologue. IRGenDebugInfo will handle them correctly anyway and if the instruction with the prologue location originates from an inlined function, this would result in dropping debug location information.
rdar://problem/23288366
2015-11-10 10:24:57 -08:00
David Farler
8f2fbdc93a Make function parameters and refutable patterns always immutable
All refutable patterns and function parameters marked with 'var'
is now an error.

- Using explicit 'let' keyword on function parameters causes a warning.
- Don't suggest making function parameters mutable
- Remove uses in the standard library
- Update tests

rdar://problem/23378003
2015-11-09 16:56:13 -08:00
David Farler
a759ca9141 Disallow 'var' bindings in case patterns
Make the following illegal:

switch thing {
  case .A(var x):
    modify(x0
}

And provide a replacement 'var' -> 'let' fix-it.

rdar://problem/23172698

Swift SVN r32883
2015-10-25 18:53:02 +00:00
Michael Gottesman
6d74962918 Adapt all DebugInfo testcases to the new upstream LLVM metadata format.
Swift SVN r31813
2015-09-09 04:37:34 +00:00
Dmitri Hrybenko
0fce5c7b4e tests: remove uses of println() that are not relevant to the tests
Swift SVN r28016
2015-05-01 03:35:50 +00:00
Duncan Exon Smith
c6d42db070 Adapt to MD* => DI* renaming of debug info types
Applied the upgrade script from r236120 (LLVM) and r236121 (CFE).  This is the
final step of rdar://problem/20434113.



Swift SVN r27925
2015-04-29 21:40:21 +00:00
Duncan Exon Smith
093eb3c365 DebugInfo: Hand-update testcases after LLVM r231082
Update debug info testcases after moving the new hierarchy into place in
upstream LLVM r231082.

rdar://problem/19720042



Swift SVN r25715
2015-03-03 19:15:31 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Adrian Prantl
d7489b7272 Update testcases for new LLVM IR assembler syntax.
Swift SVN r24428
2015-01-14 23:38:18 +00:00
Adrian Prantl
12838bd2df Manually update testcases where the automatic upgrader wasn't able to.
Swift SVN r23943
2014-12-15 20:47:50 +00:00
Adrian Prantl
162bc8d24c Updated testcases for upstream assembler changes.
Swift SVN r23942
2014-12-15 19:39:21 +00:00
Graham Batty
83f27a8af7 Revert "Mark tests that don't pass on linux as XFAIL."
This reverts commit 2711ca86de7bf6a7885ccea24219a48a590b1e95.

Swift SVN r23577
2014-11-24 17:42:13 +00:00
Graham Batty
198402dcfe Mark tests that don't pass on linux as XFAIL.
Swift SVN r23573
2014-11-24 17:40:37 +00:00
Adrian Prantl
0c21c4da07 Expose ExitableFullExpr scopes to the debug info, so variables declared in
patterns show up in their own scopes, and the same variable name can be
reused in consecutive patterns.

<rdar://problem/15187441> Implement local variable debug scoping for variables declared in patterns

Swift SVN r23251
2014-11-11 23:27:43 +00:00
Adrian Prantl
a64a2691b1 Debug info: Use the end of a call expression as the location for a call.
Swift SVN r22740
2014-10-15 00:26:45 +00:00
Erik Eckstein
e59c4b6eb7 Add -primary-file options to prevent whole-module-optimizations.
This is needed for tests which define internal functions which should not be eliminated.

So far this was not needed because of a hack which prevented whole-module-optimizations for tests.



Swift SVN r22658
2014-10-10 09:51:48 +00:00
Adrian Prantl
5cb356686c Turn the location for the break out of a switch case into a cleanup
location.
<rdar://problem/18401152> stepping out of the body of the case that was taken goes back to the case statement

Swift SVN r22285
2014-09-25 16:29:25 +00:00
Doug Gregor
3ebf5cb3da Switch the string literal protocols over to initializer requirements.
Swift SVN r22076
2014-09-18 15:48:42 +00:00
Dave Abrahams
f3ac09497d Store ASCII string literals as UTF8
Fixes <rdar://problem/16740011> ASCII string literals produce UTF16
Strings

Swift SVN r21419
2014-08-22 19:05:15 +00:00
Ted Kremenek
d075f06573 Require a minimum deployment target of iOS 7 or OSX 10.9
Implements <rdar://problem/17532113>

Swift SVN r19451
2014-07-02 06:23:38 +00:00
John McCall
f40e9ef0ae Rewrite switch dispatch emission.
Specialization now recurses on only that prefix of the
current matrix which shares a specialization form
(essentially, a pattern kind) with the head row.  This is
inferior to the previous algorithm in a number of ways: we
may require more switches to perform a single dispatch, and
we may introduce more redundant variables in the leaves.
However, it also means that we will have fully specialized a
row along exactly one path in the decision tree, which makes
it much easier to work with dispatches that introduce new
cleanups.

This change also changes switch-dispatch to use the new
dynamic-cast instructions.

Incidentally fixes rdar://16401831.

Swift SVN r19336
2014-06-30 11:55:28 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Adrian Prantl
201d3cfc68 Add a testcase for rdar://problem/15187441
Swift SVN r9096
2013-10-09 22:22:59 +00:00