The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.
Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.
Swift SVN r26449
Simplify binary switches to select_enum instead of enum_is_tag, and make a first attempt at changing passes over to recognize limited forms of select_enum instead of enum_is_tag. There is one case in test/SILPasses/simplify_cfg.sil I wasn't able to figure out, and there are a lot more general passes we could define in terms of select_enum.
Swift SVN r22615
Update SILGen to create SILGlobalVariable and SILGlobalAddrInst instead of
GlobalAddrInst. When we see a definition for a global variable, we create
the corrsponding SILGlobalVariable definition.
When creating SILGlobalVariable from a global VarDecl, we mangle the global
VarDecl in the same way as we mangle it at IRGen. The SILLinkage is also
set in the same way as we set it at IRGen.
At IRGen, we use the associated VarDecl for SILGlobalVariable if it exists,
to have better debugging information.
We set the initializer for SILGlobalVariable definition only.
We also handle SILGlobalAddrInst in various SILPasses, in the similar way
as we handle GlobalAddrInst.
rdar://15493694
Swift SVN r21887
This will hopefully make it clearer as we onboard people that
SimplifyInstruction should not add instructions to the IR by making it clearer
that it is an analysis, not a pass.
Swift SVN r21752
This looks for @effects(readnone) on functions. A follow up commit will mark
_swift_isClassOrObjCExistential as readnone allowing us to CSE it.
rdar://17961249
Swift SVN r21285
Currently this should not matter because isSideEffectFree calls isReadNone for
swift builtins. The only difference between isReadNone and isSideEffectFree is
that isSideEffectFree allows llvm intrinsics that are readonly.
Looking at llvm's intrinsic td file I did not see any readonly functions so we
should also be safe before this change. But better safe than sorry - especially
if someone changes the implementation of isSideEffectFree to be more permissable
later.
Swift SVN r21239
This reduces the number of optimizable retain, release pairs in a swap on Strings from 6 to 2:
func foo(inout T : [String]) {
swap(&T[9], &T[1])
}
Swift SVN r21191
Now the pass does not need to know about the pass manager. We also don't have
runOnFunction or runOnModule anymore because the trnasformation knows
which module it is processing. The Pass itself knows how to invalidate the
analysis, based on the injected pass manager that is internal to the
transformation.
Now our DCE transformation looks like this:
class DCE : public SILModuleTransform {
void run() {
performSILDeadCodeElimination(getModule());
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
}
};
Swift SVN r13598
The instruction that we want to sink is the last instruction in a block that does not dominate anything. In other words, the only possible user is the terminator.
Swift SVN r13110
In some cases the duplicated code in the predecessors is a strong_release
and sinking it allows Box2Stack to promote it. This accelerates two of
the string benchmarks by 20%.
Swift SVN r13093