Commit Graph

15 Commits

Author SHA1 Message Date
Nate Chandler
a54a8ddaa3 [SIL] Key consume addr checking off var_decl attr.
Previously, the lexical attribute on allock_stack instructions was used.
This doesn't work for values without lexical lifetimes which are
consumed, e.g. stdlib CoW types.  Here, the new var_decl attribute on
alloc_stack is keyed off of instead.  This flag encodes exactly that a
value corresponds to a source-level VarDecl, which is the condition
under which checking needs to run.
2024-03-09 05:29:01 -08:00
Nate Chandler
11dd0e4aa6 [NFC] SIL: Typed debug_value's wasMoved.
Help avoid errors with boolean flags by using the new
UsesMoveableValueDebugInfo_t.
2024-03-08 21:24:39 -08:00
Michael Gottesman
11f0ff6e32 [sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.

rdar://123484595
2024-02-27 13:14:47 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Allan Shortlidge
2990c65457 NFC: Address some unused variable warnings. 2024-02-12 12:23:42 -08:00
Nate Chandler
336afca477 [SILOpt] Removed unreachable bailouts.
Now that supportsMoveOnlyTypes is always true, these bailouts can't be
reached.  Delete the bailouts and the predicate.
2024-02-05 17:40:17 -08:00
swift-ci
2f4bd434fa Merge remote-tracking branch 'origin/main' into rebranch 2023-08-20 21:34:05 -07:00
Michael Gottesman
361562aef5 [consume-operator] Emit a better error message when failing to consume globals or escaping captures.
Specifically, we previously emitted a "compiler doesn't understand error", so we
were always emitting an error appropriately. This just gives a better error
message saying instead that the compiler did understand what happened and that
one cannot apply consume to globals or escaping captures.

https://github.com/apple/swift/issues/67755
rdar://112561671
2023-08-20 18:59:37 -07:00
swift-ci
4fe55c5732 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-11 00:35:20 -07:00
Andrew Trick
83ce3a1777 Rename getArgumentOperandConvention to getCaptureConvention
The name was misleading and problematic. There is already a
getArgumentConvention which is completely different.
2023-08-10 11:17:53 -07:00
Evan Wilde
309aed4925 Add SmallSetVector replacement
llvm::SmallSetVector changed semantics
(https://reviews.llvm.org/D152497) resulting in build failures in Swift.
The old semantics allowed usage of types that did not have an
`operator==` because `SmallDenseSet` uses `DenseSetInfo<T>::isEqual` to
determine equality. The new implementation switched to using
`std::find`, which internally uses `operator==`. This type is used
pretty frequently with `swift::Type`, which intentionally deletes
`operator==` as it is not the canonical type and therefore cannot be
compared in normal circumstances.

This patch adds a new type-alias to the Swift namespace that provides
the old semantic behavior for `SmallSetVector`. I've also gone through
and replaced usages of `llvm::SmallSetVector` with the
`Swift::SmallSetVector` in places where we're storing a type that
doesn't implement or explicitly deletes `operator==`. The changes to
`llvm::SmallSetVector` should improve compile-time performance, so I
left the `llvm::SmallSetVector` where possible.
2023-07-25 12:28:27 -07:00
Kavon Farvardin
71763a124e merge similar diagnostics together under a unified naming scheme for more consistent word tense
sil_movekillscopyablevalue_* and sil_moveonlychecker_* can share diagnostics.

rdar://109281444
2023-05-24 20:56:38 -07:00
Kavon Farvardin
12d33b2b84 run the move-checker if lexical borrow scopes are enabled
this pulls just the move checking passes out from
behind the experimental flag.
2023-03-13 22:39:31 -07:00
Michael Gottesman
cec4896615 [debug-info] Add a new super class of DebugVarCarryingInst called VarDeclCarryingInst.
I discovered when working with improving the debug output of the move only
address checker that I had a need for lightweight thing like
DebugVarCarryingInst but that only could vend a VarDecl (unlike
DebugVarCarryingInst which also can vend a SILDebugVariable). As an example,
this lets one write a high level API that uses the standard API to loop over a
bunch of instructions all that vend a VarDecl and construct a stringified path
component list.

rdar://105293841
2023-02-10 13:37:59 -08:00
Michael Gottesman
3a538282ff [consume-operator] Rename checker passes to have ConsumeOperator in the name to reduce confusion with MoveChecking passes.
Just trying to eliminate potential confusion.
2023-01-27 13:46:32 -08:00