Commit Graph

11224 Commits

Author SHA1 Message Date
Arnold Schwaighofer
4b2fb9ebb4 Fix Definite initialization
The code assumed it is safe to get the element type of a compound type and get a
legal SIL type back. This is not the case.

rdar://24450119
2016-02-12 16:50:17 -08:00
Xin Tong
40ff0895d6 Improve epilogue release matcher to handle exploded release_value.
So instead of only being able to match %1 and release %1 in (1). we
can also match %1 with (release %2, and release%3, i.e. exploded release_value)
in (2).

(1)
foo(%1)
  strong_release %1

(2)
foo(%1)
  %2 = struct_extract %1, field_a
  %3 = struct_extract %1, field_b
  strong_release %2
  strong_release %3

This will allow function signature to better move the release instructions to
the callers.

Currently, this is a NFC other than testing using the epilogue match dumper.
2016-02-12 15:22:13 -08:00
Xin Tong
d1c75976c9 Add a epilogue release dumper. This pass tests/prints what epilogue releases for
function arguments are found and dump them.

This is important as we are trying to improve EpilogueReleaseMatcher.
2016-02-12 10:40:55 -08:00
Daniel Duan
efe230774b [AST] rename some isXXX methods to getAsXXX
There's a group of methods in `DeclContext` with names that start with *is*,
such as `isClassOrClassExtensionContext()`. These names suggests a boolean
return value, while the methods actually return a type declaration. This
patch replaces the *is* prefix with *getAs* to better reflect their interface.
2016-02-11 16:23:40 -08:00
Slava Pestov
5c97b21598 Merge pull request #1253 from dduan/delete_typelowering_dead_code
early exit in TypeLowering for address-only type
2016-02-10 19:20:12 -08:00
Daniel Duan
c5f9fc170c remove (now unused) TypeLowering::isValid() 2016-02-10 16:15:40 -08:00
Xin Tong
e2c0990851 Rename hasNoUsesExceptDebug to onlyHaveDebugUses. The double negation logic is
harder to understand. NFC.
2016-02-10 14:46:09 -08:00
Erik Eckstein
0747505472 SimplifyCFG: fix a crash in checked_cast_br jump threading
I introduced this bug recently in my change to reduce compile-time.
2016-02-10 12:14:23 -08:00
Xin Tong
79c1f38724 Remove 1/5 iterations of redundant load elim. I do not see performance
regression. but do see a compilation time improvement
2016-02-09 22:20:10 -08:00
Xin Tong
84a6ff1d98 And lastly rename NewProjection to Projection. This is a NFC. rdar://24520269 2016-02-09 22:20:10 -08:00
Xin Tong
8775d8b2da Migrate LSLocation printer pass to new projection. This should be NFC 2016-02-09 22:20:09 -08:00
Xin Tong
d9671f5b0e Migrate SILCombiner to new projection. This should be a NFC 2016-02-09 22:20:09 -08:00
Xin Tong
6fb741bbca Migrate dead object elimination to new projection. This should be a NFC 2016-02-09 22:20:09 -08:00
Xin Tong
111af0322f Using ProjectionTree to create NewProjectionTree and wire NewProjectionTree up
with function signature optimizations to make sure it passes some basic testing.

We are one step closer to get rid of the old projection.
2016-02-09 22:20:09 -08:00
Erik Eckstein
7971621f8b Inliner: reduce and improve debug output. NFC. 2016-02-09 10:32:19 -08:00
Mark Lacey
891ab087be Remove unnecessary call to invalidate dominator info.
We don't use this information after this point and are already
invalidating this (and everything else for this function body) at the
end of the pass, so this is not necessary.

NFC.
2016-02-08 15:34:15 -08:00
Mark Lacey
e301d41686 Remove tracking of previously inlined functions in the inliner.
Prior to splitting devirtualization out of inlining we needed this to
ensure that we would not go into an infinite loop in certain cases.

Now that these are split out and we no longer iterate within the inliner
over new opportunities, we only need to check for self-recursive
functions.

NFC.
2016-02-08 15:34:15 -08:00
Xin Tong
7808fb3034 Make dead function elim respect optimize.sil.never. Its possible these functions
can be called from something external of the program, e.g. debugger
2016-02-08 13:35:23 -08:00
Slava Pestov
6a254042ee SILOptimizer: Functions referenced from sil_default_witness_table are alive 2016-02-08 00:05:57 -08:00
Xin Tong
92b16cde75 Remove unncessary headers 2016-02-07 13:56:12 -08:00
Xin Tong
d5dfe57e14 Migrate to use new projection for COWArrayOpt. This should be a NFC.
This is part of rdar://24520269
2016-02-07 13:56:12 -08:00
Xin Tong
17e3f35758 Migrate to use new projection for PerformanceInliner. This should be a NFC.
This is part of rdar://24520269
2016-02-07 13:56:12 -08:00
practicalswift
55ccd3e961 [gardening] Fix recently introduced typo: "initiailize" → "initialize" 2016-02-07 10:34:32 +01:00
practicalswift
afd89f5751 [gardening] Fix recently introduced typo: "initiailize" → "initialize" 2016-02-07 10:34:22 +01:00
Xin Tong
0258e8e816 Migrate to use new projection for SimplifyCFG. This should be a NFC.
This is part of rdar://24520269
2016-02-06 08:27:05 -08:00
Xin Tong
338a2d0af5 Migrate to use new projection for SILmem2reg. This should be a NFC.
This is part of rdar://24520269
2016-02-05 23:16:35 -08:00
Xin Tong
8318b83016 Remove unnecessary header. NFC 2016-02-05 22:49:24 -08:00
Xin Tong
3391140ed1 Remove unnecessary header. NFC. 2016-02-05 22:43:29 -08:00
Xin Tong
4837889e63 Reapply Add a dead function elimination pass before we run SIL highlevel optimizations
I see improvement in compiling stdlib -O.

=== Before adding the pass ===
real time: 1m3.472s

=== After adding the pass ===
real time: 1m1.793s
2016-02-05 22:19:02 -08:00
Slava Pestov
f2157c93d1 Revert "Add a dead function elimination pass before we run SIL highlevel optimizations."
This reverts commit 909c3b28c4 because it
broke SILOptimizer/sil_witness_tables_external_witnesstable.swift.
2016-02-05 20:57:11 -08:00
Xin Tong
909c3b28c4 Add a dead function elimination pass before we run SIL highlevel optimizations.
I see slight compilation time improvements.
2016-02-05 20:22:35 -08:00
Adrian Prantl
b6a7d6906a Debug Info: Fix the lowering of the SILDebugScope tree to the LLVM
inlined-at chain.

The previous implementation was only correct for cases where the inliner
inlined bottom-up in the call graph, which happened to cover the majority
of all cases.

rdar://problem/24462475
2016-02-05 13:53:34 -08:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Erik Eckstein
529b386701 SILCombine: allow promotion of init_existentials over control flow + a small bug fix
This allows devirtualization of witness method calls if the initialization of the existential is not in the same basic block.
This change also fixes a bug where promotion is done even if the stack is overwritten after initialization. Although I'm not sure if this kind of code is ever generated.
2016-02-04 10:59:56 -08:00
Xin Tong
ae86ef2b72 Implement more conservative debugging value support on function arguments in
function signature opt.

Instead of replacing %1 with UNDEF in debugvalueinst %1, we form an aggregate,
taking the alive part of %1 and fill the dead part with undef.

rdar://23727705
2016-02-04 10:50:26 -08:00
Mark Lacey
82fd057eaf Remove devirtualization and specialization from the inliner.
Now that we process functions in bottom-up order in the pass manager and
have a mechanism to restart the pass pipeline on the current
function (or on a newly created callee function), we can split these
passes back out from the inliner and end up with the same benefits we
had from initially integrating them. We get the further benefit of fully
optimizing newly created callee functions before continuing with the
function that resulted in the creation of those callee
functions (e.g. as a result of a specialization pass running).
2016-02-04 08:52:01 -08:00
Arnold Schwaighofer
755bfe3185 Revert "Split the method isProfitableToInline."
This reverts commit 670f193e4a.

It has broken a build bot.
2016-02-03 18:10:17 -08:00
Nadav Rotem
670f193e4a Split the method isProfitableToInline.
This commit refactors the parts of isProfitableToInline that compute the cost
and benefit of inlining into a separate function. NFC.
2016-02-03 16:24:06 -08:00
Adrian Prantl
0854b3ce6d SILDebugScope: Add accessors for the parent SIL functions and use them in
assertions. (NFC)
2016-02-03 14:48:06 -08:00
Jordan Rose
923b9a6201 Don't emit any check for #available of another platform.
Previously we treated the * platform as checking for the minimum
deployment target, but that's definitely unnecessary.

There is a bit of a hack here to avoid diagnosing the 'else' branch as
unreachable: if a constant true/false came from #available, ignore it.
2016-02-03 14:27:13 -08:00
Nadav Rotem
6d92a15b29 Sink the loop depth calculation into the IF that uses it. NFC. 2016-02-03 14:11:33 -08:00
Nadav Rotem
1c29dc49ae Remove whitespace. NFC.
I am doing this commit to test the internal infrastructure.
2016-02-03 13:44:50 -08:00
Mark Lacey
a97164656f Disallow inlining of self-recursive functions into other functions.
This effectively returns us to the code from dc65f70.

With the recent pass manager changes, combined with upcoming inliner
changes, we can potentially run the inliner more than we currently
do. Allowing self-recursive functions to be inlined, and running the
inliner more often, can result in a lot of code bloat, which increases
binary sizes and compile times. Even with a relatively small value (10)
for the number of times we allow a function to run through the pass
pipeline, we end up with a significant increase in the stdlib and
stdlib unit test build times.

This results in some performance regressions, but I think the trade-off
here is reasonable.
2016-02-02 20:19:39 -08:00
Erik Eckstein
8520120121 SimplifyCFG: don't recalculate the dominator tree for each jump threaded checked_cast_br instruction.
This is done by splitting the transformation into an analysis phase and a transformation phase (which does not use the dominator tree anymore).
The domintator tree is recalucated once after the whole function is processed.

This change eventually solves the compile time problem of rdar://problem/24410167.
2016-02-02 17:46:32 -08:00
Erik Eckstein
6e00d8a9e1 add asserts in replaceBranchTarget() and use casts instead of dyn_casts 2016-02-02 17:46:32 -08:00
Mark Lacey
378e94b901 Formatting changes on recently added lines. 2016-02-01 21:50:01 -08:00
Arnold Schwaighofer
ac423ebe97 A generic class can inherit from objc and so the devirtualizer needs to emit a default case
rdar://23228386
2016-02-01 20:33:40 -08:00
Arnold Schwaighofer
f6866b4ae7 Perform a dynamic method call if a class has objc ancestry in speculative devirt as fallback.
If a class has an @objc ancestry this class can be dynamically overridden and
therefore we don't know the default case even if we see the full class
hierarchy.

rdar://23228386
2016-02-01 18:16:37 -08:00
Mark Lacey
beb0f7dc2f Update pass manager execution strategy for function passes.
Allow function passes to:

1. Add new functions, to be optimized before continuing with the current
   function.
2. Restart the pipeline on the current function after the current pass
   completes.

This makes it possible to fully optimize callees that are the result of
specialization prior to generating interprocedural information or making
inlining choices about these callees.

It also allows us to solve a phase-ordering issue we have with generic
specialization, devirtualization, and inlining, by rescheduling the
current function after changes happen in one of these passes as opposed
to running all of these as part of the inlining pass as happens today.

Currently this is NFC since we have no passes that use this
functionality.
2016-02-01 16:47:26 -08:00
Dmitri Gribenko
1f6fe29e49 Merge pull request #1155 from practicalswift/typo-fixes-20160201
[gardening] Fix typos: "specalized" → "specialized", "uniqueing" → "uniquing"
2016-02-01 14:57:18 -08:00