(libraries now)
It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.
This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.
Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
(Headers first)
It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.
This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.
Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
Move these to SILDeclRef, maybe not the best place but a good home for now.
Factor out a new requiresForeignToNativeThunk() function, which cleans up
some code duplication introduced by the following patch:
478e1c7513
This is a small step towards consolidating duplicated logic for figuring out
method dispatch semantics and emitting curry thunks.
getOverriddenVTableEntry only goes one level up in the class hierarchy,
but getConstantOverrideInfo requires that the next level up not itself be an
override.
A little bit of refactoring:
SILDeclRef::getOverriddenVTableEntry()
-> SILDeclRef::getNextOverriddenVTableEntry()
static findOverriddenFunction()
-> SILDeclRef::getBaseOverriddenVTableEntry()
rdar://problem/22749732
Use malloc/free for allocating/freeing SIL instructions instead of using the BumpPtrAllocator. This allows for memory reuse and significantly reduces the memory footprint of the compiler.
For example, a peak memory usage during a compilation of the standard library and StdlibUnitTest is reduced by 25%-30%. The performance of the compiler seems to be not affected by this change, i.e. no slowdown is measured.
The use-after-free issues reported by build bots are fixed now.
rdar://23303031
between SILType and a list of ProjectionPath is cached. This pass is immutable and never invalidated.
Redundant load elimination and dead store elimination use this pass to improve compilation time.
I see the hit rate of the cache to be ~95%.
Without the pass.
----------------
Running Time Self (ms) Symbol Name
16338.0ms 28.2% 62.0 swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>)
2716.0ms 4.6% 5.0 (anonymous namespace)::SimplifyCFGPass::run()
2654.0ms 4.5% 12.0 (anonymous namespace)::ARCSequenceOpts::run()
2218.0ms 3.8% 7.0 (anonymous namespace)::SILCombine::run()
1660.0ms 2.8% 66.0 (anonymous namespace)::SILCSE::run()
1625.0ms 2.8% 120.0 (anonymous namespace)::RedundantLoadElimination::run()
1491.0ms 2.5% 35.0 (anonymous namespace)::DeadStoreElimination::run()
1213.0ms 2.0% 1.0 swift::BottomUpFunctionOrder::getFunctions()
777.0ms 1.3% 127.0 (anonymous namespace)::DCE::run()
381.0ms 0.6% 2.0 (anonymous namespace)::SILCodeMotion::run()
With the pass.
--------------
Running Time Self (ms) Symbol Name
15866.0ms 26.8% 73.0 swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>)
2736.0ms 4.6% 6.0 (anonymous namespace)::SimplifyCFGPass::run()
2696.0ms 4.5% 14. (anonymous namespace)::ARCSequenceOpts::run()
2393.0ms 4.0% 7.0 (anonymous namespace)::SILCombine::run()
1673.0ms 2.8% 81. (anonymous namespace)::SILCSE::run()
1290.0ms 2.1% 2.0 swift::BottomUpFunctionOrder::getFunctions()
1288.0ms 2.1% 17.0 swift::BottomUpFunctionOrder::FindSCCs(swift::SILModule&)
1140.0ms 1.9% 138.0 (anonymous namespace)::RedundantLoadElimination::run()
1119.0ms 1.8% 21.0 (anonymous namespace)::DeadStoreElimination::run()
749.0ms 1.2% 147.0 (anonymous namespace)::DCE::run()
379.0ms 0.6% 7.0 (anonymous namespace)::SILCodeMotion::run()
256.0ms 0.4% 11.0 (anonymous namespace)::ABCOpt::run()
There's a buggy SIL verifier check that was previously tautological,
and it turns out that it's violated, apparently harmlessly. Since it
was already doing nothing, I've commented it out temporarily while
I figure out the right way to fix SILGen to get the invariant right.
Match the new SILGen pattern, where only the box parameter is partially applied to the closure, and the address of the value is projected on the callee side.
This commit adds a hook that allows passes, analysis or data structures that can
be registered as receivers of delete notifications to decide if they want to
receive notifications All of the analysis and the currently executing passes are
automatically registered to receive notifications and this hook is useful in
reducing the runtime overhead. With this change the only analysis that accepts
notifications is alias analysis.
This centralizes the entrypoints for creating SILFunctions. Creating a
SILFunction is intimately tied to a specific SILModule, so it makes sense to
either centralize the creation on SILModule or SILFunction. Since a SILFunction
is in a SILModule, it seems more natural to put it on SILModule.
I purposely created a new override on SILMod that exactly matches the signature
of SILFunction::create so that beyond the extra indirection through SILMod, this
change should be NFC. We can refactor individual cases in later iterations of
refactoring.
This commit adds the basic support for delete notification handlers. The SIL
Module is notified every time an instruction is deleted. The module will forward
notification messages to users who ask to be notified. The motivation for this
work is described in the upcoming commit to OptimizerDesign.md.
Please stop adding uses of this; the source base should be portable
C++ to the greatest extent possible, and saving a few characters of
typing does not qualify for an exception.