Commit Graph

49 Commits

Author SHA1 Message Date
Erik Eckstein
f18c8431fd SIL: remove unneeded includes 2016-01-25 15:00:49 -08:00
Erik Eckstein
b745691a38 SIL refactoring: Move some functions out of SILValue and Operand
SILValue.h/.cpp just defines the SIL base classes. Referring to specific instructions is a (small) kind of layering violation.
Also I want to keep SILValue small so that it is really just a type alias of ValueBase*.
NFC.
2016-01-25 10:37:03 -08:00
Erik Eckstein
ec172cde5b Remove SILValue::replaceAllUsesWith.
It's not needed anymore because we can use ValueBase::replaceAllUses
2016-01-21 16:04:30 -08:00
Erik Eckstein
25e52a0ba0 treat project_box as projection in SILValue and SideEffectAnalysis 2016-01-15 12:35:29 -08:00
Michael Gottesman
2f3709443d [rc-id] Make RCIdentity strip off single-pred arguments.
In a bunch of use-cases we use stripSinglePredecessorArgs to eliminate this
case. There is no reason to assume that this is being done in the caller of
RCIdentity. Lets make sure that we handle this case here.

rdar://24156136
2016-01-14 18:19:54 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
practicalswift
ff03d6faff Fix typo: arugment → argument 2015-12-14 00:11:14 +01:00
Ted Kremenek
2dca3963a9 Merge pull request #7 from aschwaighofer/hoist_addr_proj_bug
Fix a bug in SILValue's hoistAddressProjections
2015-11-20 15:36:53 -08:00
Ted Kremenek
3e779dbc66 Revert "Revert "Safely implement strict TBAA rules.""
We believe the failure now may be in the setup of the test harness.
Re-applying this change, since the tests passed in our other
configurations.
2015-11-20 15:08:58 -08:00
Ted Kremenek
ddc9c52d5a Revert "Safely implement strict TBAA rules."
This reverts commit 3d5c4969a0.

This is breaking the iOS device tests.
2015-11-20 14:51:25 -08:00
Andrew Trick
3d5c4969a0 Safely implement strict TBAA rules.
This fixes type punning issues with unsafeBitCast.

The optimizer is still too aggressive with UnsafePointer. To fix that,
we first need an explicit API for circumventing type safety
(rdar://23406272).

I should be able to fix the following regressions by migrating the
stdlib away from unsafeBitCast to unsafeReferenceCast (~2 weeks).

Slowdowns:
|.Benchmark.................|..Before.|...After.|.Speedup|
|.ArrayInClass..............|...49.00.|...78.00.|.-37.2%.|
|.Sim2DArray................|..471.00.|..549.00.|.-14.2%.|
|.PrimeNum..................|.1876.00.|.1980.00.|..-5.3%.|

Speedups:
|.Benchmark.................|..Before.|...After.|.Speedup|
|.HeapSort..................|.2962.00.|.2663.00.|..11.2%.|
|.StdlibSort................|.2672.00.|.2537.00.|...5.3%.|
2015-11-20 09:59:56 -08:00
Arnold Schwaighofer
95f43bccad Fix a bug in SILValue's hoistAddressProjections
We have to insert instructions that are operands *before* the instruction using
them as an operand.

Also fix a bug in the same code when looking through single predecessor basic
block arguments.

Add a testcase for all three cases.

rdar://23159379
2015-11-20 07:47:33 -08:00
Andrew Trick
2318be324f UncheckedAddrCast does not preserve RC identity.
UncheckedRefCastAddr does.

This cleans up the white-list used by ARC
optimization to be a bit more conservative.

I wasn't able to observe a change in behavior.
2015-11-12 10:41:19 -08:00
Andrew Trick
c20370a664 Remove the last remnants of unchecked_ref_bit_cast
Swift SVN r32598
2015-10-10 05:42:57 +00:00
Michael Gottesman
74a984de6b Rename SILValue::stripAggregateProjections => SILValue::stripValueProjections.
This matches the terminology used in Projection. NFC.

Swift SVN r31418
2015-08-23 04:27:24 +00:00
Arnold Schwaighofer
0c6363a399 SILValue: Add an api to strip expect intrinsics
Swift SVN r27838
2015-04-27 23:43:41 +00:00
Michael Gottesman
52a332b2bd Specify that the static_asserts I inserted in the past couple of comments are
meant to ensure behavior does not change by mistake, but are open to be changed
if one wishes to modify them on purpose.



Swift SVN r26531
2015-03-25 06:46:53 +00:00
Michael Gottesman
3ec2d151f6 Shrink Projection to 24 bytes and Add some static assertions to make sure that SILValue and Projection stay the same size and standard layout.
Swift SVN r26526
2015-03-25 06:21:08 +00:00
Mark Lacey
fbc7b76614 Be more conservative about stripping upcasts in devirtualization.
This fixes two issues that I ran into with the devirtualizer and also
paves the path to more simplification of the devirtualizer code.

Both issues are due to having a very liberal definition of what can be
considered an upcast.

In one case, we tunnel through an unchecked_ref_cast and then fail to
devirtualize because the source type is not a class
type (rdar://problem/20115523). We would be better off sticking to the
class type we started with.

In the other case, we tunnel through an unchecked_ref_bit_cast and this
results in an attempt to insert a checked_cast_br between unrelated
types (rdar://problem/20117782).

Swift SVN r25976
2015-03-11 08:25:51 +00:00
Arnold Schwaighofer
a95eefb934 Add a utility function to Operand to hoist projections rooted in an operand to
an earlier point.

Swift SVN r25618
2015-02-27 22:07:38 +00:00
Erik Eckstein
c2702fbf8b Fix <rdar://problem/19069205> Stack overflow in SIL alias analysis
The problem was that SILValue::stripAddressProjections() was out of sync with Projection::isAddrProjection().



Swift SVN r23806
2014-12-09 11:16:16 +00:00
Roman Levenstein
ab7b1c26ca Move stripClassCasts into SILValue. NFC.
Swift SVN r23539
2014-11-21 22:21:52 +00:00
Arnold Schwaighofer
08015deced RefToBridgeObjectInst and BridgeObjectToRefInst are rc identity preserving
rdar://19006443

Swift SVN r23411
2014-11-18 21:23:07 +00:00
Arnold Schwaighofer
0b12dd19e3 These casts are not rc identity preserving we can't strip them
rdar://18668900

Swift SVN r22804
2014-10-16 23:44:13 +00:00
Roman Levenstein
ed22906964 Add helper methods to strip upcasts. This is required for upcoming devirtualizer patches.
Swift SVN r22602
2014-10-08 13:09:05 +00:00
Arnold Schwaighofer
36ad6d2faa ValueBase: Add getParentBB api
Swift SVN r21925
2014-09-12 21:05:21 +00:00
Michael Gottesman
4609513593 Remove SILValue::stripRCIdentityPreservingArgs and teach all uses of that method to use the new RCIdentityAnalysis.
Currently, the pass just calls a local version of that function. After OzU, I
will enable the full pass (which is currently disabled behind a flag).

Swift SVN r21894
2014-09-11 22:29:31 +00:00
Michael Gottesman
4647eb9601 Create RCIdentityAnalysis a cache for stripRCIdentityPreservingOps.
The cache is needed to ensure we do not run into compile time problems once we
start looking through Phi Nodes.

The analysis is currently disabled and just returns
SILValue::stripRCIdentityPreservingOps. I am going to thread it through the rest
of the passes that use that call. Then I am going to hide
stripRCIdentityPreservingArgs. Finally post OzU, I am going to enable the pass.

rdar://18300069

Swift SVN r21891
2014-09-11 21:51:29 +00:00
Michael Gottesman
875fa02f98 Hide SILValue::stripSinglePredecessor{Args,RCIdentityPreservingArgs}.
These really should never have been exposed since they are internals to
SILValue.

Swift SVN r21868
2014-09-11 05:44:58 +00:00
Michael Gottesman
2b4d7f72a2 [g-arc-opts] Look through enum literal instructions.
The enum literal instruction has the same reference identity as its payload if
it has a payload.

<rdar://problem/18195085>

Swift SVN r21644
2014-09-02 16:03:11 +00:00
Michael Gottesman
ec7cc211cb [g-arc-opts] A struct_extract of the only non-trivial stored field of a struct is always a ref count identity preserving identity.
rdar://18189325

Swift SVN r21614
2014-08-31 18:08:30 +00:00
Michael Gottesman
fb04e9082b [g-arc-opts] unchecked_enum_data is always a ref count identity preserving operation, always strip them off.
Originally I was using the notion of layout compatible to define the notion of a
ref count identity preserving operation. This is too restrictive of a definition
since layout compatible implies that the operation does not change the memory
location being pointed at. On the other hand, we just care that the ref counts
are the same.

rdar://18189329

Swift SVN r21613
2014-08-31 18:08:29 +00:00
Michael Gottesman
ae0ff91ff3 Teach the various forms of stripping to ignore single predecessor args from br and cond_br.
This is effectively looking through a no-op. So it makes sense to always look
through them if we can.

<rdar://problem/18038959>

Swift SVN r21343
2014-08-21 05:16:45 +00:00
Michael Gottesman
b30b212d04 Remove the term non-PHI and instead use SinglePredecessor.
Swift SVN r21340
2014-08-21 04:13:27 +00:00
Michael Gottesman
73434aa4fa Rename SwitchEnumInst::getBBCase => getUniqueCaseForDestination.
This matches the name for SwitchEnumInst::getCaseDestination() and includes the word
'unique' so that the name self documents.

I also removed a local function doing the same work in SimplifyCFG and changed
its user to use getUniqueCaseForDestination instead.

Swift SVN r21339
2014-08-21 04:06:19 +00:00
Michael Gottesman
6d7ace6013 Make sure that when stripping non phi rc identity preserving args from switch enums, we only strip off switch enum inst if our BB is mapped to the first payloaded case of the enum.
Swift SVN r21336
2014-08-21 03:46:26 +00:00
Michael Gottesman
96ef9814f5 Change CondBranchInst::getArgForDestBB() so that it returns SILValue() if the TrueBB and the False BB equal and so that it takes the SILArgument instead of the index.
Swift SVN r21335
2014-08-21 03:45:35 +00:00
Michael Gottesman
87d1c91394 [g-arc-opts] Look through non phi rc identity preserving arguments.
rdar://18070340

Swift SVN r21329
2014-08-20 23:40:50 +00:00
Michael Gottesman
f3145119b9 Add SILValue::stripNonPHIArgs and SILValue::stripNonPHIRCIdentityPreservingArgs
for looking through SILArguments that are not PHIs in a load-store and ARC
optimizer context respectively.

Swift SVN r21328
2014-08-20 23:40:49 +00:00
Michael Gottesman
56d51ca9f1 [g-arc-opts] Teach the ARC optimizer how to strip off ref count equivalent operations such as casts and ref count identity preserving typed geps.
Now that the ARC optimizer does not rely on stripCasts I also added
unchecked_trivial_bit_cast to stripCasts.

This and r21164 give the following speedups > 10%:

Ary      55.95%
MatMul   36.71%
Ary2     34.97%
Richard  32.08%
PrimeNum 15.87%

<rdar://problem/17456455>

Swift SVN r21240
2014-08-15 22:47:57 +00:00
Mark Lacey
ab3e8aac22 Make SILValue::stripCasts see through UncheckedRefBitCastInst.
The ARC optimizer had a wrapper that handled this, but other uses of
SILValue::stripCasts could benefit as well.

Swift SVN r21153
2014-08-12 19:00:45 +00:00
Joe Groff
7d274e28a7 SIL: Add an unchecked_addr_cast instruction.
Cast an address to another address type without the silly address_to_pointer/pointer_to_address round trip.

Swift SVN r16743
2014-04-24 04:14:48 +00:00
Joe Groff
68f942117a SIL: Squash 'ref_to_native_object' and 'native_object_to_ref' into one 'unchecked_ref_cast' insn.
An unsafe cast from a base to a derived class isn't really all that different from one from Builtin.NativeObject to an arbitrary class, so relax this pair of instructions to allow an arbitrary bitcast. This only combines the instructions; it doesn't attempt to simplify any codegen that was emitting round-trip casts before yet.

Swift SVN r16736
2014-04-24 03:10:53 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Mark Lacey
679077305f Revert "Assert rather than going into an infinite loop."
This reverts r16307, which is not really useful with r16303 in place.

Swift SVN r16336
2014-04-14 22:13:18 +00:00
Mark Lacey
570a158679 Assert rather than going into an infinite loop.
Swift SVN r16307
2014-04-14 07:57:39 +00:00
Joe Groff
855ea99063 SIL: Combine 'archetype_ref_to_super' and 'upcast'.
We were wantonly applying 'upcast' to archetypes in some cases, and really, that's OK, since these instructions do the same thing (and generic specialization could turn archetype_ref_to_super into upcast). Make everyone's life easier by folding archetype_to_super into upcast. Fixes <rdar://problem/16192324>.

Swift SVN r14496
2014-02-28 04:33:18 +00:00
Michael Gottesman
0f287562de There are more than a few methods in SIL.cpp for SILValue. Refactor SILValue's implementations into its own file SILValue.cpp.
Swift SVN r13445
2014-02-04 20:25:49 +00:00