Skip to content

Add swift SIL/Optimizer infrastructure #40805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 13, 2022

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Jan 11, 2022

All this are generally useful additions. The motivation to add them now is because they will be needed by #39438.

The main changes are:

  • Improve collections in the swift SIL/Optimizer to make it more user friendly, especially for debugging
  • add basic block utilities: BasicBlockSet, BasicBlockWorklist, BasicBlockRange
  • add InstructionRange which can be used for value lifetime analysis.
  • add analysis bridging for the dominator and post-dominator tree analysis and the DeadEndBlocksAnalysis
  • and more smaller additions and improvements.

For details see the commit messages.

InstructionRange (which builds on top of BasicBlockRange) is doing backward reachability analysis e.g. to compute the life range of a value. For reference: on the C++ side we have four different utilities for this purpose, which all do approximately the same thing: ValueLifetimeAnalysis, findJointPostDominatingSet, PrunedLiveness and BackwardReachability (We should avoid piling up redundant utilities). Instruction/BasicBlockRange is the utility for this purpose on the swift side.

This PR does not contain tests for the new utilities, because they will be tested by the larger #39438.

@eeckstein eeckstein requested a review from atrick January 11, 2022 21:30
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

* instructions: function_ref, mark_dependence
* add `BuiltinInst.id`
* add isObjC and canAllocOnStack for alloc_ref and alloc_ref_dynamic
* add `ApplySite::referencedFunction`
* add `Builder.createDeallocStackRef`
* add == and != operators for `Function`
* add `List.first` and `ReverseList.first`
Improve block/instruction lists and similar collections

* pretty print collections in the form “[a, b, c]”
* also do this for lazy sequences
* define a custom Mirror
* in a collection, only print the name of blocks, functions and globals (instead of the full object)
* replace `BasicBlock.reverseInstructions` with `BasicBlock.instructions.reversed()` - in an efficient way
…ackList

* add `BasicBlockSet`
* add `BasicBlockWorklist`
* add `BasicBlockRange`, which defines a range of blocks from a common dominating “begin” block to a set of “end” blocks.
* add  `InstructionRange`, which is similar to `BasicBlockRange`, just on instruction level. It can be used for value lifetime analysis.
* rename `StackList` -> `Stack` and move it to `Optimizer/DataStructures`
* rename `PassContext.passContext` to `PassContext._bridged`
* add notify-functions to PassContext
This bridges to the StackNesting utility in C++
…lity

For inserting new instruction after another instruction. This is especially interesting if the insertion point is a terminator.
In this case, the new instruction(s) are inserted in the successor block(s).
@eeckstein eeckstein force-pushed the swift-sil-infrastructure branch from a0d2d11 to 82ad1fa Compare January 12, 2022 14:54
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein eeckstein merged commit f87fc5a into swiftlang:main Jan 13, 2022
@eeckstein eeckstein deleted the swift-sil-infrastructure branch January 13, 2022 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant