Meghana Gupta
21cc1a185b
Add memory lifetime verification support for borrow accessors
2025-11-06 10:55:42 -08:00
Andrew Trick
e7000e4668
SIL: Add mark_dependence_addr
2025-03-25 23:02:42 -07:00
Erik Eckstein
d225c47d25
AST: rename OpenArchetypeType -> ExistentialArchetypeType
...
NFC
2025-03-11 20:21:46 +01:00
Slava Pestov
541757a491
AST: Remove TypeBase::isOpenedExistential()
...
At one point, OpenedArchetypeType did not exist as a separate subclass
of ArchetypeType, so this method did something. Now, it's just
equivalent to calling is<> or isa<>.
I also removed a couple of asserts that were obvious no-ops as a result.
2025-02-27 09:55:36 -05:00
Erik Eckstein
6a6d3f0b13
SIL: handle mark_dependence in the MemoryLifetimeVerifier
...
The check is not perfect, because it only checks that the base operand is alive _at_ the mark_dependence.
Ideally it should check that the base operand is alive during the whole lifetime of the value operand.
2025-02-10 17:57:47 +01:00
Tim Kientzle
1d961ba22d
Add #include "swift/Basic/Assertions.h" to a lot of source files
...
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Nate Chandler
600164257a
[NFC] Moved SmallBitVector dumping to Basic.
...
Moved out of MemoryLocations.h and merged the implementations of <<,
keeping the version from MemoryLocations with its brackets and commas
available via a flag but defaulting the implementation previously in the
header.
2024-02-19 11:41:38 -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
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
Josh Soref
d767912be2
Spelling sil ( #42471 )
...
* spelling: accessible
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: accessories
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: allocated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: amortizes
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: are
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: arguments
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: cacheable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: check
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clazz
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: compatible
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: compilation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: completely
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: construct
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conversion
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declarations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: derivation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: deserialization
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: destroyed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: determined
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: different
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: doesn't
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equality
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equivalent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: formation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: forwards
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: global
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: guaranteed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: have
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: identify
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: inaccessible
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indeterminate
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indices
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: inefficient
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: inheritance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instantaneous
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instruction
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: intentionally
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interior
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: intrinsic
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: introducing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: irrelevant
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: message
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: multi
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: necessarily
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: object
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: one
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: optimization
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: otherwise
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: overridden
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: parameter
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: pattern
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: pipeline
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: possibility
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: postdominance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: providing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: reached
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recognized
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: refrigerator
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: remaining
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: resilient
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: retrieve
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scavenge
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scheduled
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: separately
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: serializable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: signature
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: simplicity
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specifically
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substituted
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substitution
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: subtypes
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: supplement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: syntax
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: the
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: there
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: these
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: this
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: though
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: through
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transitively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transpose
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: trivial
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: value
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: verification
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: visibility
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: weird
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: whole
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com >
2022-04-22 15:11:09 -07:00
Ben Langmuir
35478637d3
Migrate from SmallVector.set_size to resize_for_overwrite
...
In the "next" branch, set_size has been made protected. Instead, users
can use resize_for_overwrite, optionally followed by truncate, to
handle the same use cases more safely.
2022-02-24 13:54:22 -08:00
Michael Gottesman
8f22966ff7
[move-function] Emit mark_unresolved_move_addr when we inline Builtin._move in a generic context.
...
This turns off the diagnostic that prevented the user from calling _move in such
contexts. I left that in for _copy.
2021-12-06 12:47:31 -08:00
Michael Gottesman
d74299e68d
[move-function] Add a new instruction called mark_unresolved_move_addr.
...
This instruction is similar to a copy_addr except that it marks a move of an
address that has to be checked. In order to keep the memory lifetime verifier
happy, the semantics before the checker runs are the mark_unresolved_move_addr is
equivalent to copy_addr [init] (not copy_addr [take][init]).
The use of this instruction is that Mandatory Inlining converts builtin "move"
to a mark_unresolved_move_addr when inlining the function "_move" (the only
place said builtin is invoked).
This is then run through a special checker (that is later in this PR) that
either proves that the mark_unresolved_move_addr can actually be a move in which
case it converts it to copy_addr [take][init] or if it can not be a move, emit
an error and convert the instruction to a copy_addr [init]. After this is done
for all instructions, we loop back through again and emit an error on any
mark_unresolved_move_addr that were not processed earlier allowing for us to
know that we have completeness.
NOTE: The move kills checker for addresses is going to run after Mandatory
Inlining, but before predictable memory opts and friends.
2021-12-06 12:47:29 -08:00
Erik Eckstein
25d6340a13
SIL: extract the isEmptyType from MemoryLocations into a general utility in SILType
...
NFC
2021-09-09 11:19:49 +02:00
Min-Yih Hsu
343d842394
[SIL][DebugInfo] PATCH 3/3: Deprecate debug_value_addr SIL instruciton
...
This patch removes all references to DebugValueAddrInst class and
debug_value_addr instruction in textual SIL files.
2021-08-31 12:01:04 -07:00
Min-Yih Hsu
e1023bc323
[DebugInfo] PATCH 2/3: Duplicate logics regarding debug_value_addr
...
This patch replace all in-memory objects of DebugValueAddrInst with
DebugValueInst + op_deref, and duplicates logics that handles
DebugValueAddrInst with the latter. All related check in the tests
have been updated as well.
Note that this patch neither remove the DebugValueAddrInst class nor
remove `debug_value_addr` syntax in the test inputs.
2021-08-31 11:57:56 -07:00
Meghana Gupta
6de9c973e0
Make it explicit that MemoryLifetimeVerifier will not handle reborrows
2021-08-19 15:01:37 -07:00
Erik Eckstein
4e26d8466a
fix a use-after free in MemoryLocations
...
rdar://75441030
2021-03-15 21:47:06 +01:00
Erik Eckstein
b9c8e57d7a
MemoryLifetimeVerifier: also verify locations with trivial types.
...
It helps to catch more problems
2021-03-13 10:41:30 +01:00
Erik Eckstein
d7468b1b47
MemoryLifetimeVerifier: fix the check for "empty" types.
...
The MemoryLifetimeVerifier has to ignore locations with empty types, e.g. and empty tuple.
So far, the check for empty types didn't check recursively, so it missed e.g. "((), ())"
2021-03-13 10:41:30 +01:00
Erik Eckstein
1baf009c06
refactoring: Split MemoryLifetime.cpp/h into three separate files
...
And rename MemoryDataflow -> BitDataflow.
MemoryLifetime contained MemoryLocations, MemoryDataflow and the MemoryLifetimeVerifier.
Three independent things, for which it makes sense to have them in three separated files.
NFC.
2021-03-13 10:41:30 +01:00