Commit Graph

6583 Commits

Author SHA1 Message Date
swift-ci
4eda70de33 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-11 15:15:42 -07:00
Michael Gottesman
5baf2af88a [sil] Add a new instruction called explicit_copy_addr.
This is exactly like copy_addr except that it is not viewed from the verifiers
perspective as an "invalid" copy of a move only value. It is intended to be used
in two contexts:

1. When the move checker emits a diagnostic since it could not eliminate a copy,
we still need to produce valid SIL without copy_addr on move only types since we
will hit canonical SIL eventually even if we don't actually codegen the SIL. The
pass can just convert said copy_addr to explicit_copy_addr and everyone is
happy.

2. To implement the explicit copy function for address only types.
2022-08-11 11:40:53 -07:00
Allan Shortlidge
bc5f13cb6b AST: Accept @_weakLinked on import decls to force weak linkage of symbols from a module.
The effect of declaring an import `@_weakLinked` is to treat every declaration from the module as if it were declared with `@_weakLinked`. This is useful in environments where entire modules may not be present at runtime. Although it is already possible to instruct the linker to weakly link an entire dylib, a Swift attribute provides a way to declare intent in source code and also opens the door to diagnostics and other compiler behaviors that depend on knowing that all the module's symbols will be weakly linked.

rdar://96098097
2022-08-11 11:02:57 -07:00
Anxhelo Xhebraj
e748f01d90 Swift SIL: add constant checking for ref_element_addr field and global 2022-08-11 10:16:40 -07:00
Anxhelo Xhebraj
303ed781ff Swift SIL: add AccessKind to BeginAccess 2022-08-11 10:16:40 -07:00
swift-ci
adece3d90f Merge remote-tracking branch 'origin/main' into rebranch 2022-08-09 15:14:41 -07:00
Arnold Schwaighofer
2baa1e4ac6 Merge pull request #60450 from aschwaighofer/globals_and_large_types
LoadableByAddress: Updating global variables' types
2022-08-09 15:07:35 -07:00
swift-ci
71c6bd422e Merge remote-tracking branch 'origin/main' into rebranch 2022-08-09 13:14:18 -07:00
Slava Pestov
9d96ed940f AST: Rename 'canonical wrt. generic signature' to 'reduced'
We had two notions of canonical types, one is the structural property
where it doesn't contain sugared types, the other one where it does
not contain reducible type parameters with respect to a generic
signature.

Rename the second one to a 'reduced type'.
2022-08-09 12:46:31 -04:00
Arnold Schwaighofer
58420a164b LoadableByAddress: Updating global variables' types
Because of pointer authentication the type of global variables needs to
be updated.

rdar://93688980
2022-08-09 09:03:03 -07:00
swift-ci
d2cfd04e34 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-05 12:32:59 -07:00
Sima Nerush
7b00eb67cf SIL: Remove unused parameter 2022-08-04 21:25:43 -06:00
swift-ci
e52f3cb3df Merge remote-tracking branch 'origin/main' into rebranch 2022-07-28 21:54:39 -07:00
Erik Eckstein
e8e61a9565 SIL: create cond_fail 1 instead of builtin "int_trap" for unconditional failures
`int_trap` doesn't provide a failure message, which makes crash reports hard to understand.
This is mostly the case for optimized casts which fail.

rdar://97681511
2022-07-28 16:05:07 +02:00
Arnold Schwaighofer
2296c72515 Merge pull request #60256 from aschwaighofer/rebranch_adjust_to_DEPRECATED
[rebranch] Adjust to removal of LLVM_ATTRIBUTE_DEPRECATED
2022-07-27 12:22:05 -07:00
swift-ci
fd2a82f8e2 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-27 11:57:04 -07:00
Arnold Schwaighofer
3b42240209 Adjust to removal of LLVM_ATTRIBUTE_DEPRECATED 2022-07-27 08:35:32 -07:00
Erik Eckstein
57fdba2e7f SIL: add infrastructure to make snapshots from SILFunctions.
Snapshots are copies of a function at a given point in time.

Currently it's only used for running passes repeatedly for performance profiling.
In future it can be used for caching when doing lazy evaluation in the pipeline.
2022-07-27 17:02:35 +02:00
swift-ci
4492599fea Merge remote-tracking branch 'origin/main' into rebranch 2022-07-26 17:13:27 -07:00
Michael Gottesman
1e6187c4f4 [sil] Update all usages of old API SILValue::getOwnershipKind() in favor of new ValueBase::getOwnershipKind().
Andy some time ago already created the new API but didn't go through and update
the old occurences. I did that in this PR and then deprecated the old API. The
tree is clean, so I could just remove it, but I decided to be nicer to
downstream people by deprecating it first.
2022-07-26 11:46:23 -07:00
swift-ci
40d3b02cfa Merge remote-tracking branch 'origin/main' into rebranch 2022-07-25 06:35:29 -07:00
Egor Zhdan
8165806aa0 Merge pull request #60174 from apple/egorzhdan/scs-stringref-p1
[cxx-interop][SwiftCompilerSources] Use `llvm::StringRef` instead of `BridgedStringRef`
2022-07-25 14:26:59 +01:00
swift-ci
705901327d Merge remote-tracking branch 'origin/main' into rebranch 2022-07-22 11:54:21 -07:00
Michael Gottesman
b0449589a6 Merge pull request #60187 from gottesmm/moveonly_type_begin
[move-only] Implement very initial work for move only
2022-07-22 11:35:52 -07:00
swift-ci
fe7d3a49f7 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-22 11:14:42 -07:00
nate-chandler
83d97819ad Merge pull request #60121 from nate-chandler/rdar94346482
[SILOpt] Handle reborrows of owned phis in CanonicalizeOSSALifetime.
2022-07-22 11:08:02 -07:00
Michael Gottesman
65c21b61bf [move-only] Begin implementing support for concrete move only types.
This is just the very beginning... I still need to implement more parts of
SILGen for this. But all great things start small. I am going to iterate on top
of this and just wanted to get some initial parts of the work in as I go.
2022-07-21 15:33:17 -07:00
Michael Gottesman
afd8accb75 [move-only] Add a move only request to lookup if a ValueDecl is a "move only type".
I also created a SILType::isMoveOnly() helper that returns true if a type is
a move only wrapped type or a first class move only type. The verifier check
that move only types aren't copied in canonical SIL was rewired to use that as well.
2022-07-21 15:33:17 -07:00
Nate Chandler
fe435312a1 [OwnershipUtils] Visit owned phi's reborrows.
The new utility, given an phi, visits all adjacent phis (i.e. arguments
to the same block) which are (potentially iterated) reborrows of a value
reaching the given phi.
2022-07-21 15:03:43 -07:00
Egor Zhdan
0e2d438c5b [cxx-interop][SwiftCompilerSources] Use llvm::StringRef instead of BridgedStringRef
rdar://83361000
2022-07-21 16:32:16 +01:00
swift-ci
f41e0a0621 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 02:53:30 -07:00
Michael Gottesman
7a43d246b0 Merge pull request #60047 from gottesmm/plus_zero_fix_noimplicitcopy
[no-implicit-copy] Use default param convention instead of forcing +1
2022-07-20 02:36:52 -07:00
Michael Gottesman
f1182a73da [no-implicit-copy] Remove auto +1 param signature change called by noimplicit copy in favor of following normal convention.
I also added a bunch of tests for both the trivial/non-trivial case as well as
some docs to SIL.rst.
2022-07-19 16:39:03 -07:00
Michael Gottesman
9b625588f0 [sil] Make copyable_to_moveonlywrapper forwarding like moveonlywrapper_to_copyable.
Specifically this means that rather than always being owned, we now have owned
and guaranteed versions of copyable_to_moveonlywrapper. Similar to
moveonlywrapper_to_copyable, one chooses which variant one gets by using
specific SILBuilder APIs:
create{Owned,Guaranteed}CopyableToMoveOnlyWrapperValueInst. It is still
forwarding and the rest of the forwarding APIs work as expected except that the
forwarding ownership is fixed (and an assertion will result if one attempts to
do so).

NOTE: It is assumed that trivial operands are always passed to the owned
variant.
2022-07-19 14:39:59 -07:00
swift-ci
8fa494a894 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-19 04:53:11 -07:00
Erik Eckstein
cd8efecd96 SIL Optimizer: check for SILUndef before constructing a ValueSet for a value
Fixes a crash, because SILUndef's function is null.

rdar://97199428
2022-07-19 11:19:34 +02:00
Nate Chandler
8c44d36bc8 [SIL] Add utility to transitively visit operands.
The new utility looks through operands whose values are themselves
SILPhiArguments and visits those arguments' operands.
2022-07-18 16:22:13 -07:00
swift-ci
3a0b8016db Merge remote-tracking branch 'origin/main' into rebranch 2022-07-15 05:54:42 -07:00
Roberto Rosmaninho
ff222acebc Setting hardcode SWIFT_NOEXCEPT and noexcept flags only to
non-throwing functions.
Activating swift-functions-errors tests
Inserting macros and additional parameters in C and C++ functions following the pattern to lowering to LLVM IR.
2022-07-14 12:34:53 -03:00
swift-ci
8771684a28 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-14 02:13:20 -07:00
eeckstein
d128d81ea5 Merge pull request #60035 from eeckstein/silnode-set
SIL: add efficient Set data structures for SILValue and SILInstruction, similar to BasicBlockSet.
2022-07-14 10:56:21 +02:00
swift-ci
d735697088 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-14 01:13:21 -07:00
Pavel Yaskevich
5bd077a461 [SIL] Keep alive @_alwaysEmitIntoClient decls with opaque result types
If such declarations have availability conditions they have to be
kept alive until IRGen to emit opaque type descriptor that is going
be used at runtime to determine the underlying type.

This is important for "optimized" mode only because in non-optimized
mode "shared" symbol survives SILGen.
2022-07-13 15:46:23 -07:00
Michael Gottesman
36e1e52009 [type-lowering] When determining lowered rvalue types, don't look through moveonlywrapped.
This ensures that we do not lose the move only wrapper from the input type if is
SILMoveOnlyWrapped.
2022-07-13 14:03:23 -07:00
Erik Eckstein
dd9efa87a0 SIL: add block/instruction/value set variants which maintain their current size. 2022-07-13 14:27:50 +02:00
Erik Eckstein
6760dc420c SIL: add a utility which can manage per-value and per-instruction bitfields and flags efficiently.
It's used to implement `InstructionSet` and `ValueSet`: sets of SILValues and SILInstructions.
Just like `BasicBlockSet` for basic blocks, the set is implemented by setting bits directly in SILNode.
This is super efficient because insertion and deletion to/from the set are basic bit operations.

The cost is an additional word in SILNode. But this is basically negligible: it just adds ~0.7% of memory used for SILInstructions.
In my experiments, I didn't see any relevant changes in memory consumption or compile time.
2022-07-13 14:27:50 +02:00
swift-ci
3ca83619fb Merge remote-tracking branch 'origin/main' into rebranch 2022-07-11 22:14:23 -07:00
eeckstein
511bd67929 Merge pull request #59999 from eeckstein/simplify-silnode-bits
SIL: simplify the SILNode inline bitfields.
2022-07-12 07:04:56 +02:00
swift-ci
846972a5aa Merge remote-tracking branch 'origin/main' into rebranch 2022-07-11 15:33:27 -07:00
swift-ci
02a381664d Merge pull request #59983 from atrick/fix-discovered-blocks
PrunedLiveness fix discoveredBlocks to be unique.
2022-07-11 15:29:51 -07:00