Commit Graph

74 Commits

Author SHA1 Message Date
Michael Gottesman
cd7213e3a2 [send-non-sendable] Eliminate a bunch of temporary heap allocations caused by using std::vector temporaries.
Just making small improvements as I go.
2023-09-12 12:11:44 -05:00
Michael Gottesman
42df9c4c72 [send-non-sendable] Cleanup logging a little.
Specifically:

1. Converted llvm::errs() -> llvm::dbgs() when using LLVM_DEBUG.
2. Converted a dump method on errs to be a print method on dbgs that is called from dump with print(llvm::dbgs()).
2023-09-12 12:11:44 -05:00
Michael Gottesman
336ed714ce [send-non-sendable] Convert SILInstruction translation to use an exhaustive switch.
This ensures that we actually handle all instructions. I already found that we
are not handling ~106 cases... but to make this just a refactoring patch, I just
put in a default + a break + left in the error.

rdar://115367810
2023-09-12 12:11:39 -05:00
Michael Gottesman
a1daf817f3 [send-non-sendable] Remove ASCII color from log output.
Not everyone uses color output and having to remove the ASCII color support is
annoying.
2023-09-11 09:07:29 -05:00
Michael Gottesman
68564f12dc [sendable-non-sendable] When tracking values flow sensitive properties, map a SILValue to the state rather than including the state in the mapping.
Otherwise, we can potentially map the same SILValue twice if its Key state is
slightly different.
2023-08-28 18:39:52 -07:00
Michael Gottesman
c68a976c9f [send-non-sendable] Change a set::set to be an llvm::DenseSet. 2023-08-25 12:17:18 -07:00
Michael Gottesman
74c71b871c [send-non-sendable] Make TrackableSILValue a POD value.
Previously before this patch, the logic for constructing TrackableSILValue was
split inbetween TrackableSILValue and the PartitionOpTranslator. A lot of
routines were also just utility routines that did not depend on the state in
either of the constructs.

With that in mind in this patch I:

1. Moved the utility functions that did not depend on internal state of those
functions into utility functions in the utility section.

2. Moved the logic in TrackableSILValue's constructor that depended on state
inside PartitionOpTranslator into PartitionOpTranslator itself.

3. Made TrackableSILValue a simple POD type used for storing state.

4. I changed capturedUIValues to just store within it a SILValue. It actually
does not care about isAliased or isSendable... it is just used as a way to check
if we have a uniquely identified value. In a forthcoming patch, I am going to
try to do similar things with the other maps that use TrackableSILValues since
by making the TrackableSILValues our keys/sets it allows for us to potentially
store multiple versions of the same TrackableSILValues if their aliased/sendable
state differ... which would lead to bugs.
2023-08-25 12:05:19 -07:00
Michael Gottesman
4f20b5ddbb [send-non-sendable] Move utility functions into a utility section.
I also used a more general way to check for apply insts that are not builtins
(ApplySite).
2023-08-25 11:59:12 -07:00
Michael Gottesman
bfb204643f [send-non-sendable] Cleanup the main SILFunctionTransform. 2023-08-25 11:58:16 -07:00
Michael Gottesman
373a007efa [send-not-sendable] Eliminate relative includes and add a file header.
Specifically, the two routines we were importing relatively were:

1. TypeChecker::conformsToProtocol. I moved this onto a helper routine on
SILType.

2. swift::findOriginalValueType(Expr *). This routine just looks through various
implicit conversions to find the original underlying type. I moved it to a
helper method on Expr.
2023-08-23 14:38:30 -07:00
jturcotti
bb2f3c011e rename DeferredSendableChecking pass to SendNonSendable pass, handle more instructions such as try_apply and begin_apply, and fix bugs 2023-07-27 16:45:29 -07:00
jturcotti
853ef7cf3c fix bugs that present themselves when handling multiarg and varargs functions, including adding better debug dump methods 2023-07-20 14:01:08 -07:00
jturcotti
a83d7aa39c improve diagnostics about data races; highlight the individual expressions being sent and accessed as precisely as possible, and include information about specific non-sendable types and isolation crossings 2023-07-19 17:27:16 -07:00
jturcotti
55e8f9f2ed improve debug output, finalize explicit constructor refactor, and begin improving diagnostic messages 2023-07-18 15:58:56 -07:00
jturcotti
5f42a142df handle tuple creation 2023-07-18 14:32:12 -07:00
jturcotti
3868f1dc27 perform refactor to use named types as elements and regions in partitions, and ensure that all SILValues are converted once to TrackableSILValues in the SendNonSendable analysis pass 2023-07-18 13:32:43 -07:00
jturcotti
34113c4c0f implement searching for a ConsumeReason instead of just diagnosing accesses to consumed values 2023-07-14 16:12:52 -07:00
jturcotti
1d130390be add more comprehensive cases to tests, and fix many bugs, relying on much more potent resolution of addresses 2023-07-14 09:28:27 -07:00
jturcotti
1a716d82cf replace use of internal "projections" tracking map with usage of memutils' AccessStorage utilities 2023-07-14 09:28:26 -07:00
jturcotti
65fa6fd966 use LLVM_DEBUG instead of static DEBUG constant 2023-07-12 09:36:21 -07:00
jturcotti
e7a1747af2 Tweak, improve, and debug the PartitionAnalysis engine until a fairly comprehensive suite of simple tests passes (region_based_sendability.swift) 2023-07-11 11:12:38 -07:00
jturcotti
29bd728f4c Begin to fill in the SendNonSendable SIL pass using a PartitionAnalysis engine, works for some simple examples but needs to address address values in SIL. 2023-07-10 15:20:14 -07:00
jturcotti
aae9f43bda Write PartitionUtils.h, implementing common utilities for manipulating a partition data structure that will be used for flow-sensitive, region-based Sendable checking. 2023-07-10 15:20:14 -07:00
jturcotti
aa9f1a3584 add an experimental feature DeferSendableChecking to defer the sendable checking of some sites. For now, only diagnostics corresponding to non-sendable arguments passed to calls with unsatisfied isolation are deferred. A SIL pass SendNonSendable is added to emit the deferred diagnostics, and ApplyExpr is appropriately enriched to make that deferral possible. 2023-07-03 09:52:11 -07:00