Commit Graph

2768 Commits

Author SHA1 Message Date
Nate Chandler
2cbc13aca6 [CanonInst] Process "at" load after rewriting.
When a load/load_borrow is canonicalized, canonicalization should
continue from where the load was before rather than the first
instruction that was after it.  Enables narrowing the load through
a sequence of projections.
2024-03-13 17:42:33 -07:00
Nate Chandler
9c3d941a4a [Gardening] Deleted stale comment. 2024-03-13 17:42:33 -07:00
Erik Eckstein
4316a7cf05 ConstExpr: look through sendable function conversions 2024-03-13 09:58:31 +01:00
Meghana Gupta
2d27ec581c Merge pull request #72267 from meg-gupta/enablesilcombineempty
Enable SILCombine of inject_enum_addr for empty types
2024-03-12 20:34:09 -07:00
Michael Gottesman
f2b5b86e2e [region-isolation] Learn how to find variable names around phi arguments.
With this, the only remaining "task or actor isolated" error is due to changes I
need to land around async let.
2024-03-12 13:43:02 -07:00
Meghana Gupta
50f0fd232c Enable SILCombine of inject_enum_addr for empty types 2024-03-12 13:01:44 -07:00
Michael Gottesman
ec81ecdbe6 [region-isolation] Eliminate more of the 'task or actor isolated value cannot be transferred' warning.
Specifically, I had to teach the variable name inferrer how to infer through
unchecked_enum_data and unchecked_take_enum_data_addr.
2024-03-12 12:26:55 -07:00
Nate Chandler
7db84f25b1 [NFC] SIL: Typed move_value's isLexical. 2024-03-08 22:27:52 -08:00
Nate Chandler
9f6c30919b [NFC] SIL: Typed begin_borrow's isLexical. 2024-03-08 22:27:50 -08:00
cui fliter
127077b3aa chore: fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 17:23:22 +08:00
Meghana Gupta
59153a0a39 Merge pull request #72019 from meg-gupta/instdeleterassertfix
Update canTriviallyDeleteOSSAEndScopeInst and a related assertion
2024-03-01 15:54:30 -08:00
Meghana Gupta
eb7772ca1a Update canTriviallyDeleteOSSAEndScopeInst and a related assertion
A destroy_value of Optional.none can be deleted.

A move-only struct with deinit has a non trivial SILType but OwnershipKind::None,
such values cannot be deleted.
2024-03-01 12:15:14 -08:00
Adrian Prantl
23e6e54ca1 Merge pull request #71925 from Snowy1803/recursive-sroa
[DebugInfo] Add debug info support for recursive SIL SROA
2024-02-28 20:05:57 -08:00
Emil Pedersen
49ee148a2d [DebugInfo] Add support for chained fragments in salvageDebugInfo 2024-02-28 14:41:19 -08:00
Emil Pedersen
0faa055c11 [DebugInfo] Add debug info support for recursive SIL SROA
This removes the restriction that only one fragment is allowed at
the end of a SIL DIExpression.

rdar://100046900
2024-02-28 12:48:17 -08:00
Michael Gottesman
11f0ff6e32 [sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.

rdar://123484595
2024-02-27 13:14:47 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Michael Gottesman
a703f225d7 Merge pull request #71823 from gottesmm/strong_transferring
[region-isolation] Improve errors around strong transferring and wordsmith main error
2024-02-22 17:03:39 -08:00
Joe Groff
161183cbc4 Merge pull request #71803 from jckarter/begin-borrow-fixed-switch-subject
SIL: Enclose switch subjects in a new begin_borrow [fixed] variant.
2024-02-22 14:45:17 -08:00
Michael Gottesman
e21c0a6c39 [sil] Teach variable name inference how to look through more instructions. 2024-02-22 13:50:06 -08:00
Michael Gottesman
e1ecd8b54d [sil] Teach VariableNameUtils how to look through function conversion thunk patterns. 2024-02-22 13:50:06 -08:00
Michael Gottesman
9154082d12 [sil] Teach VariableNameInferrer how to look through /all/ accessors. 2024-02-22 13:50:06 -08:00
Joe Groff
d75a62ce64 SIL: Enclose switch subjects in a new begin_borrow [fixed] variant.
We want to preserve the borrow scope during switch dispatch so that move-only
checking doesn't try to analyze destructures or consumes out of it. SILGen
should mark anywhere that's a potential possibility with its own marker so that
it gets borrow checked independently.
2024-02-21 20:41:20 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Erik Eckstein
fa85745f2d ConstantFolding: fix wrong constant folding for float-infinity compares
Only if the other operand of a comparison with Inf is a literal we can be sure that it's not Inf or NaN.

Fixes a miscompile
rdar://122605966
2024-02-14 16:09:23 +01:00
John McCall
d5142668f4 SIL and IRGen support for @isolated(any). SILGen to come. 2024-02-13 03:04:13 -05:00
Slava Pestov
db60caecc0 Merge pull request #71441 from slavapestov/specializer-loop-rdar121867690
SILOptimizer: Fancier 'too complex' check to prevent runaway specialization
2024-02-08 13:54:23 -05:00
Slava Pestov
f79b621ad5 SILOptimizer: Fancier 'too complex' check to prevent runaway specialization
We weren't looking at the length of an opaque archetype's type parameter,
which could lead to unbounded growth in the number of emitted specializations.

Fixes rdar://problem/121867690.
2024-02-08 09:54:25 -05:00
Nate Cook
e317febc9d Revert "Allow normal function results of @yield_once coroutines (#69843)"
This reverts commit aa5b505014.
2024-02-07 14:57:31 -06:00
Michael Gottesman
1795f7f661 Merge pull request #71429 from gottesmm/fixes-for-stdlib
[region-isolation] Fixes that enable the stdlib to build with region based isolation
2024-02-07 09:47:11 -08:00
Anton Korobeynikov
aa5b505014 Allow normal function results of @yield_once coroutines (#69843)
This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

For now only direct results are supported, but this seems to be enough for autodiff purposes.
2024-02-06 22:13:15 -08:00
Michael Gottesman
d4f727adde [region-isolation] Add support for identifying names when a temporary is initialized with a store. 2024-02-06 16:49:30 -08:00
Nate Chandler
b535725647 [NFC] SIL: Renamed SpecifyTestInst.
The instruction's spelling was changed to `specify_test` but the class
name wasn't updated from `TestSpecificationInst`.  Update it here.
2024-02-06 16:29:09 -08:00
Michael Gottesman
7df13b3c1f [sil] Refactor VariableNameUtils for handling more kinds of writes to temporaries. 2024-02-06 16:18:34 -08:00
Michael Gottesman
2010579b02 [sil] Add basic test support for variable name inference. 2024-02-06 15:21:11 -08:00
Michael Gottesman
a569160f21 [sil] Refactor out the variable name inferer from MoveOnlyDiagnostics.cpp -> VariableNameUtils.
I am going to reuse this for TransferNonSendable. In the process I made a few
changes to make it more amenable to both use cases and used the current set of
tests that we have for noncopyable types to validate that I didn't break
anything.
2024-02-06 13:42:35 -08:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Erik Eckstein
874360e719 GenericCloner: make sure that we can always specialize in mandatory mode
This may involve changing the linkage of the specialized function.
If called from a serialized function we cannot make the specialized function shared and non-serialized.
The only other option is to keep the original function's linkage.

rdar://121675461
2024-02-02 07:28:42 +01:00
Meghana Gupta
4f362b2be1 Merge pull request #71193 from meg-gupta/disablecheckedcastjumpthread
Disable checked_cast_br jump threading in ossa temporarily
2024-01-26 20:40:33 -08:00
Meghana Gupta
7e03fd27e8 Disable checked_cast_br jump threading in ossa temporarily
This was enabled in ossa recently.
There are 2 bugs:
- In CheckedCastBrJumpThreading::Edit::canRAUW, we don't check for canFixUpOwnershipForRAUW.
- Currently modifyCFGForSuccessPreds has to be called after modifyCFGForFailurePreds.
But modifyCFGForFailurePreds can modify cfg in a way such that OSSA RAUW can no longer be done in modifyCFGForSuccessPreds.

This will require an algorithmic change, disabling temporarily to unblock rdar://121484645
2024-01-26 14:46:46 -08:00
Arnold Schwaighofer
edd7eaa0d7 OSLog: os_log strings should be in the __oslogstring section on machO
rdar://121384422
2024-01-26 08:30:56 -08:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Kavon Farvardin
b8cd7effeb Merge pull request #70866 from kavon/ncgenerics-stdlib-building-v4
Build Stdlib with Noncopyable Generics (Part 4)
2024-01-25 07:09:38 -08:00
Meghana Gupta
c3c7465a44 Merge pull request #71125 from meg-gupta/rdar121485860
Don't duplicate builtin "once"
2024-01-25 01:49:15 -08:00
Meghana Gupta
1369043c6c Don't duplicate builtin "once"
Fixes rdar://121485860
2024-01-24 14:40:43 -08:00
Kavon Farvardin
107475b224 SILType: Avoid asking ASTType if it is Noncopyable
It's better to ask SILType if it is MoveOnly than go to the AST type and
 ask if it is noncopyable, because some types in SIL do not have a
 well-defined notion of conformance in the AST.
2024-01-23 22:42:38 -08:00
Kavon Farvardin
a72925248b [NCGenerics] fix a few isNoncopyable calls
These calls were being made on types either with a type parameter, or a
SIL-only type that doesn't actually have conformances.

In such cases, it's better to use SILType's move-only query methods.
2024-01-23 22:42:38 -08:00
Dario Rexin
6bfbaa1fb4 [SILOpt] Fix layout based pre-specialization with marker protocols (#71038)
Marker protocols can be ignored in the specialization, because they have no witness and the conformance will be checked before the specialization is applied.

Also fixes an issue where multiple requirements on the same type caused type mismatches in the erased signature.
2024-01-22 08:40:08 -08:00
Slava Pestov
166d059625 Merge pull request #70937 from slavapestov/rename-conformance-lookup
TypeChecker::conformsToProtocol() => ModuleDecl::checkConformance()
2024-01-16 22:21:04 -05:00