Commit Graph

280 Commits

Author SHA1 Message Date
Nadav Rotem
4ba1dc2259 Update the smallvector size to match the number of passes and analysis we are using.
Swift SVN r26373
2015-03-20 22:53:06 +00:00
Nadav Rotem
48f84e1132 [PM] Add API for module passes to invalidate a specific function.
Swift SVN r26371
2015-03-20 22:53:04 +00:00
Mark Lacey
a30d13b0ce Simplify handling of metatypes in devirtualization.
Make the devirtualization functions take the actual type we're
devirtualizing (or speculatively devirutalizing) to, in order to
simplify the handling of metatypes. Remove the ClassDecl parameter from
these functions since it can always be derived from this type.

These changes set things up for more forthcoming improvements to
metatype handling.

As part of this I've simplified the function that determines if a member
is known to be 'final'. My expectation is that this can be further
simplified by removing the type parameter as part of other improvements
to metatype handling.

Swift SVN r26165
2015-03-15 22:04:46 +00:00
Roman Levenstein
51ad2d964d Move the logic for type casts optimizations into one place.
This is mostly a re-factoring. It creates a new helper class CastOptimizer which contains all the logic for performing type casts optimizations. This logic is a copy of the current logic from sil-combine and simplify-cfg. Those passes will become clients of this new helper class.

Swift SVN r26122
2015-03-14 02:23:05 +00:00
Mark Lacey
ffaa74bfbb Remove DevirtClassMethodInfo.
It turns out we're already at a point where we can easily pass the same
data along to the devirtualization functions, and were already passing
some of it.

Swift SVN r26040
2015-03-12 07:46:10 +00:00
Mark Lacey
b98f1cd51b Create a thinner coupling between devirtualization functions.
Redefine DevirtClassMethodInfo to carry fewer values in an effort to
reduce the coupling between these functions. Long term I expect this
structure to go away, but that is difficult to do without more
refactoring.

Swift SVN r26034
2015-03-12 05:09:47 +00:00
Roman Levenstein
b5f73b2f34 Add support for removal of the dead code after "unreachable" even during SIL cloning and generic specialization.
SIL cloning is not always followed by sil-combine, which could do the clean-up. Therefore, take care of removing the dead code after "unreachable" instructions at the end of the cloning process.

Swift SVN r26029
2015-03-12 03:37:28 +00:00
Nadav Rotem
5d08db87ec [overflow checks] Add a new (empty) pass to remove overflow checks
Swift SVN r26006
2015-03-12 00:55:06 +00:00
Arnold Schwaighofer
819eba2360 Add a utility function to split edges between two basic blocks.
Swift SVN r25980
2015-03-11 17:25:15 +00:00
Arnold Schwaighofer
aa24e126e4 ArraySemantic: Move to its own file in SILAnalysis
I want to use it in ARCAnalysis.

Swift SVN r25924
2015-03-10 15:20:20 +00:00
Michael Gottesman
b2d9833259 Add PrettyStackTrace support for SILFunctionTransforms and SILModuleTransforms.
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
2015-03-07 03:08:28 +00:00
Mark Lacey
c26c15cc9f Don't pass arguments that can be easily derived from other arguments.
Swift SVN r25799
2015-03-06 06:56:56 +00:00
Arnold Schwaighofer
06f7c40c32 ArraySemanticsCall: Handle @guaranteed parameters
Also improve checking of parameter requirements.

This is needed for our move to +0 self.

radar://20039357

Swift SVN r25798
2015-03-06 03:20:47 +00:00
Mark Lacey
757ae5796e First step in splitting out a utility for devirtualizing from the pass.
No functional change here, and this is not in its final form. This is
just cut/paste/tweak to split the code apart in a first reasonable form.

Swift SVN r25769
2015-03-04 22:21:38 +00:00
Erik Eckstein
de09d1e684 SimplifyCFG: create a simplifyBBArgs pass.
Purpose: for testing



Swift SVN r25756
2015-03-04 15:18:08 +00:00
Arnold Schwaighofer
f7c01f2061 Nuke isReadNone function
We can now compute the same result with Inst.mayReadOrWriteMemory(). NFC.

Swift SVN r25743
2015-03-04 05:03:45 +00:00
Arnold Schwaighofer
951dc2875a Nuke isSideEffectFree
We can now compute the same result with Inst.mayHaveSideEffects(). NFC.

Swift SVN r25742
2015-03-04 05:03:44 +00:00
Arnold Schwaighofer
1f399aa192 MergeCondFail: Combine cond_fail instructions in basic blocks
We can combine cond_fail instructions in basic blocks if there is no side-effect
or read in between them.

rdar://20006530

Swift SVN r25697
2015-03-03 00:45:56 +00:00
Arnold Schwaighofer
14ddfe1427 Add an API to ArraySemantic call to get the self argument as an operand.
Swift SVN r25619
2015-02-27 22:07:39 +00:00
Arnold Schwaighofer
0e327ea05b Add a mergeBasicBlockWithSuccessor utility function.
Swift SVN r25614
2015-02-27 22:07:35 +00:00
Nadav Rotem
2f167a37ca Clean up the GenericSpecializer interface. NFC.
Swift SVN r25580
2015-02-27 00:53:10 +00:00
Nadav Rotem
a5119ff22e Fix a bug in the code that specializes individual calls. We need to use the worklist because
the callee may have calls to specialize.

Testcase in the next commit (together with the devirtualizer functionality).

Swift SVN r25575
2015-02-27 00:32:06 +00:00
Nadav Rotem
285e2e88e1 Change the specialization API to allow specialization of individual calls
and specialization using a call tree.

Swift SVN r25573
2015-02-27 00:32:03 +00:00
Nadav Rotem
690cc050f0 Refactor the generic specialization API. NFC.
Swift SVN r25572
2015-02-27 00:32:01 +00:00
Nadav Rotem
932790b4e9 Refactor the generic specialize into two parts: a utility and a pass.
Swift SVN r25570
2015-02-27 00:31:59 +00:00
Nadav Rotem
663482ea93 Split the debugging feature to set the pass name inside the PassManager resetAndRemoveTransformations into a new function.
Swift SVN r25562
2015-02-26 21:01:46 +00:00
Michael Gottesman
4a34f25c6b Add support for verifying analyses when -sil-verify-all is passed in.
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
2015-02-24 22:49:46 +00:00
Erik Eckstein
b8ef26a3bd inliner: remove the obsolete CannotBeInlined cost value
Swift SVN r25427
2015-02-20 15:48:08 +00:00
Luqman Aden
e1c60464d3 Fold getCmpFunction function into helper method on SILBuilder.
Swift SVN r25416
2015-02-20 04:08:08 +00:00
Luqman Aden
858d8d99df SILCombine: Add cmp_*_T . (zext U->T x, zext U->T y) => cmp_*_T (x, y)
peephole for unsigned/equality comparisons.

Fixes <rdar://problem/19759124>

Swift SVN r25404
2015-02-20 00:39:33 +00:00
Michael Gottesman
669cdc537c Create an entrypoint tryToConcatenateStrings and hide the class StringConcatenationOptimizer in Local.cpp.
In every instance, we were just creating the StringConcatenationOptimizer and
then invoking optimize on it. This is a cleaner solution since the details of
how we perform the string concatenation are hidden in Local.cpp instead of being
in a header.

NFC.

Swift SVN r25341
2015-02-17 01:59:13 +00:00
Mark Lacey
03cca73418 Fix naming convention.
Swift SVN r25179
2015-02-11 10:27:19 +00:00
Mark Lacey
c804c50c4d Add a simple utility for determining the lifetime of a value.
This refactors some code out of AllocBoxToStack that computes the
lifetime of a value in the strictess sense, limiting the lifetime to
that value and not anything derived from that value (whether by casting,
projection, etc.).

In the short term this will be used to fix a very rarely hit
optimization in AllocBoxToStack.

Longer term I will replace the other similar code in AllocBoxToStack to
use this instead.

Swift SVN r25176
2015-02-11 10:17:03 +00:00
Michael Gottesman
436f022867 [local] Add tryDeleteDeadClosures.
This utility attempts to delete dead closures with a set of
post-dominating releases using the infrastructure from
getFinalReleasesForValue.

It currently only will eliminate closures that only have retain, release
uses and a final post-dominating release set.

The reason why we need the final post-dominating release set is so that
we can release any captured variables at the points where we would have
deallocated the release. This is b/c captured variables are passed in at
+1 to partial apply.

Swift SVN r25050
2015-02-06 21:59:52 +00:00
Arnold Schwaighofer
283a6bee39 Fix users of ArraySemantics::getSelf to correctly handle Array.init
Array.init does not have a self argument (it returns the newly created array
@owned). Passes using the ArraySemantic::getSelf() interface must handle it
specially.

rdar://19724033

Swift SVN r25013
2015-02-05 19:31:23 +00:00
Erik Eckstein
4dd44833ea Refactor constant folding: extract constant folding to utility functions.
NFC

I need the constant folding functions for my upcoming changes in the inliner.



Swift SVN r24600
2015-01-21 11:11:36 +00:00
Roman Levenstein
5831e7a5cc [sil-dead-function-elimination] Re-factoring of the external function definitions elimination pass.
Rename LateDeadFunctionElimination into ExternalFunctionDefinitionsElimination.
Move ExternalFunctionDefinitionsElimination  out of DeadFunctionElimination and make it a separate pass.
Move a common logic shared by  DeadFunctionElimination and ExternalFunctionDefinitionsElimination into a newly created base class.

Make ExternalFunctionDefinitionsElimination pass eliminate just those external functions which are only reachable via vtables and witness_tables, but leave directly reachable function definitions in place. This gives LLVM more chances to analyze directly reachable functions for side-effects and perform better optimizations based on this. Once we have a proper IPO support for Swift, we can eliminate all external function definitions, including directly reachable ones, as there will be other ways to get information about their side-effects.

Swift SVN r24546
2015-01-20 03:14:45 +00:00
Michael Gottesman
8c5b200239 [inst-count] Move InstCount into frontend_main wrapped in performSILInstCount so that we can gather statistics even if we don't run any SIL optimization passes.
Swift SVN r24490
2015-01-17 02:15:18 +00:00
Michael Gottesman
3d28921607 Add pass ExternalDefsToDecls that changes all available_external functions into declarations.
This is useful to ascertain how much code size comes from available_external functions.

Swift SVN r24471
2015-01-16 03:17:53 +00:00
Arnold Schwaighofer
1e482be681 Add a pass to remove trivial pin/unpin pairs.
This pass removes pin/unpin pairs that are not interleaved by a may-release of
the pin's operand.

This will be needed when we turn on John's work on safe array accessors.

Swift SVN r24434
2015-01-15 00:48:59 +00:00
Roman Levenstein
9f49a1096a [sil-dead-function-elimination] Add a LateDeadFunctionElimination entry point to remove external definitions.
This pass is an extension of the dead function elimination, which additionally performs removal of external function definitions (i.e. function bodies) for a sake of improving the compile times by reducing the amount of code running through IRGen.  It is safe, because such functions are defined elsewhere and where required only for analysis and optimization purposes.

This pass is supposed to run very late in the pipeline, after any passes that may need to look at the function bodies, i.e. after devirtualization, inlining and all specialization passes.

Swift SVN r24417
2015-01-14 18:57:36 +00:00
Adrian Prantl
95eec5a155 Fix Test for: DCE is dropping debug intrinsics, Was: DebugInfo/closure-multivalue test is failing
In order to not completely loose testcoverage while rdar://problem/18709125
is under investiagtion, add a special flag for enabling debug value
liveness.

Patch by Michael Gottesman!

<rdar://problem/19267059>

Swift SVN r24416
2015-01-14 18:37:39 +00:00
Michael Gottesman
1ae4002b6f Add the frontend flag '-external-pass-pipeline-filename'
This flag enables one to specify a json file that expresses a specific
pipeline in the following format:

[
  [
    "$PASS_MANAGER_ID",
    "run_n_times"|"run_to_fixed_point",
    $NUM_ITERATIONS,
    "$PASS1", "$PASS2", ...
  ],
  ...
]

This will make it easier to experiment with different pass pipelines by
allowing:

1. Automatic generation of pass pipelines without needing to recompile
   the compiler itself.
2. Simple scripting of pass pipelines via the json meta language.
3. Enabling the easy expression and reproducability of a specific
   pipeline ordering via radar.

In the next commit I will provide a python library for the generation of these
json files with a few types of pipeline generators already created.

Swift SVN r24055
2014-12-20 04:09:47 +00:00
John McCall
94514d7a22 Fix an annoying spate of build warnings about variadic macro
application.

Swift SVN r24046
2014-12-19 23:57:08 +00:00
Andrew Trick
d84feff62b Add a changeBranchTarget helper.
I refactored, generalized, and cleaned up an existing helper.

I also removed hard-coded assumptions about successor indices.
There's no point giving CondBranch a true/false API if we don't respect it.

Swift SVN r24001
2014-12-18 01:26:45 +00:00
Michael Gottesman
93b92a8f9f Add in Passes.def for metaprogramming with SILPassKinds.
This simplifies some code in SILOpt and SILPasses. The real reason to do it is
to use it to procedurally generate random pipelines.

Swift SVN r23996
2014-12-17 23:56:26 +00:00
Erik Eckstein
31dd17a49f Add array.uninitialized semantics to ArrayCallKind, ArraySemanticsCall and the docs.
For completeness. NFC.



Swift SVN r23955
2014-12-16 13:28:18 +00:00
Andrew Trick
6cc72ee21b Print SIL optimization stages. SIL debugging.
Swift SVN r23902
2014-12-12 23:57:03 +00:00
Arnold Schwaighofer
2f949056d6 SIL utils: Rename array.props.isCocoa to array.props.isNative
The upcoming stdlib patch will also be modified.

NFC

rdar://17955309

Swift SVN r23813
2014-12-09 21:58:16 +00:00
Mark Lacey
9d6e7cddc8 Reapply r23673, which was reverted in r23679.
It had exposed a problem with the MemBehavior on a couple SIL
instructions which resulted in code motion moving a retain across an
instruction that can release (fixed in r23722).

From the original commit message:

    Remove restriction on substituting existentials during mandatory inlining.

    Issues around this have now been resolved, so we should now support
    anything that Sema lets through.

    Fixes rdar://problem/17769717.

Swift SVN r23729
2014-12-05 05:47:42 +00:00