Michael Gottesman
03986db44f
[mem-access] Teach mem-access about mark_must_check.
2022-09-07 18:20:33 -07:00
Erik Eckstein
32af2dd5a4
Swift SIL: an autogenerated Location needs to keep the debug scope.
...
Therefore, instead of creating an autogenerated location with a null scope, make an existing location `autoGenerated`.
2022-09-02 08:56:38 +02:00
Erik Eckstein
082aec0990
Swift SIL: add var FunctionArgument.convention
...
Also:
* move the `ArgumentConvention` enum from Function.swift to Argument.swift.
* `FunctionArgument.isExclusiveIndirectParameter` -> `ArgumentConvention.isExclusiveIndirect`
* add `ArgumentConvention.isInout`
2022-09-02 07:11:49 +02:00
Erik Eckstein
f7aaa35092
Swift SIL: fix KeyPathInst.visitReferencedFunctions
...
It crashed for keypath instructions with zero components.
2022-08-26 18:00:11 +02:00
Erik Eckstein
f6e6b2ecf3
Swift SIL: add the possibility to pass a custom location to Builder initializers.
...
And add the static property `Location.autoGeneratedLocation`
2022-08-26 18:00:11 +02:00
Erik Eckstein
2745565a83
Swift SIL: correctly bridge "invalid" witness table entries.
...
Originally, I thought that couldn't appear in valid SIL, but there are "no_default" entries in default witness tables, which map to "invalid" entries.
2022-08-26 18:00:11 +02:00
Erik Eckstein
2fe1ee5533
Swift SIL: add a few Builder functions
...
* add `createAllocStack`
* add `createDeallocStack`
* add `createCopyAddr`
* add `@discardableResult` to the existing `createDeallocStackRef`
2022-08-24 17:55:02 +02:00
Erik Eckstein
0e59dde0fa
Swift SIL: add the TermInst.isFunctionExiting property
2022-08-24 17:55:02 +02:00
Erik Eckstein
bfb284f827
Swift SIL: add a few instructions and Instruction.visitReferencedFunctions
...
* add `DynamicFunctionRefInst` and `PreviousDynamicFunctionRefInst`
* add a common base class to all function-referencing instructions: `FunctionRefBaseInst`
* add `KeyPathInst`
* add `IndexAddrInst.base` and `IndexAddrInst.index` getters
* add `Instruction.visitReferencedFunctions` to visit all functions which are referenced by an instruction
2022-08-24 17:55:02 +02:00
Erik Eckstein
fbb694bcde
Swift SIL: add bridging for witness and default witness tables
2022-08-24 17:55:02 +02:00
Erik Eckstein
7816513f0d
Swift SIL: add bridging for vTables
2022-08-24 17:55:02 +02:00
Erik Eckstein
7b9b97fb76
Swift SIL: fix BeginAccessInst.endInstructions
2022-08-24 17:54:46 +02:00
Erik Eckstein
fe40707d5e
Swift SIL: add Function.isPossiblyUsedExternally and Function.isAvailableExternally
2022-08-24 17:54:46 +02:00
Erik Eckstein
5015555737
Swift SIL: add a utility protocol BridgedRandomAccessCollection
...
It fixes the default reflection for bridged random access collections, which usually have a `bridged` stored property.
Conforming to this protocol displays the "real" children of a bridged random access collection and not just `bridged`.
2022-08-24 17:54:46 +02:00
Erik Eckstein
306e5b0c9c
Swift SIL: make Function hashable
2022-08-24 17:54:46 +02:00
Erik Eckstein
3bba7caacc
Swift SIL: add var Function.instructions
...
To be used to iterate over all instructions in a function without the need of two loops - one for blocks and one for instructions.
2022-08-24 17:54:46 +02:00
Erik Eckstein
20a8f450dd
Swift AccessUtils: improvements and bug fixes
...
While I was using the new AccessUtils for a new optimization pass I discovered some areas for improvements. Also I found some bugs.
Changes:
* AccessBase: remove the unhealthy redundancy between `kind` and `baseAddress` types. Now AccessBase is single enum with the relevant base objects/addresses as payloads.
* AccessBase: for `global`, store the `GlobalValue` and not a `global_address` instruction, which is more accurate (because there can be multiple `global_addr`s for a single global variable)
* AccessBase: drop the support for function argument "pointers". The `pointer` is now always a `pointer_to_address` instruction. This also simplifies `PointerIdentification`: either it finds a matching `address_to_pointer` or it bails.
* AccessBase: improve `func isDistinct(from:)`. There are more possibilities to prove that two access bases do not alias.
* AccessBase: replace `var isUniquelyIdentified` with `var hasKnownStorageKind` which is more useful for aliasing checking.
* AccessPath: fix `func isDistinct(from:)`. `SmallProjectionPath.matches` is the wrong way to check if two expression paths may overlap. Instead use the new `SmallProjectionPath.mayOverlap`.
* AccessStoragePathWalker: rename `getAccessStorage` -> `visitAccessStorageRoots` and let it return false if it's not a class/reference AccessBase.
* add tests for `AccessPath.isDistinct(from:)`
2022-08-22 13:22:14 +02:00
Erik Eckstein
05d62293e6
Swift SIL: add NominalFieldsArray.getNameOfField(withIndex:)
2022-08-22 13:22:06 +02:00
Erik Eckstein
3367fdd04d
SmallProjectionPath: add mayOverlap(with:)
...
"Overlapping" means that both paths may project the same field.
2022-08-22 13:22:06 +02:00
Anxhelo Xhebraj
d6192f4f43
Swift SIL: add ScopedInstruction protocol for instructions like BeginAccess
2022-08-11 10:16:40 -07:00
Anxhelo Xhebraj
462d208d15
Swift SIL: add GlobalVariable equality
2022-08-11 10:16:40 -07:00
Anxhelo Xhebraj
e748f01d90
Swift SIL: add constant checking for ref_element_addr field and global
2022-08-11 10:16:40 -07:00
Anxhelo Xhebraj
303ed781ff
Swift SIL: add AccessKind to BeginAccess
2022-08-11 10:16:40 -07:00
Egor Zhdan
0e2d438c5b
[cxx-interop][SwiftCompilerSources] Use llvm::StringRef instead of BridgedStringRef
...
rdar://83361000
2022-07-21 16:32:16 +01:00
Erik Eckstein
b52297bb79
Swift SIL: some improvements for WalkUtils and EscapeInfo
...
* "merge" the `Path` and `State` in WalkUtils into a single `WalkingPath`. This makes it simpler for clients to configure a path and additional state variables. EscapeInfo now defines `EscapePath` which includes the projection path and EscapeInfo's specific state variables.
* Make the `WalkerCache` part of the WalkUtils, so that not all clients have to re-implement it.
* Rename `walkDownResults` -> `walkDownAllResults` and `walkUpOperands` -> `walkUpAllOperands` and make these functions client configurable.
2022-07-20 13:50:18 +02:00
Erik Eckstein
c871197e1a
Swift SIL: fix ApplySite.callerArgIndex
...
It needs to return nil in case the callee argument is not really applied by the ApplySite.
This fixes a crash in EscapeInfo when handling "escaping-to" effects:
If the callee operand of an apply instruction is a `partial_apply` of a `function_ref`, the callee-analysis looks through the `partial_apply` and we get the referenced function as a callee.
In this case there are less apply arguments than callee arguments, because the `partial_apply` already "applies" some of the callee arguments.
rdar://96830171
2022-07-12 17:53:27 +02:00
Anxhelo Xhebraj
03e4e5cdb2
Merge pull request #59729 from Angelogeb/apple/walkutils
...
Swift Optimizer: add def-use/use-def walker utilities
2022-07-07 08:44:31 -07:00
Egor Zhdan
38edc7f377
[cxx-interop][SwiftCompilerSources] Remove getCopiedBridgedStringRef and freeBridgedStringRef
...
`std::string`s can now be passed directly between Swift and C++.
rdar://83361087
2022-07-06 12:57:50 +01:00
Anxhelo Xhebraj
c3ccbde52b
Swift Optimizer: update EscapeInfo to use the generic walker utilities
...
`EscapeInfo` now conforms to the generic protocols defined in `WalkUtils`.
This simplifies the implementation a bit, since trivial instructions are handled
by `WalkUtils` and `EscapeInfo` only has to handle a subset of instructions
inherent to escape information.
Passes using `EscapeInfo` are updated accordingly to become visitors that
customize the `EscapeInfo` walk.
2022-07-05 11:28:49 -07:00
Egor Zhdan
f476f6245c
[cxx-interop][SwiftCompilerSources] Workaround for std::string crash on arm64 Linux
...
`std::string` constructor crashes when called from `SILBridging.cpp`, likely due to a miscompile. This is a workaround that fixes the crash.
2022-06-15 15:54:45 +01:00
Egor Zhdan
ffb9ee9422
Revert "Revert "[cxx-interop][SwiftCompilerSources] Fix conversion between std::string and Swift.String""
...
This reverts commit 9542837a18 .
2022-06-09 23:40:51 +01:00
Erik Eckstein
a17ee435b6
Swift SIL: fix var ApplySite.arguments
...
In case of type-dependent operands, not all operands are part of the arguments
2022-06-08 22:51:57 +02:00
Egor Zhdan
9542837a18
Revert "[cxx-interop][SwiftCompilerSources] Fix conversion between std::string and Swift.String"
...
This reverts commit be711e387f .
2022-06-08 14:10:04 +01:00
Egor Zhdan
be711e387f
[cxx-interop][SwiftCompilerSources] Fix conversion between std::string and Swift.String
...
This fixes a dangling pointer issue when creating a `Swift.String` from `std::string`.
Also fixes a warning:
```
warning: variable 's' was never mutated; consider changing to 'let' constant
var s = SILBasicBlock_debugDescription(bridged)
~~~ ^
let
```
rdar://92963081
rdar://93053488
2022-05-30 20:06:36 +01:00
Erik Eckstein
a91d541a26
Swift SIL: add ApplySite.substitutionMap and ApplySite.getArgumentConvention()
2022-05-12 21:48:37 +02:00
Erik Eckstein
1a933fc76e
Swift SIL: add Type.getIndexOfEnumCase(withName:)
...
... to get the enum case index with a given name.
2022-05-12 21:48:37 +02:00
Erik Eckstein
b0003d51da
Swift SIL: add an initializer to create an empty SubstitutionMap
2022-05-12 21:48:37 +02:00
Erik Eckstein
7c71f0091e
Swift SIL: add UseList.isSingleUse
2022-05-12 21:48:37 +02:00
Erik Eckstein
dd5d5f97c4
Swift SIL: add Function.hasSemanticsAttribute
2022-05-12 21:48:37 +02:00
Erik Eckstein
ad9dafc9bf
Swift SIL: add Value.definingBlock
...
and re-factor `Value.definingInstruction`
2022-05-12 21:48:37 +02:00
Erik Eckstein
3b43da9637
Swift Optimizer: improve ergonomics of Builder and PassContext
...
* split the PassUtils.swift file into PassContext.swift and Passes.swift
* rework `Builder` bridging allowing more insertion point variations, e.g. inserting at the end of a block.
* add Builder.create functions for more instructions
* add `PassContext.splitBlock`
* move SIL modification functions from PassContext to extensions of the relevant types (e.g. instructions).
* rename `Location.bridgedLocation` -> `Location.bridged`
2022-05-12 21:48:37 +02:00
Erik Eckstein
14b985d87e
Swift SIL: support ownership
...
* add the `Ownership` enum and the `Value.ownership` getter
* add `Function.hasOwnership`
2022-05-12 21:48:37 +02:00
Erik Eckstein
cd456fa792
Swift SIL: make Function.name and GlobalVariable.name return a StringRef and not a String
...
and introduce the StringRef struct.
It's more efficient.
Also, rename the `HasName` protocol to `HasShortDescription`, which introduces the new requirement `shortDescription`. This is need because `name` now has `StringRef` type and not `String` anymore
2022-05-12 21:48:37 +02:00
Allan Shortlidge
1ffe55b856
Revert "swift SIL: Fix variable 's' was never mutated; consider changing to 'let' constant warnings."
...
This reverts commit d83c17e832 .
2022-05-10 10:38:58 -07:00
Allan Shortlidge
d83c17e832
swift SIL: Fix variable 's' was never mutated; consider changing to 'let' constant warnings.
2022-05-06 17:29:12 -07:00
Egor Zhdan
145ed33482
[cxx-interop][SwiftCompilerSources] Use std::string instead of BridgedStringRef
...
This reverts commit 2900dec7
2022-05-03 19:48:14 +01:00
Erik Eckstein
1c4ba46c3b
EscapeInfo: fix a bug and some refactoring
...
Add a flag `analyzeAddresses` for distinguishing address vs value escape analysis. This is simpler than handling that in the visitUse/visitDef closures.
Also, fix a related bug, which let an address, which is escaping to a function, get unnoticed.
2022-04-25 08:56:24 +02: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
Erik Eckstein
a5ac6c2cff
TypeLowering: add a recursive property to check if a type contains a RawPointer
...
This is needed for the new escape analysis
2022-04-22 09:50:07 +02:00
Erik Eckstein
b75108e70a
Swift SIL: a few small addition to SmallProjectionPath
...
* rename `matchesAllValueFields` -> `topMatchesAnyValueField`
* add `hasSingleClassIndirection` and `hasClassProjection`
* add `popLastClassAndValuesFromTail`
2022-04-22 09:50:07 +02:00