Commit Graph

1877 Commits

Author SHA1 Message Date
Felipe de Azevedo Piovezan
7114d77a50 [DebugInfo] Relax check-next in yielding_mutate.swift
This is too strict for targets that generate authentication
instructions.
2026-02-05 08:25:12 +00:00
Felipe de Azevedo Piovezan
92191a0f4a Merge pull request #86936 from felipepiovezan/felipe/coro_line_table_issue
[IRGenSIL][DebugInfo] Fix location of Coroutine/Async exit code
2026-02-03 17:35:00 +00:00
Felipe de Azevedo Piovezan
ecaa1011ca [IRGenSIL][DebugInfo] Extend lifetime of variables in coroutines
Just like in async functions, coroutines will go through the CoroSplit
flow. As such, variables in O0 need to go through the same treatment
they undergo for async functions: an `asm` directive is emitted so to
create a use of the variable after each split point.
2026-02-02 17:33:11 +00:00
Felipe de Azevedo Piovezan
e14ff72d70 [IRGenSIL][DebugInfo] Fix location of Coroutine/Async exit code
Exit code should not inherit the location of the previous basic block;
instead, it should contain line zero to denote that this is not
associated with any user code.

Without this patch, stepping over code code like:

```
1. yielding mutate {
2.   yield &member_int
3.   blah
4.   blah
}
```

Would go from line 3, to line 4, to line 2.

rdar://149106144
2026-02-02 15:20:13 +00:00
Felipe de Azevedo Piovezan
559d9e5b50 [DebugInfo] Fix return debug location of borrowing accessor's second funclet
When the main IRGenSIL loop decides to use the previous instruction's
location, it does so by emitting a compiler generated location. This is
creating an issue where the return address of a borrowing accessor is
landing on such a cleanup location, making the parent frame have no line
associated with it.

Why not use the last instruction's location instead? No tests fail with
this change, and it seems to keep the literal meaning of the "use the
last location" boolean variable that already exists in code.
2026-01-30 16:29:28 +00:00
Max Desiatov
0f1dce4d1b test/DebugInfo/LoadableByAddress.swift: require PTRSIZE=64 (#86774)
This test in its current form does not pass on 32-bit platforms.
2026-01-25 08:47:34 -08:00
elsa
5e9f215f31 Merge pull request #86010 from elsakeirouz/rework-for-each-desugar
Rework ForEachStmt Desugaring
2026-01-24 13:55:51 +00:00
Max Desiatov
22e68a3aff test/DebugInfo: enable all available tests for Wasm (#86742)
Wasm is the only 32-bit platform regularly tested on Swift CI, let's enable existing `DebugInfo` tests for it.
2026-01-23 17:36:20 -08:00
Elsa Keirouz
d54a572f7f [Sema] desugar ForEachStmt at AST level 2026-01-23 15:17:29 +00:00
Finagolfin
e8c2005c52 [test] Disable newly failing DebugInfo async-args test case and two other unmodified regressions on 32-bit platforms 2026-01-23 17:14:49 +05:30
Adrian Prantl
974c2e77a6 Merge pull request #86653 from felipepiovezan/felipe/swift_update_tests_main
[swift] Fix DebugInfo tests to account for CoroSplit changes
2026-01-22 08:10:51 -08:00
Elsa Keirouz
eedab7031a [DEBUGINFO] Tests the same things across architectures 2026-01-22 12:07:04 +00:00
Felipe de Azevedo Piovezan
cb33d6da47 [swift] Fix DebugInfo tests to account for CoroSplit changes
After 9ff29a89020e in llmv-project, the async frame ptr is stored in an
alloca in entry funclets.
2026-01-20 12:21:26 +00:00
Hamish Knight
df187348bc [test] Add some extra for loop tests
Add some test cases that were uncovered when doing source compatibility
testing for the for loop rework.
2026-01-18 23:25:52 +00:00
Hiroshi Yamauchi
6f60adf009 Use a separate DIRefMap cache for existential typealiases (#86368)
After https://github.com/swiftlang/swift/pull/85655, DI types for
existential typealiases and their inner protocol types are created,
which may encounter conflicts in the DIRefMap cache and assert failures
because they can have identical mangled names. This change fixes this
issue by using a separate cache for existential typealiases to avoid
such conflicts.

Issue https://github.com/swiftlang/swift/issues/86313
2026-01-14 13:50:59 -08:00
Aidan Hall
37e89902a3 Merge pull request #85957 from aidan-hall/fix-debug-info-again
Retain more debug info in SIL optimization passes
2026-01-13 17:13:36 +00:00
Hiroshi Yamauchi
a3e5f0bcef Set up the AST-affecting ClangImporter CodeGenOpts options early (#86175)
This is to keep clang module cache hashes consistent throughout the
build and avoid inconsistent hash errors due to the CodeGenOpts
changing at the IRGen phase in the middle of a build.

https://github.com/swiftlang/swift/issues/86116
2026-01-09 10:38:46 -08:00
Aidan Hall
0ef2094279 [DebugInfo] Salvage more during SIL optimization passes
This reverts commit b1eb70bf45.

The original PR (#85244) was reverted (#85836) due to rdar://165667449

This version fixes the aforementioned issue, and (potentially) improves overall
debug info retention by salvaging info in erase(instructionIncludingDebugUses:),
rather than inserting many explicit salvageDebugInfo calls throughout the code
to make the test cases pass.

Bridging: Make salvageDebugInfo a method of MutatingContext

This feels more consistent than making it a method of Instruction.

DebugInfo: Salvage from trivially dead instructions

This handles the case we were checking in constantFoldBuiltin, so we do not need to salvage debug info there any more.
2026-01-06 12:01:20 +00:00
Slava Pestov
2934386efd ASTMangler: Fix mangling of sugared (nested) ProtocolCompositionTypes
Canonical ProtocolCompositionTypes never nest; we flatten the structure
when computing a canonical type.

However, in DWARF mangling, we might encounter ProtocolCompositionTypes
that contain other ProtocolCompositionTypes, via TypeAliasType sugar.

Make sure to visit this nested structure instead of just ignoring it.

- Fixes https://github.com/swiftlang/swift/issues/86207.
2026-01-02 15:15:15 -05:00
Dan Blackwell
e62d58349f [Sanitizers] Add metadata to memsets created in zeroInit for LLDB (#85558)
The swift compiler memsets new allocas to zero. It does this so that
LLDB is able to display a friendly 'variable is uninitialized' message
rather than garbage. Unfortunately this use of a variable before its
lifetime.start disagrees with the memtag-stack tagging pass.

This patch attaches a piece of metadata to these memsets, so that the
memtag-stack tagging pass can recognize them and work around them
appropriately.

Paired with: https://github.com/swiftlang/llvm-project/pull/11846.

rdar://162206592
2026-01-02 10:40:34 +00:00
Aidan Hall
b1eb70bf45 Revert "[DebugInfo] Salvage more in -O builds"
This reverts commit a95d2979f9.

rdar://165667449
2025-12-04 15:39:39 +00:00
Adrian Prantl
0e55f81931 Merge pull request #66580 from adrian-prantl/110333983
Make source locations for standard library calls explicit
2025-12-02 08:56:32 -08:00
Aidan Hall
96dca43eb9 Merge pull request #85244 from aidan-hall/fixing-debug-info-rebase
Retain more debug info in optimized builds
2025-12-01 20:49:40 +00:00
Aidan Hall
a95d2979f9 [DebugInfo] Salvage more in -O builds
Specifically, improved debug info retention in:
* tryReplaceRedundantInstructionPair,
* splitAggregateLoad,
* TempLValueElimination,
* Mem2Reg,
* ConstantFolding.

The changes to Mem2Reg allow debug info to be retained in the case tested by
self-nostorage.swift in -O builds, so we have just enabled -O in that file
instead of writing a new test for it.

We attempted to add a case to salvageDebugInfo for unchecked_enum_data, but it
caused crashes in Linux CI that we were not able to reproduce.
2025-11-28 17:42:18 +00:00
Adrian Prantl
45547be3f8 [Debug Info] Represent type alias existantials in debug info
Previously debug info made not difference between an existential type and a
protocol type. This caused us to loose typealiases such as

typealias Alias = ProtocolType

in the debug info.

rdar://161134092
2025-11-21 15:17:47 -08:00
Adrian Prantl
11356acd44 Merge pull request #85397 from adrian-prantl/163167975
[SILOptimzer] Fix a crash caused by SILCombine mishandling inlined variables
2025-11-10 18:41:07 -08:00
Adrian Prantl
99cf35cdce [SILOptimzer] Fix a crash caused by SILCombine mishandling inlined variables
This showed up on and off again on the source-compatibility testsuite project hummingbird.

The gist of the problem is that transformations may not rewrite the
type of an inlined instance of a variable without also createing a
deep copy of the inlined function with a different name (and e.g., a
specialization suffix). Otherwise the modified inlined variable will
cause an inconsistency when later compiler passes try to create the
abstract declaration of that inlined function as there would be
conflicting declarations for that variable.

Since SILDebugScope isn't yet available in the SwiftCompilerSources
this fix just drop these variables, but it would be absolutely
possible to preserve them by using the same mechanism that SILCloner
uses to create a deep copy of the inlined function scopes.

rdar://163167975
2025-11-07 17:06:33 -08:00
Erik Eckstein
04688a69ec Optimizer: Always respect deinit barriers when hoisting destroys.
Also for non-lexical lifetimes
2025-11-06 21:00:45 +01:00
John McCall
13937fdb4e Merge pull request #84528 from rjmccall/async-let-runtime-realism
Model async let begin/finish as builtins in SIL
2025-11-05 10:24:46 -08:00
John McCall
a7d7970e29 Turn finishAsyncLet into a builtin.
This is necessary because we need to model its stack-allocation
behavior, although I'm not yet doing that in this patch because
StackNesting first needs to be taught to not try to move the
deallocation.

I'm not convinced that `async let` *should* be doing a stack allocation,
but it undoubtedly *is* doing a stack allocation, and until we have an
alternative to that, we will need to model it properly.
2025-11-03 16:33:40 -08:00
Adrian Prantl
457a2d3325 Merge pull request #85100 from adrian-prantl/163302154
Add a -debug-module-path frontend option
2025-11-03 12:30:55 -08:00
Anthony Latsis
e0ca132af2 Merge pull request #85102 from swiftlang/jepa-main2
[test] Remove pre-rebranch `nocapture` matches
2025-10-29 22:21:38 +00:00
Anthony Latsis
b5aec4cc34 [test] Remove pre-rebranch nocapture matches
These were added in https://github.com/swiftlang/swift/pull/81375 (and
several other follow-up PRs because we missed a few places) and
are no longer needed.
2025-10-24 02:07:22 +01:00
Adrian Prantl
cb4efa0839 Add a -debug-module-path frontend option
This new option allows the Driver to pass the path to a compilation
job's own binary swiftmodule artifact to the frontend. The compiler
then stores this path in the debug info, to allow clients like LLDB to
unambiguously know which binary Swift module belongs to which compile
unit.

rdar://163302154
2025-10-23 17:10:50 -07:00
Erik Eckstein
7a7004927c Optimizer: remove the CopyForwarding pass
This pass removes `copy_addr` instructions.
However, it has some problems which causes compiler crashes.
It's not worth fixing these bugs because
1. Most copy_addrs can be eliminated by TempRValueElimination and TempLValueElimination.
2. Once we have opaque value we don't need copy_addr elimination, anyway.

rdar://162212460
2025-10-20 20:19:54 +02:00
Hamish Knight
8232345b68 [ASTScopes] Avoid relying on in SourceLoc for closures
Missed this in my previous patch, avoid relying on the `in` location
for closures with parameters and capture lists. Instead, form scopes
that start at the first element of the body. This fixes a crasher
uncovered by the fuzzer.
2025-10-17 15:21:53 +01:00
Adrian Prantl
b8f2d33ded [DebugInfo] Use the human-readable name as name of FwdDecls of unused structs
rdar://162080220
2025-10-06 17:54:57 -07:00
Adrian Prantl
305f0edb20 [DebugInfo] Properly nest types declared in extensions in the debug info
rdar://161923580
2025-10-03 16:12:24 -07:00
Charles Zablit
d61f71a3d0 [windows] fix DebugInfo tests 2025-10-01 16:53:25 +01:00
Charles Zablit
68b3b53ade [windows] create a Windows specific Debug/basic.swift test 2025-09-29 19:00:26 +01:00
swift-ci
d5a03fa0e4 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-26 22:36:42 -07:00
Erik Eckstein
2f124cf564 Remove the -enable-ossa-modules option.
OSSA modules are enabled by default.
The compiler still accepts this option but it has no effect.
2025-09-26 08:01:08 +02:00
Charles Zablit
01dae2eccf [windows][lldb] deactivate DebugInfo/basic.swift while it's being fixed 2025-09-09 17:46:59 +01:00
Shubham Sandeep Rastogi
35ed2080ba Revert "Temporarily disable debug info generation for async functions"
This reverts commit 8d763321c1.
2025-08-22 15:31:47 -07:00
swift-ci
fdc5b2bc73 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-14 19:55:30 -07:00
Mykola (Nickolas) Pokhylets
31470bbd1e Merge pull request #82732 from nickolas-pohilets/mpokhylets/weak-let-feature
Wrap SE-0481 into an upcoming feature until source incompatibilities are resolved
2025-08-14 23:59:28 +02:00
Ben Barham
8d763321c1 Temporarily disable debug info generation for async functions
Temporary workaround for a compiler crash in rebranch:
```
location of #dbg_declare must be a pointer or int
```
2025-08-13 15:36:02 -07:00
swift-ci
80c967ef0c Merge remote-tracking branch 'origin/main' into rebranch 2025-08-05 14:37:21 -07:00
Hamish Knight
396a6a8fe6 Enable InlineArray type sugar
Promote it from an experimental feature.

rdar://155607927
2025-08-04 15:16:30 +01:00
Mykola Pokhylets
89f8f8b9bf Wrap only changes related to the closure frontend logic 2025-08-02 20:24:46 +02:00