Commit Graph

2441 Commits

Author SHA1 Message Date
Cyndy Ishida
98fa58408f [swift][TBDGen] Stop adding redundant ObjC Classes (#62068)
TBD files contain a section reserved for obj-c classes. Previously,
TBDGen was adding symbols with this + normal globals with objc class
prefixes. This patch removes the extra globals being added.

This also accounts for this behavior for `validate-tbd-against-ir`
checking.

Resolves: rdar://101442087
2022-11-11 20:36:31 -08:00
Nate Chandler
65fe910130 [OperandOwnership] @in_constant operands consume.
Match the behavior that MemoryLifetimeVerifier::setFuncOperandBits
verifies for addresses for values.
2022-11-11 17:30:01 -08:00
Erik Eckstein
0eacaabfef SIL: add SILArgument::isErased()
Similar to SILInstruction, it's now possible to check if an argument was erased from a SILBasicBlock.
2022-11-11 07:58:51 +01:00
Erik Eckstein
696d5c56dd SIL: fix a memory corruption bug in AllocStackInst
The `numOperands` field needs to be set before any trailing objects are initialized. Otherwise they are initialized at the wrong address.
2022-11-10 16:56:44 +01:00
Slava Pestov
8379601574 SIL: Don't recursively lower ExistentialType and ParameterizedProtocolType 2022-11-08 19:09:07 -05:00
Slava Pestov
09b061bd0d SIL: Preliminary type lowering for PackType and PackExpansionType 2022-11-08 19:09:07 -05:00
swift-ci
6402bded14 Merge pull request #61894 from meg-gupta/fixselectvalue
Fix OperandOwnership of select_value
2022-11-07 12:53:38 -08:00
Allan Shortlidge
49e0015b8f SIL: Emit symbols methods associated with methods from SILSymbolVisitor when visiting a FuncDecl.
Previously, dispatch thunks and method descriptors were only emitted when visiting the containing `ClassDecl`. IRGen for `#_hasSymbol` requires visiting the `FuncDecl` directly.
2022-11-04 11:16:25 -07:00
nate-chandler
9e4c9ce612 Merge pull request #61917 from nate-chandler/opaque-values/1/20221103
[OpaqueValues] Follow-up to #61846.
2022-11-03 20:08:04 -07:00
nate-chandler
db9a140c44 Merge pull request #61887 from nate-chandler/opaque-values/1/20221102
[OpaqueValues] Handle Builtin.addressOfBorrow.
2022-11-03 14:46:02 -07:00
Nate Chandler
bfd865b6b6 [ApplySite] Renamed insertAfterApplication.
Now that it can be called on partial_apply instructions,
insertAfterFullEvaluation does not name what the function does.  One
could imagine a function which inserted after the applies of
(non-escaping) partial_applies.
2022-11-03 13:52:42 -07:00
Allan Shortlidge
23fe16875c Merge pull request #61886 from tshortli/silgen-has-symbol-forward-decls
SILGen: Forward declare SIL functions referenced by `#_hasSymbol` query helpers
2022-11-03 13:06:51 -07:00
Meghana Gupta
c220116539 Fix OperandOwnership of select_value
Fixes rdar://101616865
2022-11-02 23:32:33 -07:00
Allan Shortlidge
38779f32c1 SILGen/IRGen: Delegate decision to skip @_silgen_name functions to TBDGenVisitor.
This allows SILGen for `#_hasSymbol` conditions to visit them and emit a declaration of the function appropriately.
2022-11-02 21:38:33 -07:00
Nate Chandler
520dfc26cd [OpaqueValues] Added variants of addressOfBorrow.
The variants are produced by SILGen when opaque values are enabled.
They are necessary because otherwise SILGen would produce
address_to_pointer of values.

They will be lowered by AddressLowering.
2022-11-02 14:41:35 -07:00
Nate Chandler
e357fb45c5 [OpaqueValues] Handle Builtin.copy.
Specify the operand ownership of the Builtin differently depending on
whether lowered addresses are used.  Handle rewriting the value version
of the builtin as the address version of the builtin in AddressLowering.
2022-11-02 13:48:47 -07:00
Nate Chandler
78a8409ac1 [ApplySite] Promoted insertAfter to ApplySite.
Previously the API was only on FullApplySite, but it is useful to be
able to insert code after a partial_apply as well.
2022-11-01 13:02:32 -07:00
Allan Shortlidge
a44b54b818 NFC: Refactor the logic of TBDGenVisitor into two helper classes; SILSymbolVisitor and IRSymbolVisitor. 2022-10-30 09:14:29 -07:00
Allan Shortlidge
5053055362 CMake: Break dependency cycles involving Sema. 2022-10-29 15:10:39 -07:00
Allan Shortlidge
53ac896853 Merge pull request #61770 from tshortli/fix-sil-silgen-circular-dependency
Interop: Untangle circular dependency introduced by #59787
2022-10-27 20:04:15 -07:00
nate-chandler
b7793511a1 Merge pull request #61747 from nate-chandler/opaque-values/1/20221014
[AddressLowering] Storage root inherits lexical.
2022-10-27 16:35:15 -07:00
Allan Shortlidge
f5d760e613 Interop: Untangle circular dependency introduced by #59787
The changes for https://github.com/apple/swift/pull/59787 introduced a circular depenendcy between the SIL library and the SILGen library. I have undone this in the cheapest way possible as I don't have bandwidth to look into a more correct fix at the moment.
2022-10-27 13:17:38 -07:00
Nate Chandler
ed623d7b64 [NFC] Shortened SIL [init] flag.
Instead of writing out [initalization] for some instructions, use [init]
everywhere.
2022-10-27 10:38:54 -07:00
Zoe Carver
b0de482d82 Merge pull request #61757 from zoecarver/frt-method-call-crash
[cxx-interop] Fix crash when lowering self arg in foriegn reference t…
2022-10-27 09:54:07 -07:00
Allan Shortlidge
0d37f52fe0 APIDigester: Break cycle between Frontend and APIDigester targets.
Also push a utility that was previously on `SILDeclRef` down to AST so that the SIL dependency can be removed entirely from APIDigester.
2022-10-26 20:30:36 -07:00
zoecarver
96cd6188ef [cxx-interop] Fix crash when lowering self arg in foriegn reference type method call. 2022-10-26 18:22:50 -07:00
Saleem Abdulrasool
5456c71a08 Merge pull request #61727 from meg-gupta/revertnewsilcombine
Revert "Implement several peephole optimizations to unblock further o…
2022-10-26 08:16:25 -07:00
Nate Chandler
510e9110dc [Gardening] Listed switch_enum explicitly.
Make it clear that it's not a missed case.  It changes representation.
2022-10-26 07:56:57 -07:00
Meghana Gupta
5e20112e0c Revert "Implement several peephole optimizations to unblock further optimizations of autodiff code (#60520)"
This reverts commit 2f5492f572.
2022-10-25 13:35:14 -07:00
Michael Gottesman
285f03ee8c [move-only] Change type lowering to ensure that we use {retain,release}_value instead of strong_{retain,release} for move only enum/structs
This ensures that when we hit IRGen, if we have a type with trivial contents, we
emit nothing and if we have a type with non-trivial contents, we just emit
recursive retain/release as appropriate.

This is the last bug holding up the buffer view prototype from Guilliume.
2022-10-24 21:16:46 -07:00
Michael Gottesman
14c687a577 [move-only] Emit the move only marker for move only trivial enums.
Just an oversight I discovered when writing the enum deinit tests.
2022-10-24 20:05:04 -07:00
Becca Royal-Gordon
82d78a384f Merge pull request #60630 from beccadax/at-implementation
Add @_objcImplementation
2022-10-20 17:14:21 -07:00
Erik Eckstein
698196b1eb SILFunction: add getMemoryBehavior
This retrieves the side effect information from the function effects.
2022-10-20 09:20:28 +02:00
Meghana Gupta
ebd7a90587 NFC: Remove unused code + reorg 2022-10-19 19:54:28 -07:00
Meghana Gupta
786eb94853 Support @guaranteed forwarding phis 2022-10-19 19:54:27 -07:00
Meghana Gupta
b1f719709b Rename ForwardingBorrow -> GuaranteedForwarding 2022-10-19 19:54:27 -07:00
Nate Chandler
7ea336367d [NFC] Port isDeinitBarrier to Swift.
Added new C++-to-Swift callback for isDeinitBarrier.

And pass it CalleeAnalysis so it can depend on function effects.  For
now, the argument is ignored.  And, all callers just pass nullptr.

Promoted to API the mayAccessPointer component predicate of
isDeinitBarrier which needs to remain in C++.  That predicate will also
depends on function effects.  For that reason, it too is now passed a
BasicCalleeAnalysis and is moved into SILOptimizer.

Also, added more conservative versions of isDeinitBarrier and
maySynchronize which will never consider side-effects.
2022-10-18 21:23:22 -07:00
Becca Royal-Gordon
ad359fa753 Give @_objcImpl classes implicit deinits 2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
ba1ec90419 Generate IR for @_objcImpls
This commit begins to generate correct metadata for @_objcImplementation extensions:

• Swift-specific metadata and symbols are not generated.
• For main-class @_objcImpls, we visit the class to emit metadata, but visit the extension’s members.
• Includes both IR tests and executable tests, including coverage of same-module @objc subclasses, different-module @objc subclasses, and clang subclasses.

The test cases do not yet cover stored properties.
2022-10-18 17:21:56 -07:00
Hamish Knight
350e28b4b7 [Profiler] Rework profiling of top-level code
Instead of creating and destroying a SILProfiler
per TopLevelCodeDecl, setup a single profiler
for the top-level entry point function, and visit
all the TopLevelCodeDecls when mapping regions.
2022-10-14 17:45:14 +01:00
Hamish Knight
337cbeffa3 [Profiler] Remove canCreateProfilerForAST
Preserve the assertions to make sure functions
and closures have bodies, but the other checks
seem redundant. SILGen already asserts that we
have a type-checked SourceFile, and we already
control what nodes we call `createProfiler` for.
2022-10-14 17:45:14 +01:00
Hamish Knight
d1e2ac15d4 Factor out SILDeclRef::getInitializationExpr 2022-10-14 17:45:12 +01:00
Hamish Knight
1c9b77ef54 Merge pull request #61566 from hamishknight/countdown 2022-10-14 13:57:48 +01:00
Slava Pestov
36c01e80cc Merge pull request #61537 from hborla/variadic-generics-terminology
[AST] Use consistent variadic generics terminology.
2022-10-13 16:20:43 -04:00
Hamish Knight
b4d4137a5e [Profiler] NFC: Trim out unused imports
Also bump the copyright year.
2022-10-13 19:42:38 +01:00
Hamish Knight
809cfb7bf2 [Profiler] Introduce ProfileCounterRef
For now this just wraps an ASTNode, but in the
future it will allow us to model counters
that cannot simply hang off ASTNodes, e.g
error branch counters.
2022-10-13 19:42:37 +01:00
Nate Chandler
ab35362056 [SIL] Added new test_specification instruction.
The new instruction exists only to be used in tests.  The idea is to
specify tests that ought to be run "in the context" of the containing
function.
2022-10-11 17:15:13 -07:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Hamish Knight
04ef945dbd [Profiler] Remove getProfilerContextForDecl
We can use `getInnermostDeclContext` instead. Also
tighten up the condition of `hasFileBeenTypeChecked`
a bit.
2022-10-10 14:11:55 +01:00
Hamish Knight
89145f39fc [Profiler] NFC: Rename assignCounter -> assignKnownCounter
Make it clearer that we expect an existing counter
to have been assigned by MapRegionCounters.
2022-10-10 14:11:54 +01:00