Commit Graph

6583 Commits

Author SHA1 Message Date
Allan Shortlidge
9a1a2c3b9d Merge pull request #64644 from tshortli/strip-unavailable-code
Introduce `-unavailable-decl-optimization`
2023-03-28 08:53:48 -07:00
Daniel Rodríguez Troitiño
eabafdf7d4 [NFC] Remove extra comma inside the macros.
The macros are all used with a semicolon after the macro invocation, so
the comma inside the macro and outside the macro are redundant. This
causes a warning in modern compilers with extra warnings enabled that it
is quite spammy in the output.

Remove the commas inside the macro to avoid the warning. This should not
have any meningful effect in the result.
2023-03-27 15:59:23 -07:00
Allan Shortlidge
ada0f09615 SILGen: Implement 'complete' unavailable decl optimization.
Avoid SIL lowering for declarations marked unavailable when
`-unavailable-decl-optimiation=complete` is specified.

Part of rdar://106674022
2023-03-27 11:40:54 -07:00
John McCall
3b3e53eb73 [NFC] Use InFlightSubstitution in the SIL type substituter 2023-03-25 18:54:14 -04:00
Andrew Trick
6b77b79ac8 MultiDefPrunedLiveness: add support for arbitrary uses/defs.
This now supports liveness holes within blocks where previously we
expected a phi def.

PrunedLiveness is streamlined for SSA liveness where we expect the
defs and uses to be related in the SSA def-use graph.
MultiDefPrunedLiveness was added on top of SSAPrunedLivenes to handle
extended SSA liveness that occurs with phis, but are still connected
in the def-use graph. Recently MultiDefPrunedLiveness was repurposed
for liveness of addressible storage. This means that we can now have
uses before defs in the same block without a corresponding phi.

Fortunately, handling this case is a straightforward extension of
MultiDefPrunedLiveness that does not complicate or penalize the
streamlined SSA case.
2023-03-24 18:40:31 -07:00
John McCall
a3c5e1664f Merge pull request #64575 from rjmccall/variadic-memberwise-initializers
Fixed memberwise initializers for structs with variadic-tuple properties
2023-03-24 12:24:38 -04:00
Andrew Trick
44fc97d340 [NFC] Move the updateForUse API into PrunedliveRange
PrunedLiveness only knows about the live blocks and uses.

The PrunedLiveRange subclass is now responsible for updating liveness
based on both the defs and uses. This is in preparation for handling
non-SSA liveness when uses occur before the first def.
2023-03-23 22:05:54 -07:00
Andrew Trick
13c60ae55a PrunedLiveness: remove a useless flag.
This was recently introduced as a result of rebasing commits. It never
did anything useful on the main branch.
2023-03-23 15:19:29 -07:00
Adrian Prantl
c5efebe784 Preserve the Implicit attribute in SILLocation. (NFC)
This change aims at reducing the need for SIL passes to check into the AST
storage of SILLocations. The end goal is to eventually merge this with the
autogenerated flag, but at the moment the emergent semantics of both properties
are not identical.
2023-03-23 14:59:05 -07:00
swift-ci
18fd92ef82 Merge pull request #64581 from atrick/fix-assert
PrunedLiveness; remove SWIFT_ASSERT_ONLY_DECL
2023-03-23 14:25:35 -07:00
nate-chandler
4ea51cfe33 Revert "Add a verify-di-hole assertion to SILBuilder." 2023-03-23 13:27:06 -07:00
Andrew Trick
fd03de4cd6 PrunedLiveness; remove SWIFT_ASSERT_ONLY_DECL
There's no value in hiding this flag in release builds.
I meant to remove SWIFT_ASSERT_ONLY_DECL in the previous commit.
2023-03-23 13:27:06 -07:00
John McCall
a3b195bd6d Merge pull request #64529 from rjmccall/variadic-tuples-in-structs
A bunch of fixes for variadic tuple properties in structs
2023-03-23 14:42:13 -04:00
Andrew Trick
b6f23da1f0 PrunedLiveness; remove SWIFT_ASSERT_ONLY_DECL
There's no value in hiding this flag in release builds.
I meant to remove SWIFT_ASSERT_ONLY_DECL in the previous commit.
2023-03-23 11:34:51 -07:00
John McCall
debc8d9ebd [NFC] Move forEachTupleElement to use a generator 2023-03-22 22:04:36 -04:00
Andrew Trick
119e712c32 Merge pull request #64534 from atrick/liveblocks-bitfield
Cleanup PrunedLiveBlocks
2023-03-22 16:33:08 -07:00
Adrian Prantl
63304d0787 SILLocation: Move pointsToEnd flag into ASTNodeTy. NFC
The pointsToEnd flag is only meaningful when combined with an AST node, and
moving it into the AST pointer frees up a bit in the flags bitfield for later
use.
2023-03-22 14:04:28 -07:00
Adrian Prantl
88b071bf9f Merge pull request #64494 from adrian-prantl/dihole-assertion
Add a verify-di-hole assertion to SILBuilder.
2023-03-22 12:50:17 -07:00
John McCall
0c3c62bd73 [NFC] Rename isPackExpansion -> isOrigPackExpansion for clarity 2023-03-22 15:40:02 -04:00
John McCall
f99efc2f94 Fix unsafeGetSubstFieldType to propagate a substitution map in
whichever case it happens to be in.

This is a basic fix so that parallel walks on tuples and function
types in the substituted type will work .  Separately, though, I
do not think the places that use this really need to be passed an
orig type; this is used for computing type properties, and I am
not aware of any reason we should need an orig type to compute
type properties.  Additionally, the orig types computed by this
function are not really correct because of the substitution being
done in some cases, so it'd be very nice to rip this all out.
I'm not good to look into that right now, though.
2023-03-22 15:40:02 -04:00
John McCall
7505a8a487 Merge pull request #64517 from rjmccall/arity-reabstraction-closures
Implement arity reabstraction for closures
2023-03-22 14:14:23 -04:00
Andrew Trick
cbe856e53a Cleanup PrunedLiveBlocks
Use BasicBlockBitfield to record per-block liveness state. This has
been the intention since BasicBlockBitfield was first introduced.

Remove the per-field bitfield from PrunedLiveBlocks. This
(re)specializes the data structure for scalar liveness and drastically
simplifies the implementation.

This utility is fundamental to all ownership utilities. It will be on
the critical path in many areas of the compiler, including at
-Onone. It needs to be minimal and as easy as possible for compiler
engineers to understand, investigate, and debug.

This is in preparation for fixing bugs related to multi-def liveness
as used by the move checker.
2023-03-22 02:36:57 -07:00
Andrew Trick
ae64ff5cb0 Rename PrunedLiveness.clear() to invalidate()
Because SILBitfield cannot be cleared.
2023-03-22 01:36:48 -07:00
Andrew Trick
15796e3ff9 PrunedLiveness: add a SILFunction argument
So that liveness can migrate to using a SILBitfield.
2023-03-22 01:36:48 -07:00
Andrew Trick
2fc50080a4 Add a BitfieldRef mini-utility.
Allows migration of existing data-structures to bitfields by
separating the state that contains the bitfield into a separate
stack-allocated container.
2023-03-22 01:17:11 -07:00
Konrad `ktoso` Malawski
345c221f56 [Concurrency] Distributed actor's unownedExecutor should be optional (#64499) 2023-03-22 08:40:41 +09:00
John McCall
3fe46464c7 Allow a SILFunctionArgument to be a parameter pack.
We might want to record the *sequence* of parameter decls associated
with a parameter pack, but currently we're not doing that.
2023-03-21 17:36:05 -04:00
Adrian Prantl
5129aea296 Add a verify-di-hole assertion to SILBuilder.
The verify-di-hole SILVerifier pass is very useful in catching incorrectly set
SILDebugScopes, but it can be very tedious to track down the root cause of a
verification failure. This patch replicates much of its functionality inside an
assertion in SILBuilder, which will result in a backtrace pointing directly to
where the offending scope is being set.
2023-03-21 09:40:11 -07:00
Erik Eckstein
010efc1ca6 Swift Bridging: use C++ instead of C bridging for the optimizer 2023-03-21 15:33:09 +01:00
Erik Eckstein
a092ecb5c2 remove SILBridgingUtils.h 2023-03-21 15:33:09 +01:00
Erik Eckstein
04c90166c4 Swift Bridging: use C++ instead of C bridging for BridgedBuilder 2023-03-21 15:33:09 +01:00
Erik Eckstein
b4510105a6 Swift Bridging: remove BridgedNode 2023-03-21 15:33:09 +01:00
Erik Eckstein
a776234354 - argument 2023-03-21 15:33:09 +01:00
Erik Eckstein
7905a9ac64 Swift Bridging: remove C bridging functions for SILDebugLocation 2023-03-21 15:33:09 +01:00
Erik Eckstein
82d9da5981 Swift Bridging: use C++ instead of C bridging for BridgedMultiValueResult 2023-03-21 15:33:09 +01:00
Erik Eckstein
47ac2d2818 Swift Bridging: use C++ instead of C bridging for BridgedArgument 2023-03-21 15:33:09 +01:00
Erik Eckstein
7789b4063e Swift Bridging: remove BridgedMemoryBehavior and use swift.MemoryBehavior instead 2023-03-21 15:33:09 +01:00
Erik Eckstein
8c05024ea6 SIL: move the SILInstruction::MemoryBehavior enum out of SILInstruction into the swift namespace 2023-03-21 15:33:09 +01:00
Erik Eckstein
4445373808 Swift Bridging: use C++ instead of C bridging for BridgedInstruction 2023-03-21 15:33:09 +01:00
Erik Eckstein
c4f5bab5b7 Swift Bridging: use C++ instead of C bridging for BridgedBasicBlock 2023-03-21 15:33:09 +01:00
Erik Eckstein
c0c0b80c81 Swift Bridging: use C++ instead of C bridging for BridgedGlobalVar 2023-03-21 15:33:09 +01:00
Erik Eckstein
ae7770d911 Swift Bridging: use C++ instead of C bridging for BridgedFunction 2023-03-21 15:33:09 +01:00
Erik Eckstein
e469c16744 Swift Bridging: remove BridgedType and directly use the C++ SILType instead 2023-03-21 15:33:09 +01:00
Erik Eckstein
598644fb92 Swift Bridging: use C++ instead of C bridging for the bridged witness table classes 2023-03-21 15:33:09 +01:00
Erik Eckstein
151f09769f Swift Bridging: use C++ instead of C bridging for BridgedVTable and BridgedVTableEntry 2023-03-21 15:33:09 +01:00
Erik Eckstein
fc2ad09d4b Swift Bridging: use C++ instead of C bridging for BridgedSuccessor 2023-03-21 15:33:09 +01:00
Erik Eckstein
eecea088e7 Swift Bridging: use C++ instead of C bridging for BridgedOperand and BridgedValue 2023-03-21 15:33:09 +01:00
John McCall
78996db4ab Merge pull request #64476 from rjmccall/arity-reabstraction
Implement parameter arity reabstraction
2023-03-21 01:27:07 -04:00
swift-ci
25280cb4cd Merge pull request #64482 from gottesmm/pr-cea9fdde854a77b8569c38181a8faae11d56192b
[gardening] Small cleanup of SILDebugInfoExpression.
2023-03-20 13:48:33 -07:00
John McCall
5f1a669f2f [NFC] Change the existing client of forEachFunctionParam
Yeah, this is much cleaner.
2023-03-20 16:01:54 -04:00