Commit Graph

46 Commits

Author SHA1 Message Date
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
149b50d901 Fix typos in code (non-comment/documentation typos). 2015-12-28 11:42:15 +01:00
practicalswift
6e3b700b44 Fix typos. 2015-12-23 00:31:13 +01:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Xin Tong
0b79ecf51c Rename swift-arc-optimize to swift-llvm-arc-optimize as this is a LLVM pass 2015-11-18 11:53:23 -08:00
Michael Gottesman
9fb54bf4bf Fix for upstream ilist changes. 2015-11-11 16:07:41 -08:00
Michael Gottesman
9ebc0d214b Move the declaration of initializeSwiftARCContractPass and initializeSwiftARCOptPass from {LLVMARCContarct,LLVMARCOpts}.cpp => PassesFwd.h so swift-llvm-opts can use them.
Swift SVN r32807
2015-10-21 21:45:19 +00:00
Michael Gottesman
72f5063f3c Update SwiftAA for upstream AA changes.
Swift SVN r32800
2015-10-21 21:45:13 +00:00
Xin Tong
921a951b63 Fix a compiler crasher with replaceAllUsesWith in LLVMARCOpt.
Swift SVN r32148
2015-09-22 16:20:45 +00:00
Xin Tong
ecc7cc091c Use LLVM RC Identity for LLVMARCOpt Retain/Release code motion.rdar://22774326
Swift SVN r32146
2015-09-22 05:58:07 +00:00
Xin Tong
768a6011de Add retain_n entry points to SwiftAA. rdar://22765670
Swift SVN r32094
2015-09-19 16:37:27 +00:00
Xin Tong
33193ef2d8 Strength reduce unknownRetain to retain.
when an object is passed to unknownRetain and retain, the unknownRetain
can be strength reduced to retain.  same for unknownRelease and release.

Swift SVN r32087
2015-09-18 23:20:20 +00:00
Xin Tong
dca508bfbb This is part of a series of commits to remove reference forwarding for
some of the ARC entry points. rdar://22724641. After this commit,
swift_retain_noresult will be completely replaced by swift_retain.
LLVMARCOpts pass is modified NOT to rewrite swift_retain to
swift_retain_noresult which forward no reference.

Swift SVN r32082
2015-09-18 21:56:50 +00:00
Michael Gottesman
121ef3ef9f Revert the series of commits for removing the return value from swift_retain_noresult.
I asked that the patches were split up so I could do post commit review.

This reverts commit r32059.
This reverts commit r32058.
This reverts commit r32056.
This reverts commit r32055.

Swift SVN r32060
2015-09-18 02:31:24 +00:00
Xin Tong
4e46dacc3d Completely replace swift_retain_noresult with swift_retain. this is part of a series of commits
to remove reference forwarding for some of the ARC entry points. rdar://22724641. After this
commit, swift_retain_noresult will be completely replaced by swift_retain and LLVMARCOpts.cpp
will no longer canonicalize swift_retain to swift_retain_noresult as now swift_retain returns no
reference.

Swift SVN r32058
2015-09-18 01:51:17 +00:00
Michael Gottesman
0db8d77e4c Refactor LLVMARCContract => LLVMARCContract.cpp.
Swift SVN r30393
2015-07-20 06:34:55 +00:00
Michael Gottesman
3ddaf105b0 Refactor ARCEntryPointBuilder => ARCEntryPointBuilder.h
Swift SVN r30392
2015-07-20 06:34:54 +00:00
Erik Eckstein
57c5de4491 [llvm-arc-opts] Optimize strong_retain_unowned/strong_release pairs.
Replaces a swift_retainUnowned/swift_release pair with a swift_checkUnowned, if possible.
For details see rdar://problem/21297936




Swift SVN r30262
2015-07-16 13:46:18 +00:00
Michael Gottesman
672d32ef02 [llvm-arc-opts] Merge together multiple retains/releases in the same BB into retain_n/release_n calls.
We are taking advantage of the fact that we can always safely move a retain
earlier in the program and a release later in the program. Given this
information, in every BB, we merge together all retains into the first retain
(creating a retain_n) and all releases into the last release in that BB
(creating a release_n).

rdar://21803771

Swift SVN r30261
2015-07-16 12:28:29 +00:00
Michael Gottesman
123dbc6912 [llvm-arc-opts] Extract out single BB analysis/opts into its own method. To shrink the size of SwiftARCContractImpl::run.
Swift SVN r30260
2015-07-16 12:28:28 +00:00
Michael Gottesman
cd0e84acb7 [llvm-arc-opts] Extract out the implementation of SwiftARCContract into SwiftARCContractImpl so we can store global information more conveniently without polluting the public header where the actual LLVM pass is declared.
Swift SVN r30259
2015-07-16 12:28:27 +00:00
Michael Gottesman
3c86d000e4 Small style fixes. NFC.
Swift SVN r30258
2015-07-16 12:28:26 +00:00
Michael Gottesman
89ce119646 Add support to ARCEntryPointBuilder for emitting RetainN and ReleaseN calls.
Swift SVN r30257
2015-07-16 12:28:25 +00:00
Michael Gottesman
2315c8fd06 [llvm-arc-opts] Rename SwiftARCExpand => SwiftARCContract.
This pass does things similar to LLVMARCContract so it makes sense to use the
same naming schema.

Also I am going to be implementing some contracting optimziations here later
today.

Swift SVN r30203
2015-07-15 00:03:01 +00:00
Michael Gottesman
04890c964e [llvm-arc-opts] Remove retainAndReturnThree.
We were never generating it and are going to transition all of the stdlib data
structures to single pointer representations.

rdar://21665665

Swift SVN r30174
2015-07-13 23:10:12 +00:00
Michael Gottesman
24c9c75df0 [llvm-arc-opts] Refactor the ARC call constant caches and ARC call creation code into a builder class.
This removes a bunch of boilerplate from the LLVMARCOpts passes related
to Constant caches and creating these calls.

Swift SVN r30130
2015-07-12 22:13:10 +00:00
Dmitri Hrybenko
7c290477bc ARC optimizer: disable one optimization
ARC optimizer inserts calls to swift_retainAndReturnThree, which does
not exist.

rdar://21665665

Swift SVN r29907
2015-07-03 04:38:29 +00:00
Dmitri Hrybenko
2fc1cbe8c1 Adjust to the new IRBuilder APIs
Swift SVN r29692
2015-06-25 22:01:24 +00:00
Adrian Prantl
f68161e66c Have LLVMArcOpts preserve the debug locations when lowering calls to
retain and release operations.

rdar://problem/21028676

Swift SVN r29550
2015-06-22 18:50:51 +00:00
Dmitri Hrybenko
85975d3529 Update for upstream LLVM change
Swift SVN r25040
2015-02-06 19:09:05 +00:00
Arnold Schwaighofer
75645e22a6 LLVMARCOpts: Retain motion can ignore loads
rdar://19060610

Swift SVN r23530
2014-11-21 20:06:33 +00:00
Arnold Schwaighofer
f71006fbf1 LLVMARCOpts: Properly handle swift_bridgeObjectRetain/Release
We did not use the right name for the function and were not attempting to move
them.

rdar://19060663

Swift SVN r23529
2014-11-21 20:06:31 +00:00
Michael Gottesman
002598fae0 [llvm-arc-opts] swift_unknownRetain returns a value. Make sure to propagate the result before deleting it.
Thanks for finding this Greg!

Swift SVN r23043
2014-10-31 22:59:21 +00:00
Michael Gottesman
ad2c4afaec [llvm-arc-opts] Remove swift_unknown{Retain,Release}(null).
rdar://18832539

Swift SVN r23028
2014-10-31 04:40:35 +00:00
Michael Gottesman
037dfd7311 [llvm-arc-opts] Give a better flag name to be clear which arc opts one is disabling by passing in this flag.
Swift SVN r23013
2014-10-29 22:46:09 +00:00
Michael Gottesman
ee5751d102 [llvm-arc-opts] Add a flag to turn off llvm arc opts so I can see how far we are from eliminating it.
Swift SVN r23012
2014-10-29 22:29:25 +00:00
Michael Gottesman
56f7797609 Remove trailing whitespace. NFC.
Swift SVN r22884
2014-10-23 02:37:19 +00:00
Joe Groff
5a2f48e3be Add a Builtin.BridgeObject type.
This is a type that has ownership of a reference while allowing access to the
spare bits inside the pointer, but which can also safely hold an ObjC tagged pointer
reference (with no spare bits of course). It additionally blesses one
Foundation-coordinated bit with the meaning of "has swift refcounting" in order
to get a faster short-circuit to native refcounting. It supports the following
builtin operations:

- Builtin.castToBridgeObject<T>(ref: T, bits: Builtin.Word) ->
  Builtin.BridgeObject

  Creates a BridgeObject that contains the bitwise-OR of the bit patterns of
  "ref" and "bits". It is the user's responsibility to ensure "bits" doesn't
  interfere with the reference identity of the resulting value. In other words,
  it is undefined behavior unless:

    castReferenceFromBridgeObject(castToBridgeObject(ref, bits)) === ref

  This means "bits" must be zero if "ref" is a tagged pointer. If "ref" is a real
  object pointer, "bits" must not have any non-spare bits set (unless they're
  already set in the pointer value). The native discriminator bit may only be set
  if the object is Swift-refcounted.

- Builtin.castReferenceFromBridgeObject<T>(bo: Builtin.BridgeObject) -> T

  Extracts the reference from a BridgeObject.

- Builtin.castBitPatternFromBridgeObject(bo: Builtin.BridgeObject) -> Builtin.Word

  Presents the bit pattern of a BridgeObject as a Word.

BridgeObject's bits are set up as follows on the various platforms:

i386, armv7:

  No ObjC tagged pointers
  Swift native refcounting flag bit: 0x0000_0001
  Other available spare bits:        0x0000_0002

x86_64:

  Reserved for ObjC tagged pointers: 0x8000_0000_0000_0001
  Swift native refcounting flag bit: 0x0000_0000_0000_0002
  Other available spare bits:        0x7F00_0000_0000_0004

arm64:

  Reserved for ObjC tagged pointers: 0x8000_0000_0000_0000
  Swift native refcounting flag bit: 0x4000_0000_0000_0000
  Other available spare bits:        0x3F00_0000_0000_0007

TODO: BridgeObject doesn't present any extra inhabitants. It ought to at least provide null as an extra inhabitant for Optional.

Swift SVN r22880
2014-10-23 00:09:23 +00:00
Michael Gottesman
a623886d6c Teach the LLVM level ARC optimizer about swift_fixLifetime.
This includes:

1. Teaching SwiftAA that swift_fixLifetime does not affect loads, stores of pointers.
2. Teaching SwiftARCExpand to remove swift_fixLifetime.
3. Teaching SwiftARCOpts that it can move retains but not releases over
swift_fixLifetime.

At -O I get the following % speedups > 10%.

InsertionSort:|%29.73
ImageProc:|||||%23.97
RC4:|||||||||||%19.46
PrimeNum|||||||%18.10
Ary||||||||||||%14.09
Ary2|||||||||||%13.16

<rdar://problem/18685662>

Swift SVN r22814
2014-10-17 08:29:29 +00:00
Michael Gottesman
7b599597ca Move createSwiftAliasAnalysisPass from LLVMARCOpts.cpp => LLVMSwiftAA.cpp
Swift SVN r22813
2014-10-17 08:29:28 +00:00
Justin Bogner
5cac4f4d25 LLVMPasses: Replace some assert(0)'s with llvm_unreachable
These would fall through in a no-asserts build.

Swift SVN r22810
2014-10-17 05:18:39 +00:00
Arnold Schwaighofer
d55ba9959d LLVMARC: Don't bail on obj_retain/release or unknown_retain/release
We can remove objc_retain/releases just like swift ones.

Results -O where SU = minbefore/minafter (10 samples):

TEST`````````````````MIN``MAX``MEAN`SD```MED``MIN``MAX``MEAN`SD```MED````SU
ClassArrayGetter`````1931`1943`1938`4````1940`1143`1158`1150`5````1153```1.68
DeltaBlue````````````3434`3450`3439`4````3441`2906`2932`2913`7````2911```1.18
Dictionary```````````5616`5933`5755`112``5748`5291`5713`5515`140``5563```1.06
PopFrontArray````````103``109``104``1````104``96```99```96```1````96`````1.07
PopFrontArrayGeneric`102``106``103``1````103``95```98```96```1````96`````1.07
PrimeNum`````````````4098`7552`5953`1164`6319`4496`8653`6336`1210`6639```0.91
QuickSort````````````6380`6415`6396`11```6398`6071`6115`6086`13```6082```1.05
Rectangles```````````2277`2377`2322`31```2320`1636`1682`1657`12```1655```1.39
StrCat```````````````2811`2849`2825`12```2822`2487`2516`2501`12```2505```1.13
StringWalk```````````5784`5797`5790`4````5790`6124`6137`6129`4````6127```0.94

Swift SVN r22695
2014-10-12 22:57:21 +00:00
Arnold Schwaighofer
1ee1b40dae LLVMARCOpts: We can move retains across an objc_retain.
Teach LLVMARCOpts about swift_unknownRetain and that we can move retains accross
objc_retains.

This recovers the performance we lost (see rdar below) due to making retain
sinking more aggressive.

ClassArrayGetter```````,``581.00````,``488.00````,``92.00```,````````18.9%
Rectangles`````````````,``618.00````,``552.00````,``71.00```,````````13.0%

rdar://18337069

Swift SVN r21999
2014-09-16 23:51:27 +00:00
Michael Gottesman
1f9e654def Split lib/LLVMPasses/Passes.cpp into LLVMARCOpts.cpp and LLVMSwiftAA.cpp.
Swift SVN r21655
2014-09-02 21:14:21 +00:00