Commit Graph

11193 Commits

Author SHA1 Message Date
Arnold Schwaighofer
2f81e4eaf8 CopyForwarding: We need to check whether an argument is a function argument before checking its convention 2016-02-17 14:38:44 -08:00
Erik Eckstein
fd566d92bd EscapeAnalysis: fix a problem where a inconsistent connection graph can be generated.
rdar://problem/24686791
2016-02-17 13:27:31 -08:00
practicalswift
7f8052d289 [gardening] Fix incorrect file name in file header 2016-02-17 10:24:25 +01:00
Xin Tong
b156824f3b Rename EpilogueReleaseMatcherDumper.cpp.
Rename to EpilogueRetainReleaseMatcherDumper.cpp to better reflect
what it does now.
2016-02-16 22:29:32 -08:00
Xin Tong
a007d47dd4 Add a simple epilogue retain matcher.
This is similar and yet different from epilogue release matcher. Particularly
how retain is found and when to bail. Therefore this is put into a different
class than ConsumedArgToEpilogueReleaseMatcher

This is currently a NFC other than some basic testing using the epilogue dumper.
2016-02-16 22:27:40 -08:00
practicalswift
12012b1a15 [gardening] Fix recently introduced typo: "idenity" → "identity" 2016-02-16 22:20:48 +01:00
Xin Tong
81cc962c54 Create a fast path for release silargument.
When we have a single release that can be traced back to a SILArgument.
i.e. the released value is RC-identical to the SILArgument. we do not
need projection to check whether there are overlapping/uncovered releases
for the SILargument (which will result we exit the epilogue walking sequnece).

This brings the # of Total owned args -> guaranteed args from 118 and 149.

There are 23 owned args which we can not find epilogue releases for at this
point and many (if not most) is a result of partial_apply which rc-identity
nor projection can handle.

with this commit i see differences only in 2 benchmarks. baseline is without this
change. I am looking at the SuperChars regression.

StrToInt                              9297             8402      -895     -9.6%     1.11x
SuperChars                          676554           748375    +71821    +10.6%     0.90x (!)
2016-02-16 09:59:48 -08:00
Michael Gottesman
e93af4c119 Merge pull request #1321 from gottesmm/immutable_pointer_set_feedback
Immutable Pointer Set Fixes
2016-02-16 09:45:17 -08:00
Michael Gottesman
90dcaa7de3 Rename ImmutablePointerSet::concat => ImmutablePointerSet::merge. 2016-02-16 02:13:56 -08:00
Xin Tong
670df6dc9d Wire up improved epilogue release matcher with function signature
optimization.

We get some improvements on the # of parameters converted to guanrateed
from owned on the stdlib.

before
======
103 sil-function-signature-opts      - Total owned args -> guaranteed args

after
======
118 sil-function-signature-opts      - Total owned args -> guaranteed args

I see the following improvements by running benchmarks with and without this
change. Only difference >=1.05X

ErrorHandling         8154             7497      -657     -8.1%     1.09x
LinkedList            9973             9529      -444     -4.5%     1.05x
ObjectAllocation      239              222       -17     -7.1%     1.08x
RC4                   23167            21993     -1174     -5.1%     1.05x (!)

This is part of rdar://22380547
2016-02-15 16:10:40 -08:00
Xin Tong
99ca08e4af Check whether epilogue releases cover all non-trivial fields.
When we have all the epilogue releases. Make sure they cover all the non-trivial
parts of the base. Otherwise, treat as if we've found no releases for the base.

Currently. this is a NFC other than epilogue dumper. I will wire it up with
function signature with next commit.

This is part of rdar://22380547
2016-02-15 16:00:02 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
practicalswift
109eb8063f [gardening] Fix recently introduced typo: "thats" → "that is" 2016-02-15 20:46:44 +01:00
Xin Tong
4f66bc88b4 Move ProjectionTree::isRedundantRelease to ConsumedArgToEpilogueReleaseMatcher::isRedundantRelease.
NFC.
2016-02-15 10:22:47 -08:00
practicalswift
2f547e9356 [gardening] Use consistent header structure in newly introduced files 2016-02-15 16:47:48 +01:00
Michael Gottesman
f718111a4f [arc] Integrate ImmutablePointerSet{,Factory} into ARC Sequence Opts.
This speeds and reduces memory consumption of test cases with large
CFGs. The specific test case that spawned this fix was a large function
with many dictionary assignments:

public func func_0(dictIn : [String : MyClass]) -> [String : MyClass] {
  var dictOut : [String : MyClass] = [:]
  dictOut["key5000"] = dictIn["key500"]
  dictOut["key5010"] = dictIn["key501"]
  dictOut["key5020"] = dictIn["key502"]
  dictOut["key5030"] = dictIn["key503"]
  dictOut["key5040"] = dictIn["key504"]
  ...
}

This continued for 10k - 20k values.

This commit reduces the compile time by 2.5x and reduces the amount of
memory allocated by ARC by 2.6x (the memory allocation number includes
memory that is subsequently freed).

rdar://24350646
2016-02-14 15:26:59 -08:00
Michael Gottesman
79de928006 [arc] Only visit instructions that are actually interesting from the perspective of ARC when performing the dataflow.
This will improve ARC compile time performance.

rdar://24350646
2016-02-14 14:56:13 -08:00
Michael Gottesman
02609c0209 [arc] Remove CodeMotionOrDeleteCallback.
Now that the pairing and the actual pass are together I can remove this. It is no longer needed.
2016-02-14 14:56:13 -08:00
Michael Gottesman
e152746277 [arc] Split GlobalARCPairingAnalysis into the matching set builder part and the
top level driver . Move the top level driver of the pairing analysis into
ARCSequenceOpts and have ARCSequenceOpts use ARCMatchingSetBuilder directly.

This patch is the first in a series of patches that improve ARC compile
time performance by ensuring that ARC only visits the full CFG at most
one time.

Previously when ARC was split into an analysis and a pass, the split in
the codebase occurred at the boundary in between ARCSequenceOpts and
ARCPairingAnalysis. I used a callback to allow ARCSequenceOpts to inject
code into ARCPairingAnalysis.

Now that the analysis has been moved together with the pass this
unnecessarily complicates the code. More importantly though it creates
obstacles towards reducing compile time by visiting the CFG only once.

Specifically, we need to visit the full cfg once to gather interesting
instructions. Then when performing the actual dataflow analysis, we only
visit the interesting instructions. This causes an interesting problem
since retains/releases can have dependencies on each other implying that
I need to be able to update where various "interesting instructions" are
located after ARC moves it. The "interesting instruction" information is
stored at the pairing analysis level, but the moving/removal of
instructions is injected in via the callback.

By moving the top level driver part of ARCPairingAnalysis into
ARCSequenceOpts, we simplify the code by eliminating the dependency
injection callback and also make it easier to manage the cached CFG
state in the face of the ARC optimizer moving/removing retains/releases.
2016-02-14 14:56:13 -08:00
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