Commit Graph

419 Commits

Author SHA1 Message Date
Meghana Gupta
cbdf6e51ec Merge pull request #63323 from meg-gupta/ptrauthaddrdiversified4
Changes to support imported structs with ptruath qualified field function pointers
2023-02-02 09:19:29 -08:00
John McCall
6bf9ac858b Add instructions to allocate and deallocate packs.
Having added these, I'm not entirely sure we couldn't just use
alloc_stack and dealloc_stack.  Well, if we find ourselves adding
a lot of redundancy with those instructions (e.g. around DI), we
can always go back and rip these out.
2023-01-31 22:39:34 -05:00
Meghana Gupta
3a987cac67 Add verification for projections from structs with ptrauth qualified fields 2023-01-31 00:47:26 -08:00
John McCall
d25a8aec8b Add explicit lowering for value packs and pack expansions.
- SILPackType carries whether the elements are stored directly
  in the pack, which we're not currently using in the lowering,
  but it's probably something we'll want in the final ABI.
  Having this also makes it clear that we're doing the right
  thing with substitution and element lowering.  I also toyed
  with making this a scalar type, which made it necessary in
  various places, although eventually I pulled back to the
  design where we always use packs as addresses.

- Pack boundaries are a core ABI concept, so the lowering has
  to wrap parameter pack expansions up as packs.  There are huge
  unimplemented holes here where the abstraction pattern will
  need to tell us how many elements to gather into the pack,
  but a naive approach is good enough to get things off the
  ground.

- Pack conventions are related to the existing parameter and
  result conventions, but they're different on enough grounds
  that they deserve to be separated.
2023-01-29 03:29:06 -05:00
Doug Gregor
d192bfc7e5 Merge pull request #63125 from DougGregor/debug-info-dump-macro-expansion-buffers 2023-01-21 07:43:45 -08:00
Adrian Prantl
6335f1dee5 Debug Info: Represent macro expansions as inlined functions.
This allows the debugger to choose whether to display the expanded macro
(inlined) or the original source code (parent frame).

rdar://102916513
2023-01-20 21:43:20 -08:00
John McCall
374c202b99 Add SIL instructions to generate pack indices 2023-01-19 23:57:22 -05:00
Andrew Trick
7a0fd08b29 Fix SILOwnershipVerifier exponential run time and out-of-memory.
A 100-instruction-long block will cause the verifier to hang for
several minutes until SmallVector hits 4G and crashes.
2023-01-12 22:13:53 -08:00
Andrew Trick
c1a105a4c9 SILOwnershipVerifier: rename users to uses.
For basic sanity. Users are instructions, not operands.
2023-01-12 22:05:02 -08:00
John McCall
37baf9b2dc Add a SIL instruction to open a pack as an element archetype
IRGen not yet done.
2023-01-11 03:11:30 -05:00
Meghana Gupta
62901c2796 Fixes to reflect that we now consider a SILPhiArgument in a trivially dead block as a phi
With f9861ec9c0 we consider SILPhiArgument in a
block with no predecessors as phis, remove assert that we expect non-empt predecessors
to reflect this change.
2023-01-08 00:15:17 -08:00
Nate Chandler
32ee81ec4a [Gardening] Fixed comment. 2023-01-04 07:46:38 -08:00
Meghana Gupta
6ee4c17abe Merge pull request #62573 from meg-gupta/sbiverify
Update store_borrow checking in MemoryLifetimeVerifier and fix ForEachLoopUnroll and GenericCloner
2022-12-15 09:53:00 -08:00
John McCall
6d4588c40b Change SIL to track all LocalArchetypes and not just OpenedArchetypes. 2022-12-14 19:43:23 -05:00
Meghana Gupta
4d77b82c12 Update store_borrow verification in MemoryLifetimeVerifier
- Ensure there are no double end_borrows
- Ensure there are no end_borrows after dealloc_stack of the dest
2022-12-14 02:08:34 -08:00
swift-ci
6d0a3257a3 Merge pull request #62454 from meg-gupta/guaranteedforwardingphiverify
Update guaranteed forwarding phi apis and verification
2022-12-13 20:04:00 -08:00
Meghana Gupta
35d45deb95 Add verification to make sure guaranteed forwarding phi has guaranteed forwarding operands on all paths 2022-12-13 12:51:31 -08:00
Meghana Gupta
511739b494 Delete OperandOwnership::GuaranteedForwardingPhi
Use OperandOwnership::GuaranteedForwarding instead.
2022-12-13 12:51:31 -08:00
Meghana Gupta
b10563909c Update isGuaranteedForwarding api and delete isGuaranteedForwardingPhi api 2022-12-13 12:51:25 -08:00
John McCall
f524f3de69 [NFC] Support instructions that define multiple opened archetypes
I've also fixed this so that it should work on instructions that
define multiple values.  Someday we'll change all the open_existential
instructions to produce different values for the type dependency and
the value result; today is not that day, though.
2022-12-13 13:28:13 -05:00
Andrew Trick
f9861ec9c0 Add APIs for terminator results that forward ownership.
Add TermInst::forwardedOperand.

Add SILArgument::forwardedTerminatorResultOperand. This API will be
moved into a proper TerminatorResult abstraction.

Remove getSingleTerminatorOperand, which could be misused because it's
not necessarilly forwarding ownership.

Remove the isTransformationTerminator API, which is not useful or well
defined.

Rewrite several instances of complex logic to handle block arguments
with the simple terminator result API. This defines away potential
bugs where we don't detect casts that perform implicit conversion.

Replace uses of the SILPhiArgument type and code that explicitly
handle block arguments. Control flow is irrelevant in these
situations. SILPhiArgument needs to be deleted ASAP. Instead, use
simple APIs like SILArgument::isTerminatorResult(). Eventually this
will be replaced by a TerminatorResult type.
2022-12-12 12:37:35 -08:00
nate-chandler
7768b005a7 Merge pull request #62501 from nate-chandler/remove-in-constant
[SIL] Removed Indirect_In_Constant convention.
2022-12-12 07:29:12 -08:00
Nate Chandler
8d8577e5b0 [SIL] Removed Indirect_In_Constant convention.
It is no different from @in.

Continue parse @in_constant in textual and serialized SIL, but just as
an alias for @in.
2022-12-09 21:54:00 -08:00
Nate Chandler
964208092a [NFC] SILVerifier: Doc + cleanup to store_borrow. 2022-12-09 12:47:06 -08:00
Nate Chandler
49b4c34f37 [SIL] Verified addr usage of end_borrow. 2022-12-09 11:17:14 -08:00
Nate Chandler
570a58385d [NFC] Tweaked memory verifier require messages.
Grammar.
2022-12-09 11:16:30 -08:00
Nate Chandler
7430c6142f [SIL] Verified yielded addresses.
For yielded, nontrivial addresses, verify based on convention:
- guaranteed -> must be initialized at end_apply/abort_apply
- owned -> must be deinitialized at end_apply/abort_apply
- inout -> must be initialized at end_apply/abort_apply
2022-12-07 18:51:50 -08:00
nate-chandler
d069fff105 [SILDebugInfo] Only print under !NDEBUG. (#62325) 2022-11-30 13:11:50 -08:00
swift-ci
fbb1c0f011 Merge pull request #62181 from nate-chandler/nfc/20221118/1
[SILDebugInfo] Small tweaks.
2022-11-29 22:48:53 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Nate Chandler
a191795c2b [NFC] Simplified isAncestorScope.
Clarified preconditions, removed spurious explicit typing, and suprious
control flow.
2022-11-18 08:38:46 -08:00
Nate Chandler
0120f13bd4 [SILVerifier] Log on bad debug-info.
Previously, logging of the actually problematic instruction was guarded
by LLVM_DEBUG.  Meanwhile the verifier's require method prints an
instruction (usually one different from that at which the non-contiguous
scope was encountered).

Here, instead, the problematic instruction and the instruction which
defined the previous scope are printed to llvm::errs always (i.e.
whenever verification is actually run).

Additionally, debug-info logging is forcibly set on upon failure so that
the logs clearly show both what the previous scope was, what the current
scope is, and what instructions defined them.
2022-11-18 08:38:46 -08:00
Meghana Gupta
6471188d46 Merge pull request #61883 from meg-gupta/lbisuniq
LoadBorrowImmutabilityVerifier: Mark is_unique as a write
2022-11-02 16:06:45 -07:00
Meghana Gupta
ce332b9578 LoadBorrowImmutabilityVerifier: Mark is_unique as a write 2022-11-02 12:45:10 -07:00
Allan Shortlidge
5053055362 CMake: Break dependency cycles involving Sema. 2022-10-29 15:10:39 -07:00
Meghana Gupta
b26225c4d0 Merge pull request #61724 from meg-gupta/revertaddrphi
Revert changes to ArrayPropertyOpt to avoid address phis
2022-10-26 10:14:29 -07:00
Meghana Gupta
c9c9036c4e Revert "Ban address phis in non-OSSA SIL"
This reverts commit 035f062e69.
2022-10-25 11:10:52 -07:00
Meghana Gupta
3616fc6b53 Revert "Add verification to ensure we don't have redundant borrow scopes for @guaranteed forwarding phis"
This reverts commit dfbb2bd62a.
2022-10-21 22:31: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
Meghana Gupta
283f15e418 Remove dead code in LoadBorrowImmutabilityChecker 2022-10-19 19:55:17 -07: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
dfbb2bd62a Add verification to ensure we don't have redundant borrow scopes for @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
Becca Royal-Gordon
6143b8379f Generate IR for @_objcImpl stored properties
Only works for trivial types right now because features related to initialization and deinitialization are seriously busted.
2022-10-18 17:21:56 -07: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
Meghana Gupta
f7e7fed2df Use AccessPath exact use visitor in LoadBorrowImmutabilityChecker 2022-10-11 15:53:43 -07:00
Holly Borla
9bb837a241 [AST] Rename SequenceArchetype to PackArchetype. 2022-10-10 16:25:26 -07:00
Andrew Trick
eee184ae4e Delete isValueAddressOrTrivial
If we want a short-circuit test for address types, that should be done
within getOwnershipKind() itself.
2022-10-05 06:30:02 -07:00
Andrew Trick
52b87c25cf Temporarily disable a SILVerifier unit test.
We can't verify that store borrows aren't nested until we can reliably
compute liveness.

This can be fixed in two ways, both of which we plan to do ASAP:

 (1) With complete lifetimes, this no longer needs to perform transitive
 liveness at all.

 (2) findInnerTransitiveGuaranteedUses, which ends up being called on the
 load_borrow to compute liveness, can be taught to transitively process
 InteriorPointer uses instead of returning PointerEscape. We need to make
 sure all uses of the utility need to handle this first.
2022-10-04 13:27:47 -07:00