Commit Graph

1057 Commits

Author SHA1 Message Date
zoecarver
f063701f84 [cxx-interop][libswift] Use std::string instead of BridgedStringRef.
The first C-bridge to be removed! 🚀
2021-09-22 16:13:44 -07:00
swift-ci
f0def9afc0 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-22 09:13:41 -07:00
Andrew Trick
e85228491d Rename AccessedStorage to AccessStorage
to be consistent with AccessPath and AccessBase.

Otherwise, the arbitrary name difference adds constant friction.
2021-09-21 23:18:24 -07:00
Andrew Trick
354b5c4e17 Add AccessBase abstraction as OSSA helper
Split AccessedStorage functionality in two pieces. This doesn't add
any new logic, it just allows utilities to make queries on the access
base. This is important for OSSA where we often need to find the
borrow scope or ownership root that contains an access.
2021-09-21 19:54:24 -07:00
Andrew Trick
c1e6096e44 Fix findOwnershipReferenceRoot to stop at BeginBorrow.
Useful for finding the borrow scope enclosing an address.
2021-09-21 19:54:24 -07:00
Andrew Trick
19cff2e6eb Add AccessedStorage::isGuaranteedForFunction
to quickly bypass all liveness checking in many cases.
2021-09-21 09:43:05 -07:00
swift-ci
7adf077f7c Merge remote-tracking branch 'origin/main' into rebranch 2021-09-20 13:13:49 -07:00
Andrew Trick
b750c37f0e Merge pull request #39357 from atrick/add-borrow-extender
Add a BorrowedLifetimeExtender utility.
2021-09-20 12:53:56 -07:00
swift-ci
95162faa0a Merge remote-tracking branch 'origin/main' into rebranch 2021-09-17 22:53:47 -07:00
Meghana Gupta
db90ea20e7 Fix the ownership kind of success bb arg when emitting checked_cast_br` (#39347) 2021-09-17 22:34:47 -07:00
Andrew Trick
ffb7ecc1f7 Add a BorrowedLifetimeExtender utility.
Handle SSA update (phi creation) when extending an owned lifetime over
a borrowed lifetime.

This is a layer of logic above BorrowedValue but below
OwnershipLifetimeExtender and other higher-level utilities.
2021-09-17 20:09:58 -07:00
swift-ci
9552b4bd89 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-09 22:53:25 -07:00
swift-ci
f0dbb8ca90 Merge pull request #39230 from meg-gupta/fixlba 2021-09-09 22:41:02 -07:00
Meghana Gupta
4f2d4d5635 Fix LoadBorrowImmutabilityAnalysis in cases it raises false errors on destroy_value
We should only flag an error if there is a destroy_value on the first owned root of the access path.
2021-09-09 17:05:58 -07:00
swift-ci
ebfc6e6af1 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-09 10:33:59 -07: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
swift-ci
a34e4eb804 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-08 16:32:59 -07:00
Andrew Trick
29ee02d5bb Fix CastEmitter ownership.
Rewrite ownership forwarding through switch_enums. It's unclear what
the original code was doing, but enabling OSSA verification for
terminators revealed the issue.
2021-09-07 22:50:46 -07:00
Andrew Trick
0cfe74bba3 SIL API for OSSA terminator results.
Add OwnershipForwardingTermInst::createResult(SILBasicBlock, SILType)

Add SwitchEnumInst::createDefaultResult()

Add SwitchEnumInst::createOptionalSomeResult(), which handles most
compiler-generated switches.

Basic API for creating terminator results with consistent
ownership. This allows enabling OSSA verification on terminator
results. It fixes current issues, but is also a prerequisite for OSSA
simplify-cfg.

For switch_enum, this ensures that the default argument consistently
either forwards the original value, or handles the payload of the
unique case (the unique payload was already being inferred for
ownership, but the block argument was inconsistent with that fact).

switch_enum and checked_cast_br specify their forwarding
ownership. This can differ from their operand ownership.

For example:

    %e = enum $Optional<AnyObject>, #Optional.none!enumelt
    switch_enum %e : $Optional<AnyObject>,
                     case #Optional.some!enumelt: bb2...
  bb2(%arg : @owned T):

Independent forwarding ownership is only supported with terminators in this
change, but in the near term it will be used for all forwarding
operations to support implicit borrow scopes.
2021-09-07 10:20:14 -07:00
Alastair Houghton
3f01f853a6 [Demangling] Add error handling to the remangler.
Mangling can fail, usually because the Node structure has been built
incorrectly or because something isn't supported with the old remangler.
We shouldn't just terminate the program when that happens, particularly
if it happens because someone has passed bad data to the demangler.

rdar://79725187
2021-09-06 17:49:09 +01:00
swift-ci
d11680ffef Merge remote-tracking branch 'origin/main' into rebranch 2021-09-02 17:56:44 -07:00
Meghana Gupta
2282160e5e Fix swift::getSingleBorrowIntroducingValue in the case it can encounter .none values in the def-use chain (#39144) 2021-09-02 17:40:06 -07:00
swift-ci
ebad328a4f Merge remote-tracking branch 'origin/main' into rebranch 2021-09-01 09:14:57 -07: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
swift-ci
37d74e0094 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-25 22:14:26 -07:00
Slava Pestov
1a92b17d8f Merge pull request #39049 from slavapestov/mangler-generic-signature-cleanup
ASTMangler: Pass around generic signature explicitly and remove CurGenericSignature
2021-08-26 01:07:23 -04:00
swift-ci
4bc13fcda7 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-25 18:33:25 -07:00
Meghana Gupta
9ab8763d61 Merge pull request #38965 from meg-gupta/fixdestroyhoisting
Fix use-after-free in DestroyHoisting
2021-08-25 18:29:18 -07:00
Slava Pestov
51231e46fc ASTMangler: Pass around generic signature explicitly and remove CurGenericSignature
This pattern was really error-prone. I've fixed multiple bugs related
to CurGenericSignature not being set correctly at the right time, and
found another latent bug by inspection while doing this cleanup.
2021-08-25 16:44:09 -04:00
swift-ci
2e39774903 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-23 10:33:56 -07:00
Erik Eckstein
90c71ad002 libswift: improve and simplify pass invocation
* unify FunctionPassContext and InstructionPassContext
* add a modification API: PassContext.setOperand
* automatic invalidation notifications when the SIL is modified
2021-08-23 10:21:12 +02:00
Meghana Gupta
6de9c973e0 Make it explicit that MemoryLifetimeVerifier will not handle reborrows 2021-08-19 15:01:37 -07:00
swift-ci
e393330007 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-12 13:57:26 -07:00
Meghana Gupta
6bafc8498d Remove end_lifetime being considered as an end of scope marker (#38851)
OSSA rauw cleans up end of scope markers before rauw'ing.
This can lead to inadvertant deleting of end_lifetime, later
resulting in an ownership verifier error indicating a leak.

This PR stops treating end_lifetime scope ending like end_borrow/end_access.
2021-08-12 13:49:06 -07:00
swift-ci
a24a4f0339 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-12 06:13:43 -07:00
Konrad `ktoso` Malawski
ac6bee45db [Distributed] SIL invocation of initialize remote done 2021-08-12 14:09:01 +09:00
swift-ci
6edc2b599a Merge remote-tracking branch 'origin/main' into rebranch 2021-08-11 14:12:37 -07:00
Meghana Gupta
42f339f793 Fix ownership verifier to handle is_unique as a valid use of interior pointer op (#38838) 2021-08-11 14:07:07 -07:00
swift-ci
a8089662bd Merge remote-tracking branch 'origin/main' into rebranch 2021-08-09 16:13:32 -07:00
Andrew Trick
a6cb54511a Add a tiny BorrowedAddress utility.
Determines whether an address might be inside a borrowed scope. If so,
then any address substitution needs to find that scope boundary to
avoid violating its basic guarantee that all uses are within scope.
2021-08-09 11:43:41 -07:00
Andrew Trick
1f64871b31 MemAccessUtils: unify Box/Class/Tail storage for consistency and usability
It was originally convenient for exclusivity optimization to treat
boxes specially. We wanted to know that the 'Box' kind was always
uniquely identified. But that's not really important. And now that
AccessedStorage is being used more generally, the inconsistency is
problematic.

A consistent model is also must easier to understand and explain.

This also make the implementation of the utility simpler and more powerful.

Functional changes:

isRCIdentical will look through mark_dependence and mark_uninitialized.

findReferenceRoot is used consistently everywhere increasing analysis precision.
2021-08-09 11:43:40 -07:00
Andrew Trick
88df7833af Add InteriorPointer::ProjectBox.
InteriorPointer needs to handle all access base kinds that may be borrowed.
2021-08-07 15:26:47 -07:00
Andrew Trick
9984b81de7 MemAccessUtils cleanup: rename hasIdenticalBase
to hasIdenticalStorage.

Be precise in preparation for unifying and clarifying the access base model.
2021-08-07 15:26:46 -07:00
swift-ci
34ff88a273 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-06 18:53:41 -07:00
Meghana Gupta
64095a6d6b Fix use of MemAcessUtils in LICM (#38784)
AccessPathWithBase::compute can return a valid access path with unidentified base.
In such cases, we cannot LICM stores, because there is no base address to check if it is invariant
2021-08-06 18:34:55 -07:00
Arnold Schwaighofer
5a83172a55 Merge remote-tracking branch 'upstream/main' into rebranch 2021-08-05 12:04:56 -07:00
Andrew Trick
c323c6298b Fix an assert in collectUses when handling unknown index offsets.
AccessPathDefUseTraversal accumulates the offsets that it has seen on
the def-use walk while visiting index_addr and casts.

This is quite tricky because either the AccessPath being matched or
the def-use chain could contain unknown offsets. We need to correctly
classify all cases as either an exact, inner, or overlapping match.

For SIL like this

 %91 = integer_literal $Builtin.Int64, 0
 %113 = builtin "truncOrBitCast_Int64_Word"(%91 : $Builtin.Int64) : $Builtin.Word
 %115 = index_addr %114 : $*MyStruct, %113 : $Builtin.Word
 %119 = struct_element_addr %115 : $*MyStruct, #MyStruct.klass

We have Path: (@Unknown,#0)

There are two issues

(1) When AccessPathDefUseTraversal::checkAndUpdateOffset visits the
struct_element_addr, it fails to pop the unknown offset from the
expected path but continues trying to handle the struct_element_addr
and hits an assert. This PR fixes this.

(2) If the builtin "truncOrBitCast_Int64_Word" comes from a literal,
we should not treat it as an unknown offset (given that the literal is
within the size of a word). Added a test for this case, we should be able
to identify the access path accurately in this.
2021-08-04 17:38:51 -07:00
swift-ci
f1dbc19673 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-23 07:53:50 -07:00
Joe Groff
fc67ba57f2 Merge pull request #37938 from jckarter/async-let-multi-suspend
Handle multiple awaits and suspend-on-exit for async let tasks.
2021-07-23 07:36:54 -07:00