Hey guys. I have a couple of questions to understand how to navigate the Swift codebase and the state of LLVM passes here. Pardon the super newbie questions :)
Which LLVM version is Swift (let's say 5.2) based on?
I have a few passes that are used to add a few extensions to the language with the usage of function annotations. Would it be easy to use an existing LLVM pass in Swift or should one create it anew?
If one would create a new Swift pass, is there a "hello world" example somewhere? If not, would lib/SILOptimizer/Transforms or lib/LLVMPasses be a good place to start?
What is SILOptimizer (and what is SIL)?
Finally, would Apple Appstore accept apps made with a custom-built Swift toolchain, or would they completely refuse anything outside of XCode's toolchain, even if bitcode is bundled?
SIL stands for Swift Intermediate Language, it was created with the purpose of doing static analysis and generation of diagnostics after the AST and before lowering to LLVM IR.
SILOptimizer is in charge of optimizing the raw SIL to canonical SIL, it performs optimizations like constant folding etc, and also can produce really helpful diagnostics, additionally (This I am not sure of) it performs several optimizations to enhance the final result of the executable.
Here is the awesome documentation that is on the swift repository:
That's an Apple policy question which isn't really right for this forums.
That said, if they do accept it, you will need to be careful not to change anything in the runtime or ABI, and to not deploy your own version of the runtime as it will conflict with the system's version.
Which LLVM version is Swift (let's say 5.2) based on?
I don't know anything about SIL but you can check this for yourself, by adding the -Xcc -v flag when compiling hello world. Here's what I get with the latest 5.2.5 release and a recent 5.3 snapshot:
This tells you the version of libclang that the Swift compiler has baked in, along with a bunch of other clang info that I've snipped. Since Swift uses a forked LLVM, I suppose it's theoretically possible that's only the version of libclang and not the underlying LLVM, but the build scripts and CMake config all show those same versions for LLVM too.
For documentation, you might want to look at docs/README.md and docs/ExternalResources.md in the repository.
For the App Store policies, you probably want to consult the App Store Guidelines:
Apps distributed via the Mac App Store have some additional requirements to keep in mind:
[..]
(ii) They must be packaged and submitted using technologies provided in Xcode; no third-party installers allowed. They must also be self-contained, single application installation bundles and cannot install code or resources in shared locations.