This commit adds a flag to disable optimizations on a specific functions. The
primary motivation of this patch is to allow the optimizer developers to reduce
testcasese by disabling optimizations of parts of the code without having to
recompile the compiler or inspect SIL. The annotations "inline(never)"
and "optimize.none" can go a long way.
The second motivation for this patch is to allow our internal adopters to work
around compiler bugs.
rar://19745484
Usage:
@semantics("optimize.never")
public func miscompile() { ... }
Swift SVN r27475
Example: swiftc -O -Xllvm -sil-disable-pass="Performance Inliner" test.swift
All passes are disabled which contain the option argument string in their name.
This is useful for testing and debugging.
Swift SVN r27204
Avoid running a pass a second time if the pass has its own optimize-until-no-more-changes loop.
This pass property can be configured.
Currently I assume that all our function passes don't need to run a second time (without other changes in between).
It further reduces the number of pass runs by about 6%. But this improvement is cosmetic. There is no significant compile time reduction.
There are no performance changes.
Swift SVN r26760
It avoids that a pass runs a second time if didn't make any changes in the previous run and no other pass changed the function in between.
rdar://problem/20336764
In this change I also removed the CompleteFunctions analysis which is now obsolete.
Some measurements with swiftbench (-wmo, single threaded):
It reduces the number of pass runs by about 28%. Because only passes are skipped that don't do anything, the effect on compile time is not so dramatic.
The time spent in runSILOptimizationPasses is reduced by ~9% which gives a total compile time reduction of about 3%.
Swift SVN r26757
To set the PassKind automatically, I needed to refactor some code of the pass manager and the pass definitions.
The main changes are:
1) SILPassManager now has an add-function for each pass: PM.add(createP()) -> PM.addP()
2) I removed the ARGS argument in Passes.def, which we didn't use anyway.
Swift SVN r26756
In the case of a crash in the optimizer or verifier, this prints out information
about the source of the crash. This saves engineering time by allowing one to
get some quick information about the crash without needing to jump into the
buffer.
In the case of a SILFunctionTransform, this prints out the name of the function
being optimized and the name of the transform.
In the case of a SILModuleTransform, this prints out the name of the transform.
<rdar://problem/19946491>
Swift SVN r25831
This is b/c the callgraph verifier currently trips (I believe) due to passes
eliminating ApplyInsts without invalidating the CallGraph.
Swift SVN r25517
Currently no passes implement this, but I am going to add support to the
callgraph. I just ran into a callgraph bug that this would have helped
to catch.
rdar://19930214
Swift SVN r25514
-sil-print-only-functions takes a string as its argument and only prints out SIL for the functions whose name contains this string as a substring. This is useful e.g. if you want to emit SIL only for certain functions and see how their SIL changes after each pass.
Swift SVN r24914
-sil-print-before=<string> Print out the sil before passes which contain this string in their names
-sil-print-after=<string> Print out the sil after passes which contain this string in their names
-sil-print-around=<string> Print out the sil before and after passes which contain this string in their names
Output can further be restricted to a single function with the existing option
-sil-print-only-function=<function>
Swift SVN r23737
Revert "For debugging purposes allow passes to stop any more passes from running by calling PassManager::stopRunning()."
This reverts commit r20604.
This reverts commit r20606.
This was some debugging code that snuck in.
Swift SVN r20615
In the current setup analysis information is not reused by new pass managers.
There is no point in having different pass managers. Instead, we can just remove
transformations, reset the internal state of the pass manager, and add new
transformation passes. Analysis information can be reused.
Reuse one pass manager in the pass pipeline so that we don't have to
unnecessarily recompute analysis information.
Swift SVN r19917
This prevents us going in an infinite optimization loop. According to Michael,
we need at least 15 for performance.
The fix at r17635 does not handle the case where the recursive function calls
itself only once.
rdar://16761933
Swift SVN r17686
Verifying the module after every function transform is run on every function
takes so much compile time that the mode is not really useful. I don't imagine
we are really getting anything for verifying the whole module so it makes sense
to limit what we are verifying.
Swift SVN r14834
PassManager.
I think this is much cleaner and more flexible. The various pass
builders have no business marshalling these things around, and they
shouldn't be bound to the pass C'tor. In the future we will be able
override and dynamically modify pass configuration this way.
Swift SVN r13626
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