Skip to content

Add some swift SIL+Optimizer infrastructure #60745

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 17 commits into from
Aug 25, 2022

Conversation

eeckstein
Copy link
Contributor

This PR contains a lot of changes which I need for my upcoming work on stack protectors.

Most notably:

  • support for module passes
  • a utility for doing inter-procedural caller-analysis: FunctionUses

There are many more small additions and improvements. For details see the commit list.

To be used to iterate over all instructions in a function without the need of two loops - one for blocks and one for instructions.
E.g. used if function effects are changed. This tells the passmanager that something changed, but no SIL-specific analysis have to be invalidated.
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`.
Returning true if the element was not contained in the set before inserting
To add a module pass in `Passes.def` use the new `SWIFT_MODULE_PASS` macro.
On the swift side, create a `ModulePass`.
It’s run function receives a `ModulePassContext`, which provides access to all functions of a module.
But it doesn't provide any APIs to modify functions.
In order to modify a function, a module pass must use `ModulePassContext.transform(function:)`.
…ctions`

* 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
* add `createAllocStack`
* add `createDeallocStack`
* add `createCopyAddr`
* add `@discardableResult` to the existing `createDeallocStackRef`
Provides a list of instructions, which reference a function.

A function "use" is an instruction in another (or the same) function which references the function.
In most cases those are `function_ref` instructions, but can also be e.g. `keypath` instructions.

'FunctionUses' performs an analysis of all functions in the module and collects instructions which reference other functions.
This utility can be used to do inter-procedural caller-analysis.
And move it out of the "proposals" folder, directly into "docs". It's now more a documentation of what we have and useful as a programming guide.
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein eeckstein requested a review from atrick August 24, 2022 16:23
@eeckstein eeckstein merged commit 937d3b9 into swiftlang:main Aug 25, 2022
@eeckstein eeckstein deleted the swift-sil-infrastructure branch August 25, 2022 05:21
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