Commit Graph

9332 Commits

Author SHA1 Message Date
Slava Pestov
a1462ef184 SIL: Promote removeDeadBlock() from SILOptimizer to a method on SILBasicBlock 2024-05-21 13:52:58 -04:00
Erik Eckstein
941a7427d8 handle upcast instructions in statically initialized globals
This allows statically initialized multi-dimensional arrays in embedded swift.
2024-05-21 13:33:06 +02:00
Ellie Shin
80855c872b Fix global accessor and class linker errors.
Add global accessors to symbol list if VarDecl is fragile, i.e.
is non-resilient or its defining module allows non-resilient
access.

Don't set the class decl to hidden if it's in a package resilience
domain; even though its defining module is built resilently, the
class symbol should be visible across modules if they are in the
same package with resilience-bypass optimization. In such case,
treat its SubclassScope to Internal.

Resolves rdar://127321129
2024-05-20 14:39:37 -07:00
Arnold Schwaighofer
e415c1a42f [SIL] [Package CMO] Remove resilience bailout that is an artifact of incremental development 2024-05-20 08:49:17 -07:00
Slava Pestov
c7c244e16a Merge pull request #73712 from slavapestov/pack-expansion-closures-part-6
Pack expansion closures, part 6
2024-05-18 07:41:44 -04:00
Michael Gottesman
d759ec97ea Merge pull request #73696 from gottesmm/rdar128216574
[sending] Add support for 'sending'
2024-05-18 05:42:41 -04:00
Slava Pestov
4fd4975961 SIL: Allow getGenericSignatureWithCapturedEnvironments() on all SILDeclRefs
The main entry point _does_ have a generic signature, it's just empty.
2024-05-17 15:16:11 -04:00
Slava Pestov
749c2af7e2 SIL: Add TypeConverter::getSubstitutionMapWithCapturedEnvironments() 2024-05-17 15:16:11 -04:00
Slava Pestov
e8714e7e5a SIL: Split off reclaimUnresolvedLocalArchetypeDefinitions()
Just to be extra safe, I'm only going to call this when captured local archetypes
are present.
2024-05-17 15:16:11 -04:00
Arnold Schwaighofer
09a9ba47e7 SIL: Ignore AEIC on package declaration inside declarations without effective public access
Quoting Slava:

"The AST-level access is allowed to be 'more public'. I honestly don't
know why, but it's always worked this way and the 'lowered' access
levels must always intersect the access levels of the parents but with
@uic, @aeic and @inlinable, that means just ignoring those attributes if
some enclosing context is not @uic"

rdar://128270848
2024-05-17 08:36:54 -07:00
Slava Pestov
9cf4d61ece Merge pull request #73685 from slavapestov/pack-expansion-closures-part-5
Pack expansion closures, part 5
2024-05-17 07:42:06 -04:00
eeckstein
a7bf6540b2 Merge pull request #73623 from eeckstein/statically-initialized-array-variables
Optimizer: support static initialization of global arrays
2024-05-17 09:30:55 +02:00
Slava Pestov
a40a6e215d SIL: Fix assertion failure after deleting instructions that contain unresolved local archetypes
We maintained a counter of the number of pending local archetypes
that had not yet been defined. However, if an instruction that
references a pending local archetype was deleted before the
local archetype was defined, the counter would never decrement.

Before reading the counter value, garbage collect any inserted
placeholders that have no uses. These correspond to pending
local archetypes that are no longer in use and will never be
defined.
2024-05-16 23:00:44 -04:00
Slava Pestov
60615b8a52 SIL: Handle captured environments in SILFunction::mapTypeIntoContext() 2024-05-16 23:00:44 -04:00
Slava Pestov
c1ce0d72c2 SIL: Store captured environments in SILFunction 2024-05-16 23:00:44 -04:00
nate-chandler
a570286201 Merge pull request #73647 from nate-chandler/rdar128077404
[PrunedLiveness] Fix boundary check for dead-ends.
2024-05-16 19:45:41 -07:00
Adrian Prantl
c7644cd06c Merge pull request #73674 from Snowy1803/rdar128091794
[SILVerifier] Disable debug info type assertion for boxes
2024-05-16 16:59:58 -07:00
Nate Chandler
9d42d69c0a [PrunedLiveness] Fix boundary check for dead-ends.
Consider dead, dead-end blocks within the availability boundary to be
within the boundary.

rdar://126965232
2024-05-16 15:53:06 -07:00
Erik Eckstein
f3dafbff2f SIL: make unchecked_ref_cast buildable in a global variable initializer 2024-05-16 21:34:35 +02:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
Augusto Noronha
e5a1d61ed8 Merge pull request #73145 from augusto2112/keep-for-deb-def
Fix functions not being kept for debugger
2024-05-16 11:32:43 -07:00
Ellie Shin
1257db7342 Merge pull request #73566 from apple/elsh/sil-new-attr
[SIL] Add [serialized_for_package] to control package-wide resilience domain in Package-CMO.
2024-05-16 10:17:35 -07:00
Emil Pedersen
f704a0cb09 [SILVerifier] Disable debug info type assertion for boxes
rdar://128091794
2024-05-16 09:58:22 -07:00
Ellie Shin
0e88dc2742 Initialize SerializedForPackage bit field 2024-05-15 21:44:36 -07:00
Nate Chandler
cd14f4cbed [NFC] PrunedLiveness: Factor out duplicated method
In preparation to make it more complex.
2024-05-15 19:23:11 -07:00
Nate Chandler
aa89c015b7 [Test] Basic tests for DeadEndBlocks. 2024-05-15 19:23:11 -07:00
Ellie Shin
e632c5ec96 -Add package-cmo check to bypassResilienceInPackage method.
-Fix SILDeclRef getLinkageLimit() for GlobalAccessor to return
Limit::None if bypassResilienceInPackage is enabled.
2024-05-15 16:25:16 -07:00
Ellie Shin
2d81d0f2c7 [SIL] Add a new attribute [serialized_for_package] to support
package-wide resilience domain if Package CMO is enabled.

The purpose of the attribute includes:
- Indicates that certain types such as loadable types are
allowed in serialized functions in resiliently built module
if the optimization is enabled, which are otherwise disallowed.
- Used during SIL deserialization to determine whether such
functions are allowed.
- Used to determine if a callee can be inlined into a caller
that's serialized without package-cmo, e.g. with an explicit
annotation like @inlinable, where the callee was serialized
due to package-cmo.

Resolves rdar://127870822
2024-05-15 12:43:15 -07:00
Erik Eckstein
cb249e8956 SIL Parser: abort parsing a sil_global if there is an error in an initializer instruction
Otherwise the parser ends up printing errors indefinitely.
2024-05-15 17:43:19 +02:00
Augusto Noronha
529845056b Fix functions not being kept for debugger
At Onone, many types of functions (anything user written, compiler
generated setters and getters, etc), should be kept in the final
binary so they're accessible by the debugger.

rdar://126763340
2024-05-14 10:31:44 -07:00
Andrew Trick
e3540f0f6d Rename accesspath unit test.
If was called accesspath-base, but it's primarily about the uses of the accesspath, not the base. Very confusing.
2024-05-14 10:31:24 -07:00
Erik Eckstein
fcc03b7046 SIL: fix runtime effects of initializing store
An initializing store is not a copy and therefore doesn't perform ref counting operations

Fixes a false performance error when using non-copyable types.
https://github.com/apple/swift/issues/73582
2024-05-14 09:29:42 +02:00
Andrew Trick
4272552080 Merge pull request #73577 from atrick/fix-init-objc-block
Fix initialization of imported ObjC block types.
2024-05-13 16:57:00 -07:00
Michael Gottesman
4412fff99d [region-isolation] Fix verifier check.
After following up with @slavapestov and @xedin, I was right to be suspicious of
my changes here.

Instead of attempting to hard code this, I do the right thing and I map the
relevant type into the function's generic context and then do the check. This
ensures that when isAnyActorType() performs the conformance check,
ModuleDecl::lookupConformance() has a generic signature to work with.
2024-05-13 13:43:51 -07:00
Michael Gottesman
4789cc7e55 Merge pull request #73556 from gottesmm/rdar127295657_127844737
[region-isolation] When inferring isolation for an argument, handle non-self isolated parameters as well as self parameters that are actor isolated.
2024-05-13 11:18:51 -07:00
Emil Pedersen
15cab3a19f Merge pull request #73555 from Snowy1803/complete-getvarinfo
[DebugInfo] Return complete variable info from getVarInfo by default
2024-05-13 10:32:43 -07:00
Michael Gottesman
f51a050af4 [sil] Restrict sil_isolated to only being able to be applied to any actor types.
I also added some docs to SIL.rst about sil_isolated as well.
2024-05-11 17:14:49 -07:00
Michael Gottesman
c1d0c8cd2d [region-isolation] Avoid using the function isolation when determining isolation of a sil_isolated parameter.
It is unnecessary and seems to be slightly out of sync sometimes around
closures.
2024-05-11 16:34:50 -07:00
Andrew Trick
c112e03a32 Fix initialization of imported ObjC block types.
This fixes a SIL ownership verification error when importing structs like:

typedef bool (^boolBlock)(void);

struct objc_bool_block {
  __unsafe_unretained boolBlock block;
};

Fixes rdar://126142109 (Found an operand with a value that is not compatible
with the operand's operand ownership kind map)
2024-05-10 17:45:11 -07:00
Emil Pedersen
0be63d0422 [DebugInfo] Return complete variable info from getVarInfo by default
getVarInfo() now always returns a variable with a location and scope.
To opt out of this change, getVarInfo(false) returns an incomplete variable.
This can be used to work around bugs, but should only really be used for
printing.

The complete var info will also contain the type, except for debug_values,
as its type depends on another instruction, which may be inconsistent if
called mid-pass.

All locations in debug variables are now also stripped of flags, to avoid
issues when comparing or hashing debug variables.
2024-05-10 16:12:56 -07:00
Emil Pedersen
ac865eb2f9 [SILVerifier] Verify that debug variable types match the SSA type 2024-05-10 16:12:56 -07:00
Michael Gottesman
085f3d745e [region-isolation] Return the old way of printing ActorIsolation for use when printing SIL instructions. 2024-05-10 15:59:25 -07:00
Michael Gottesman
9bfb3b7ee7 [region-isolation] Some small gardening updates in preparation for the next commit.
Specifically, I added a few helper methods and improved the logging printing.
This all makes the next commit a more focused commit.
2024-05-10 15:33:44 -07:00
nate-chandler
e74cfb02ae Merge pull request #73386 from nate-chandler/lifetime-completion/20240501/2
[LifetimeCompletion] Require boundary to be specified.
2024-05-10 07:18:22 -07:00
nate-chandler
1b848aca09 Merge pull request #73560 from nate-chandler/gardening/20240509/1
[Gardening] SIL: Verifier messages use "lifetime".
2024-05-09 23:13:07 -07:00
Nate Chandler
bd9f9eae91 [Gardening] SIL: Verifier messages use "lifetime".
Uses aren't life ending.
2024-05-09 17:50:29 -07:00
Egor Zhdan
0971654de2 Merge pull request #73513 from apple/egorzhdan/const-ref-bool-crash
[cxx-interop] Do not crash when passing `Bool` as `const T&` parameter
2024-05-09 18:44:37 +01:00
Joe Groff
2d61e3d26b Merge pull request #73531 from jckarter/forwarding-force-unwrap
SILGen: Treat Optional `x!` force unwrapping as a forwarding operation.
2024-05-09 08:35:29 -07:00
Egor Zhdan
5b5ffde79e [cxx-interop] Do not crash when passing Bool as const T& parameter
The type bridging logic assumed that if a value of type `Swift.Bool` is passed to a Clang function as an argument, then the type of the parameter must be a Clang built-in type (usually `_Bool`). This is not always correct. For instance, the type might be a templated const reference.

rdar://125508505
2024-05-09 15:28:33 +01:00
Stephen Canon
396b055369 Implement Builtin.freeze for integer and integer-vector types. (#73519)
* Implement Builtin.freeze for integer and integer-vector types.

https://llvm.org/docs/LangRef.html#freeze-instruction

> If the argument is undef or poison, ‘freeze’ returns an arbitrary, but fixed, value of type ‘ty’. Otherwise, this instruction is a no-op and returns the input argument. All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values.

It's most importation for integer and integer-vector types because floating-point results are generally not poison (except in the case of conversion from poison integer values).
However, we might want to implement this for other types as well in the future.

* Make builtin.freeze TrivialUse

Also fix filecheck patterns for its test to work with asserts build.
2024-05-09 06:41:02 -04:00