Commit Graph

40 Commits

Author SHA1 Message Date
Erik Eckstein
198d4ab0bb Optimizer: run TempRValueElimination also at Onone
Introduce a new pass MandatoryTempRValueElimination, which works as the original TempRValueElimination, except that it does not remove any alloc_stack instruction which are associated with source variables.

Running this pass at Onone helps to reduce copies of large structs, e.g. InlineArrays or structs containing InlineArrays.
Copying large structs can be a performance problem, even at Onone.

rdar://151629149
2025-05-23 18:56:56 +02:00
swift-ci
6ea9995a81 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-19 18:57:20 -07:00
Allan Shortlidge
cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00
Shubham Sandeep Rastogi
b14e8f0679 Fixup swift tests for DIExpression folding in Corosplit
The support for DIExpression constant folding has been added to the
Corosplit pass, this patch fixes up the swift tests that need to account
for the changes in the DIExpressions.
2024-09-10 15:02:02 -07:00
Felipe de Azevedo Piovezan
a321b0afe0 [DebugInfo] Update tests to expect new LLVM debug format 2024-07-23 11:06:12 -07:00
Felipe de Azevedo Piovezan
d11563022f [DebugInfo] Re-enable x86 async tests
With https://github.com/apple/llvm-project/pull/7787 merged, we can now finally
renable these tests, as the x86 swift async handling should be properly
preserved by the x86 instruction selector.

These tests contained some incorrect checks from a time where it was expecting
an entry value even in the entry funclet of coroutines. For example, it had
this:
```
CHECK-NEXT: [[ASYNC_REG:DW_OP_.*], DW_OP_plus_uconst 0x10, DW_OP_plus_uconst 0x8,
DW_OP_deref
```

Which tries to find some "async reg", but really matches anything. It worked by
accident on arm, but not on x86. The correct check is simply:

```
CHECK-NOT: OP_entry_value
```
2023-11-14 06:26:48 -08:00
Felipe de Azevedo Piovezan
d069ad80dd [DebugInfo] Disable failing x86 tests for rebranch 2023-09-01 14:31:37 -04:00
Felipe de Azevedo Piovezan
0d24362fa0 [DebugInfo] Update coroutine tests to expect fewer entry values 2023-08-17 10:36:27 -04:00
Felipe de Azevedo Piovezan
73f39af392 Merge remote-tracking branch 'origin/main' into felipe/fix_merge_opaque
The following tests required conflict resolutions, since upstream LLVM did a lot of
work to remove dbg.addr, and this work is not available to swift's main. At the
same time, swift's main changed these tests to enable opaque pointers.

```
both modified:   test/DebugInfo/async-let-await.swift
both modified:   test/DebugInfo/move_function_dbginfo.swift
both modified:   test/DebugInfo/move_function_dbginfo_async.swift
```

The conflicts are fairly easy to fix: we keep the "structure" of the CHECK
lines present in `next`, but replace all pointers with `ptr`.
2023-06-26 17:13:02 -04:00
Felipe de Azevedo Piovezan
1ed9df0a0c [DebugInfo] Update tests to use opaque ptrs 2023-06-16 15:05:44 -04:00
swift_jenkins
c3773953d1 Merge remote-tracking branch 'origin/main' into next 2023-06-15 17:38:08 -07:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -07:00
Felipe de Azevedo Piovezan
22aa61f13f [IRGenDebug] Remove generation of dbg.addr
These intrinsics were removed upstream LLVM and are equivalent to a dbg.value +
OP_deref.
2023-05-12 15:52:58 -04:00
Adrian Prantl
158772c2ab Rebase SILScope generation on top of ASTScope.
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.

This fixes

rdar://88274783

and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288
2023-04-04 15:20:11 -07:00
Adrian Prantl
bbcce343e8 Refactor testcase to be more robust against IR ordering changes
and also make it easier to debug.
2023-03-29 12:51:05 -07:00
Michael Gottesman
4a309575d7 [sil] Rename [moved] flag on debug_value/alloc_stack to moveable_value_debuginfo.
This is in preparation for wiring up debug info support for noncopyable
values. Originally this flag name made sense since it was set when we performed
consume operator checking. Now I am going to use it for noncopyable types as
well. I think the new name uses_moveable_value_debuginfo actually describes what
the flag is supposed to do, tell IRGen that the value may be moved since it
needs to use moveable value debug info emission.
2023-03-19 15:38:42 -07:00
Kavon Farvardin
2c7d9a5047 update tests given move-only types are enabled
the main things still left behind the experimental flag(s) are
- move-only classes (guarded by MoveOnlyClasses feature)
- noimplicitcopy
- the _borrow operator
2023-03-14 18:35:13 -07:00
Joe Groff
ecceb02e2a Implement consume x operator with the accepted SE-0366 syntax.
Implement it as a contextual operator that only parses as an operator when
followed by an identifier.
2023-03-01 17:37:54 -08:00
Michael Gottesman
f3081d0e9a [move-keyword] Put the move keyword behind the experimental move only flag for now.
Originally move when it was in the stdlib as _move was behind a keyword but we
moved it in front to allow for some testing. Now that we are going with a
keyword (which we can't leave in/deprecate) move it behind the move only
experimental flag until this gets through evolution.
2022-08-10 12:45:17 -07:00
Michael Gottesman
6493886e1d [move-keyword] Wire up support for the move keyword in lvalue/rvalue emission.
I also updated the move function tests to show that this is working. As a nice
bonus, I was able to enable all of the tests also in a non-optimized stdlib.
2022-08-08 12:50:42 -07:00
Michael Gottesman
6b5ca8444b Merge pull request #59036 from gottesmm/pr-c405f97a46f28343218bd193f0bb07dba1f4b5ba
[dbg-info][move-function] Add DWARF filecheck lines for conditional control flow tests.
2022-05-24 10:23:52 -07:00
Michael Gottesman
20e0e1542a [dbg-info][move-function] Add DWARF filecheck lines for conditional control flow tests. 2022-05-23 15:55:32 -07:00
Michael Gottesman
d49dd93d93 Fix bot by removing an EOL #4 from the FileCheck pattern that we don't need to pattern match and varies with asserts. 2022-05-10 10:16:09 -07:00
Michael Gottesman
211dc4977d Revert "Disable move_function_dbginfo_async.swift"
This reverts commit e95566d6aa.
2022-05-10 10:14:55 -07:00
Evan Wilde
e95566d6aa Disable move_function_dbginfo_async.swift
Disabled on rdar://93031874
2022-05-10 08:53:26 -07:00
Michael Gottesman
640d5902e6 [debug-info] Implement a global dataflow that propagates debug info for async vars and clones the dbg info after funclet points.
The overall flow of the pass is:

1. We walk over the blocks summarizing the debug info instruction the blocks gen
as well as whether or not the block had an async funclet edge with in it.

2. We then perform a simple forward iterative optimistic dataflow using
intersection at merge points. At points where we find after merging that we have
a conflict and thus need to stop propagation, we insert a debug_value undef.

3. We then walk the CFG again visiting only blocks that we know had async
funclet edges. We then walk each said block from top to bottom starting with the
propagating gen information and updating as we go, dumping the current set of
debug_info we are tracking after each coroutine funclet boundary.

rdar://85020571
2022-05-05 14:16:51 -07:00
Michael Gottesman
4b33a7bf4d [move-function] Re-enable async var debug info test converting some hard coded registers to use a regex.
Otherwise there is a potential that various versions of the compiler may use a
slightly different register causing the test to fail. We are not attempting to
test this so it just makes sense to make this a more general pattern.

rdar://91467528
2022-04-29 13:18:11 -07:00
Erik Eckstein
ef7a5b7ee9 tests: disable test/DebugInfo/move_function_dbginfo_async.swift again
It still fails on some CI jobs.

rdar://91467528
2022-04-11 09:45:48 +02:00
Michael Gottesman
b3d17ad360 [move-function-dbginfo] Modify a test slightly to fix the arm64 bots and re-enable that test.
The pattern started to fail here since the variable "m" is not a variable that
we moved so as a result we use heuristics to determine if it should become an
entry value.

Noting that we only pattern match "m" to ensure that we can easily check the
variable "k" afterwards (the thing that was actually moved), I just loosened the
pattern so that we validate that we found "m" but do not check "m"'s
location. This guarantees that on all platforms this will pattern match
appropriately.

rdar://91467528
2022-04-08 11:42:06 -07:00
Erik Eckstein
0d0f670666 tests: disable test/DebugInfo/move_function_dbginfo_async.swift
It fails on some CI jobs.

rdar://91467528
2022-04-08 09:15:57 +02:00
Michael Gottesman
c626d505e8 [debug-info] Update DWARF output for an upstream llvm change.
Previously, "m" was below "k". Now they flipped order.
2022-04-04 13:34:59 -07:00
Michael Gottesman
5f73a178ff [debug-info] Re-enable alloc-stack-hoisting on the move function tests.
I fixed the issues exposed with alloc-stack-hoisting for llvm.dbg.addr some time
ago but didn't update this test.

The test changes are b/c I did not fix this for llvm.dbg.declare resulting in us
losing the variable "m" in certain situations. "k" the thing we care about is
actually fine though.
2022-04-01 22:21:49 -07:00
Michael Gottesman
f9c1534d59 [debug-info] Edit the move debug info tests so we can test it both on macOS x86 and arm64. 2022-04-01 22:21:49 -07:00
Michael Gottesman
ea09951570 [move-function] Update async dbginfo for upstream LLVM change.
I changed code upstream so that we are always guaranteed to have an entry value
for async arguments on r14. The main effect of this is that it eliminates a bunch of
cases where r14 would be spilled simplifying weird patterns in the test cases.

I also added additional commentary to the Dwarf part of the test cases
explaining what the patterns are checking and why.
2022-03-29 22:00:16 -07:00
Michael Gottesman
ef711743bf [move-function] Add dwarfdump filecheck tests that show that if we have a var, we get the debug info that we expect.
I already had tests that validated we got the corret IR. This tests that from
the debug info perspective, we have sane output.
2022-03-23 15:50:03 -07:00
Michael Gottesman
5acbeed5a4 [debug-info-canonicalization] Add support for propagating debug info from alloc_stack. 2022-03-22 12:34:15 -07:00
Michael Gottesman
50a0b91560 [move-function] Propagate debug_value undef rather than treat it as an invalidation.
The reason that I am doing this is that otherwise in funclets we may show an
invalidated value being available if we have an llvm.dbg.addr for a reinit value
later in the funclet. This ensures that we have the undef at the beginning of
the funclet so before that llvm.dbg.addr we will properly show no value.
2022-03-21 14:20:53 -07:00
Michael Gottesman
7091c87f67 [move-function] Update a test now that I have merged in the better debug info salvaging while coroutine splitting into LLVM.
Thanks again to Adrian Prantl for his help with this work!
2022-03-21 14:20:53 -07:00
Michael Gottesman
9da5a4b91f [move-function-addr] Fix a subtle bug where we were not inserting debug info in the case of vars.
The specific problem was that we assume that SILGen will only emit a single
debug_value for a value. This condition breaks once we start processing since we
are inserting extra debug_value when reiniting. The end result is that we do not
insert the undef, addr. To fix this I just hoisted out this computation upon the
address before we do anything.
2022-03-21 14:20:53 -07:00
Michael Gottesman
e1c4e1045f [move-function] Update the behavior for debug intrinsics on values in the coroutine frame.
This uses the previous simple dominance dbg info propagation implementation in
the previous commit.

I fix in the next commit the debug info for the last move/reinit in the var
test.
2022-03-21 14:20:53 -07:00