Commit Graph

2768 Commits

Author SHA1 Message Date
Slava Pestov
43c7310288 SILOptimizer: Move combineSubstitutionMaps() to Devirtualize.cpp 2024-08-29 16:18:14 -04:00
swift-ci
93422392cc Merge remote-tracking branch 'origin/main' into rebranch 2024-08-28 18:33:33 -07:00
Slava Pestov
f2fff10cc9 SIL: Synchronous local functions don't need to capture the isolation parameter
Also, move this rule from the computation of lowered captures in SIL,
to the computation of AST captures in Sema. This allows us to
correctly handle the case where an async function nests inside a
sync function. It also removes a special case that was added recently
to cope with a generic `self` type.

Fixes rdar://129366819.
2024-08-28 17:03:49 -04:00
swift-ci
cb27c2a61c Merge remote-tracking branch 'origin/main' into rebranch 2024-08-26 21:35:11 -07:00
Erik Eckstein
b54117c22d GenericSpecializer: drop unused indirect arguments.
If there is no read from an indirect argument, this argument has to be dropped.
At the call site the store to the argument's memory location could have been removed (based on the callee's memory effects).
Therefore, converting such an unused indirect argument to a direct argument, would load an uninitialized value at the call site.
This would lead to verifier errors and in worst case to a miscompile because IRGen can implicitly use dead arguments, e.g. for getting the type of a class reference.
2024-08-26 11:19:12 +02:00
Erik Eckstein
c8e74b8393 Generic specialization: change the mangling for dropped metatype arguments
Instead of adding a "flag" (`m` in `...Tgm5`) make it more generic to allow to drop any unused argument.
Add all dropped arguments with a `t<n-1>` (where `<n-1>` is empty for n === 0). For example `...Ttt2g5`.
2024-08-26 10:43:15 +02:00
swift-ci
5567d948a7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-25 05:15:06 -07:00
Michael Gottesman
00519669af Merge pull request #76076 from gottesmm/rdar134623227
[region-isolation] Treat sending indirect_results as disconnected even if it is a return value of an actor isolated function.
2024-08-25 08:02:25 -04:00
swift-ci
d1f642c28f Merge remote-tracking branch 'origin/main' into rebranch 2024-08-24 19:34:29 -07:00
Michael Gottesman
3e27bfc03b [region-isolation] Treat sending indirect_results as disconnected even if it is a return value of an actor isolated function.
rdar://134623227
2024-08-24 14:02:41 -04:00
Michael Gottesman
49eee05647 [region-isolation] Treat as Sendable values that are meant to be ignored since they are marked with preconcurrency
rdar://133531625
2024-08-24 13:14:39 -04:00
swift-ci
1b56b27c3b Merge remote-tracking branch 'origin/main' into rebranch 2024-08-22 12:34:33 -07:00
Erik Eckstein
b7e5ec825a MandatoryPerformanceOptimizations: force inlining of transparent functions and de-virtualization
Do this even if the function then contains references to other functions with wrong linkage. Instead fix the linkage later.
Fixes a false error in embedded swift.

rdar://134352676
2024-08-22 09:15:14 +02:00
swift-ci
e27edcada1 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-21 16:49:14 -07:00
Slava Pestov
ae77d6f0c1 AST: Replace one-off predicates with SubstitutionMap::getRecursiveProperties() 2024-08-21 13:19:10 -04:00
swift-ci
b08f7a1307 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-20 13:58:19 -07:00
Slava Pestov
b434c9fb56 Merge pull request #75984 from slavapestov/clean-up-opened-archetype
Clean up OpenedArchetypeType construction and more
2024-08-20 16:52:55 -04:00
Slava Pestov
ff308e9510 AST: Remove TypeBase::openAnyExistentialType() 2024-08-20 12:15:27 -04:00
Slava Pestov
0c2f28fd3d AST: Remove GenericSignature parameter from OpenedArchetypeType::get() 2024-08-20 12:15:27 -04:00
swift-ci
97f3a1b5e1 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-19 15:15:58 -07:00
Michael Gottesman
582144a017 Merge pull request #75960 from gottesmm/pr-d0a4bbf70b470c53c7f2435ee53051da8fd643d3
[region-isolation] Move the region isolation logging decls out of PartitionUtils.h -> RegionIsolation.h
2024-08-19 15:06:51 -07:00
Michael Gottesman
b477433a20 [region-isolation] Move the region isolation logging decls out of PartitionUtils.h -> RegionIsolation.h
These do not specifically have to do with PartitionUtils... they are really
logging options for the whole infrastructure, so it makes sense to have them in
the a different file.
2024-08-19 11:28:55 -07:00
swift-ci
a5ec343a08 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-17 06:14:34 -07:00
Slava Pestov
b601c294ac AST: Replace remaining uses of Type::transform() with transformRec() 2024-08-12 16:05:43 -04:00
Ben Barham
467e528200 Merge remote-tracking branch 'origin/main' into manual-rebranch-merge
Conflicts:
  - `lib/Serialization/ModuleFormat.h` bumped version to account for
    differences between main and rebranch.
2024-08-09 15:22:39 -07:00
Slava Pestov
b2ff3c9fa8 SILOptimizer: Clean up emitDistributedActorSystemWitnessCall() 2024-08-08 23:35:58 -04:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
swift-ci
43bd40f4d7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-08 19:11:05 -07:00
Andrew Savonichev
5aa9d3e29b Add partial_apply support for coroutines (#71653)
The patch adds lowering of partial_apply instructions for coroutines.

This pattern seems to trigger a lot of type mismatch errors in IRGen, because
coroutine functions are not substituted in the same way as regular functions
(see the patch 07f03bd2 "Use pattern substitutions to consistently abstract
yields" for more details). 

Other than that, lowering of partial_apply for coroutines is straightforward: we
generate another coroutine that captures arguments passed to the partial_apply
instructions. It calls the original coroutine for yields (first return) and
yields the resulting values. Then it calls the original function's continuation
for return or unwind, and forwards them to the caller as well.

After IRGen, LLVM's Coroutine pass transforms the generated coroutine (along with
all other coroutines) and eliminates llvm.coro.* intrinsics. LIT tests check
LLVM IR after this transformation.

Co-authored-by: Anton Korobeynikov <anton@korobeynikov.info>
Co-authored-by: Arnold Schwaighofer <aschwaighofer@apple.com>
2024-08-08 18:36:42 -07:00
swift-ci
7525555b15 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 19:55:01 -07:00
Michael Gottesman
2dd1ef2322 Merge pull request #75759 from gottesmm/variable-name-utils-refactor
[variable-name-utils] Change internal representation to use StringRef instead of a SILValue
2024-08-07 19:37:46 -07:00
swift-ci
5e74c499bf Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 16:55:20 -07:00
Michael Gottesman
d263bf0b41 Merge pull request #75760 from gottesmm/pr-d43ef71ddf97306ef50962d71b306ca6b7ce0b3d
[region-isolation] Make logging and debug tooling appear in non-asserts builds.
2024-08-07 16:40:29 -07:00
swift-ci
5be82afce7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 16:34:44 -07:00
Michael Gottesman
1fbc930cdd [region-isolation] Make logging and debug tooling appear in non-asserts builds.
This will just help me to more quickly triage without needing to compile an
asserts compiler.
2024-08-07 13:35:18 -07:00
Michael Gottesman
0039b286b5 [variable-name-inference] Eliminate the old value representation and just use StringRef. 2024-08-07 13:14:50 -07:00
Michael Gottesman
98fd04c3cd [variable-name-utils] Convert function_ref and method_inst to use the new StringRef form 2024-08-07 13:14:50 -07:00
Michael Gottesman
aa5db257ce [variable-name-utils] Move destructure and function arg to the new string ref representation. 2024-08-07 13:14:50 -07:00
Michael Gottesman
63b67389b0 [variable-name-utils] Convert all DebugVarCarryingInst|VarDeclCarryingInst to the new representation of storing a StringRef. 2024-08-07 13:14:50 -07:00
Michael Gottesman
76f67cf092 [variable-name-utils] Convert all gep like instructions except ref_element_addr to be put on the stack as StringRefs instead of values. 2024-08-07 13:14:50 -07:00
Michael Gottesman
765d3ba039 [variable-name-utils] Convert debug_value to StringRef form.
Just doing the refactoring.
2024-08-07 13:14:50 -07:00
Michael Gottesman
3d85f47671 [variable-name-utils] Store a std::variant instead of a pointer union and add the ability to append StringRef.
CONTEXT: This code works by building up a stack of SIL values of values that
need to be transformed into a StringRef as part of generating our name path and
then as a second phase performs the conversion of those values to StringRef as
we pop from the stack.

This is the first in a string of commits that are going to refactor
VariableNameUtils so that the stack will only contain StringRef instead of SIL
entities. This will be accomplished by moving the SIL value -> StringRef code
from the combining part of the algorithm (where we drain the stack) to the
construction of the stack.

The reason why I am doing this is two fold:

1. By just storing StringRef into the stack I am simplifying the code. Today as
mentioned above in the context, we gather up the SILValue we want to process and
then just convert them to StringRef. This means that any time one has to add a
new instruction, one has to update two different pieces of code. By trafficking
in StringRef instead, one only has to update one piece of code.

2. I want to add some simple code that allows for us to get names from closures
which would require me to recurse. I am nervous about putting
values/instructions from different functions in the same data structure. Today
it is safe, but it is bad practice. Instead, by just using StringRef in the
stack, I can avoid this problem.
2024-08-07 13:14:50 -07:00
Michael Gottesman
2e138024a8 [variable-name-utils] Look through convert function when finding names. 2024-08-07 13:10:54 -07:00
swift-ci
d928d906eb Merge remote-tracking branch 'origin/main' into rebranch 2024-08-02 15:16:22 -07:00
Ben Barham
3a4c1b8d51 Merge pull request #75633 from bnbarham/final-rebranch-pass
Changes to compile on macOS for stable/20240723 LLVM
2024-08-01 16:28:51 -07:00
Michael Gottesman
a75501e985 [region-isolation] Eliminate the last non-SIL test case usage of SILIsolationInfo::getWithIsolationCrossing().
The reason that I am changing this code is that getWithIsolationCrossing is a
bad API that was being used to infer actor isolation straight from an ApplyExpr
without adding an actor instance. This can cause us to reject programs
unnecessarily if we in other parts of the code correctly infer the SILValue
actor instance for the isolation.

Rather than allow for that, I am removing this code and I improved the rest of
the pattern matching here to ensure that we handled that with the normal actor
instance inferring code. This will prevent this type of mismerge from happening
by mistake. I fixed up the changes in the test cases.

The only usage of this left is for ApplyIsolationCrossings parsed straight from
SIL that we use only when testing. This is safe since if a test writer is using
the parsed SIL in this manner, they can make sure that mismerges do not happen.
2024-07-31 13:10:01 -07:00
Ben Barham
64579adf24 [SILOpt] Rename GetUndefVal to GetPoisonVal
This function was renamed in upstream LLVM.
2024-07-31 08:57:02 -07:00
swift-ci
b485d7f708 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-31 05:17:38 -07:00
Erik Eckstein
9d6643b07e Optimizer: fix a crash in keypath folding
The KeyPathProjector utility crashed for keypaths  to stored objectiveC properties.

rdar://132780588
2024-07-30 16:59:31 +02:00
swift-ci
11f8fa2d69 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-29 10:55:36 -07:00