Commit Graph

68 Commits

Author SHA1 Message Date
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