Erik Eckstein
8d90dafb22
Swift SIL: add Function.reversedInstructions
2023-01-16 19:00:09 +01:00
Erik Eckstein
3645becada
PassManager: infrastructure to disable or enable a specific instruction simplification
...
* for testing: add the option `-simplify-instruction=<instruction-name>` to only run simplification passes for that instruction type
* on the swift side, add `Options.enableSimplification`
2023-01-16 19:00:09 +01:00
Erik Eckstein
72d3f8e3ff
Swift SIL: add SubstitutionMap.isEmpty
2023-01-16 19:00:09 +01:00
Erik Eckstein
3f457eb1d4
Swift SIL: add IntegerLiteralInst.value
2023-01-16 19:00:09 +01:00
Erik Eckstein
ee80da2e59
Swift SIL: fix the CondBranch instruction
...
* make its properties public
* fix the range construction in `trueOperands`
2023-01-16 19:00:09 +01:00
Erik Eckstein
d2bdec9f59
Swift SIL: add MarkUninitializedInst and MetatypeInst instructions
2023-01-16 19:00:09 +01:00
Erik Eckstein
221a16ba17
Swift SIL: add more arguments to Builder.createApply
...
add the `isNonThrowing` and `isNonAsync` flags and the `specializationInfo`
2023-01-16 19:00:09 +01:00
Erik Eckstein
cf8c68c6c4
Swift SIL: add Type.hasArchetype
2023-01-16 19:00:09 +01:00
Erik Eckstein
230c93df30
SIL Optimizer: add some SIL modification APIs
...
* `MutatingContext.notifyInvalidatedStackNesting` and `MutatingContext.needFixStackNesting`
* `MutatingContext.tryDeleteDeadClosure`
* `MutatingContext.erase(block:)`
* `Undef.get`
* `BasicBlock.moveAllInstructions`
* `BasicBlock.eraseAllArguments`
* `BasicBlock.moveAllArguments`
* `TermInst.replaceBranchTarget`
2023-01-16 19:00:09 +01:00
Erik Eckstein
ea746479ad
SIL Optimizer: rename directory InstructionPasses -> InstructionSimplification
2023-01-16 16:16:51 +01:00
Erik Eckstein
22f03cdde6
Swift Optimizer: generalize the worklist data structure
...
Rename `BasicBlockWorklist.swift` to `Worklist` and make it generic for any elements.
Also, add methods `popAndForget` and `isEmpty`
2023-01-16 16:16:51 +01:00
Erik Eckstein
f3717d5127
Swift Optimizer: add the ReachableBlocks utility
2023-01-16 16:16:51 +01:00
Erik Eckstein
393d1a1488
SIL Builder: rename insert(at:) -> insert(before:)
...
It matches with `insert(after:)` and the intent should be clearer now
2023-01-16 15:11:34 +01:00
Erik Eckstein
cc68bd98c9
Swift Optimizer: rework pass context types and instruction passes
...
* split the `PassContext` into multiple protocols and structs: `Context`, `MutatingContext`, `FunctionPassContext` and `SimplifyContext`
* change how instruction passes work: implement the `simplify` function in conformance to `SILCombineSimplifyable`
* add a mechanism to add a callback for inserted instructions
2023-01-16 15:11:34 +01:00
Erik Eckstein
c32d6cd0fb
EscapeUitls: some refactoring
2023-01-16 15:11:34 +01:00
Erik Eckstein
eb0d6ed87e
StackPromotion: some refactoring
...
NFC
2023-01-16 15:11:34 +01:00
Erik Eckstein
6c35258f83
Swift SIL: rename parent accessors to parentX, e.g. Instruction.parentBlock
...
It makes it easier to read
2023-01-16 15:11:34 +01:00
eeckstein
6b33768e25
Merge pull request #62864 from eeckstein/fix-compute-side-effects
...
ComputeSideEffects: correct side effects for destroy_addr
2023-01-05 20:35:35 +01:00
Erik Eckstein
1f0f9d65b9
ComputeSideEffects: ignore side effects of debug_value with address operands
...
We already ignored side effects of debug_value with non-address operands. Now also do this for address operands.
2023-01-05 09:56:11 +01:00
Erik Eckstein
e26affacbd
ComputeSideEffects: correct side effects for destroy_addr
...
A destroy_addr also involves a read from the address. It's equivalent to a `%x = load [take]` and `destroy_value %x`.
It's also a write, because the stored value is not available anymore after the destroy.
Fixes a compiler crash in SILMem2Reg.
rdar://103879105
2023-01-05 09:56:11 +01:00
Erik Eckstein
3d86732bea
EscapeUtils: fix a wrong handling of argument indices in walkUpApplyResult
...
Fixes a crash
rdar://103526983
2023-01-04 11:52:19 +01:00
Erik Eckstein
beb46eb624
Use the new escape and side effects in alias analysis
2022-12-21 17:41:46 +01:00
Saleem Abdulrasool
04f4d66b73
Merge pull request #62388 from compnerd/naming
...
build: rename `EXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR`
2022-12-18 08:50:40 -08:00
Erik Eckstein
d4d1620f28
Swift SIL: rework Instruction and BasicBlock lists to support deleting instructions during iteration
...
Replace the generic `List` with the (non-generic) `InstructionList` and `BasicBlockList`.
The `InstructionList` is now a bit different than the `BasicBlockList` because it supports that instructions are deleted while iterating over the list.
Also add a test pass which tests instruction modification while iteration.
2022-12-12 19:08:57 +01:00
Erik Eckstein
a8ba48e71d
Swift SIL: add Instruction.isDeleted API
2022-12-12 19:08:57 +01:00
Erik Eckstein
9e0b86ddbd
Swift SIL: add Builder.createUnreachable()
2022-12-12 19:08:57 +01: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
Saleem Abdulrasool
b58dbb2c0a
build: rename EXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR
...
Rename the variable to `SWIFT_PATH_TO_STRING_PROCESSING_SOURCE` to match
the variables used for libdispatch, swift-syntax.
2022-12-03 17:17:13 -08:00
Anton Korobeynikov
dd6f468d09
Ensure that partial_apply of partial_apply does not produce conservative global side effects. ( #62351 )
...
Fixes #62249
2022-12-02 06:14:46 -08:00
Egor Zhdan
7203a05479
[cxx-interop] Replace std module name with the new spelling CxxStdlib
...
This is the second step in renaming the C++ stdlib module `std` into `CxxStdlib`.
See https://github.com/apple/swift/pull/61099 .
2022-11-29 17:33:35 +00:00
Rintaro Ishizaki
2f50d03d77
Remove swiftCompilerModules_SwiftSyntax library
...
This was used by _InternalSwiftSyntaxParser which was removed some time
ago.
2022-11-17 10:11:26 -08:00
Erik Eckstein
ef302ce4ac
SILOptimizer: enable stack protection by default
...
The pass to decide which functions should get stack protection was added in https://github.com/apple/swift/pull/60933 , but was disabled by default.
This PR enables stack protection by default, but not the possibility to move arguments into temporaries - to keep the risk low.
Moving to temporaries can be enabled with the new frontend option `-enable-move-inout-stack-protector`.
rdar://93677524
2022-11-11 17:14:08 +01:00
Erik Eckstein
82107c5bf2
ComputeSideEffects: consider effects in dead-end blocks
...
It was a wrong assumption that we can ignore effects in dead-end blocks.
2022-11-09 08:06:19 +01:00
Erik Eckstein
0ada6ec5bd
SIL SideEffects: handle program termination point functions
...
We can ignore any memory writes in a program termination point, because it's not relevant for the caller.
But we need to consider memory reads, otherwise preceeding memory writes would be eliminated by dead-store-elimination in the caller.
E.g. String initialization for error strings which are printed by the program termination point.
Regarding ownership: a program termination point must not touch any reference counted objects.
2022-11-09 08:06:19 +01:00
Erik Eckstein
ab2fe452f9
ComputeSideEffects: checking for unknown argument uses need to consider type which contain raw pointers
2022-11-09 08:06:19 +01:00
Erik Eckstein
dbb4d4db32
ComputeSideEffects: fix a typo in a comment
2022-11-09 08:06:19 +01:00
Erik Eckstein
ebc16d9062
EscapeInfoDumper: dump address-reachable-from-object information
2022-11-09 08:06:19 +01:00
Zoe Carver
ac131dfbf6
Merge pull request #60786 from zoecarver/unavailable-attr-class-templates
...
[cxx-interop] Mark un-specialized class templates as unavailable in Swift.
2022-10-26 11:07:56 -07:00
nate-chandler
9c17447158
Merge pull request #61654 from nate-chandler/shrink_borrow_scope/handle_barrier_merge_terminators
...
Removed deinit barrier workaround.
2022-10-24 14:40:21 -07:00
Nate Chandler
f98917b1fe
Removed workaround for missing Swift sources.
...
Previously, to workaround an issue with ShrinkBorrowScope (where it
assumed a reasonable definition of isDeinitBarrier), a placeholder
version of the function was added. It is now removed by moving the
implementation of a version of that predicate back to C++.
2022-10-24 08:47:18 -07:00
Egor Zhdan
a6372e955a
Merge pull request #61618 from apple/egorzhdan/scs-reapply-enums
...
Revert "Revert "[cxx-interop][SwiftCompilerSources] Use C++ enums directly from Swift""
2022-10-20 15:46:17 +01:00
Erik Eckstein
7db7065740
swift side effects: add CalleeAnalysis.getSideEffects(of: apply)
2022-10-20 09:20:28 +02:00
Erik Eckstein
698196b1eb
SILFunction: add getMemoryBehavior
...
This retrieves the side effect information from the function effects.
2022-10-20 09:20:28 +02:00
Erik Eckstein
b275d987b5
ComputeSideEffects: handle reference count reading instructions.
...
Conservatively model those effects as "destroy" effects.
2022-10-20 09:20:28 +02:00
Erik Eckstein
8961e2982e
swift side effects: some additions and refactoring
...
add `Function.getSideEffects(forArgument:,atIndex:,withConvention:)`
2022-10-20 09:20:28 +02:00
Erik Eckstein
173b698563
Swift SIL: add ApplySite.numIndirectResultArguments
2022-10-20 09:20:28 +02:00
Erik Eckstein
60609eb809
Swift SIL: invert Type.isNonTrivialOrContainsRawPointer to Type.isTrivialNonPointer
...
This is consistent with `Type.isTrivial`.
Also, introduce corresponding properties in `Value`: `hasTrivialType` and `hasTrivialNonPointerType`, because
1. It's less to type than `Type.isTrivial(in: function)` because `Value` knows in which function it is.
2. It fixes the corner case where value is an `Undef`, which has not parent function.
2022-10-20 09:20:28 +02:00
Erik Eckstein
0a2d233d1e
compute effects: Don't modify the effects if they didn't change
...
This avoids sending a change notification which can trigger unnecessary other invalidations.
2022-10-20 09:20:28 +02:00
Erik Eckstein
0d73a21c14
EscapeUtils: ignore debug_value for address types.
...
It has already been ignored for value types, but not for address types.
2022-10-20 09:20:28 +02:00
Erik Eckstein
b5b055adcb
Swift Utils: make StringRef matchable in patterns
...
By adding a `~=` operator with `StaticString`
2022-10-20 09:20:28 +02:00