Commit Graph

47 Commits

Author SHA1 Message Date
Michael Gottesman
8ffc0f10a3 [sil-aa] AA::may{Read,Write,ReadOrWrite}FromMemory do not care about ref counts. Add a flag to ignore ref counts during such a query.
This is due to MayHaveSideEffects encompassing ref count effects and a
myriad of other effects. If/when we separate the two concepts (which is
cleaner IMHO), the flag will no longer be necessary.

Swift SVN r16807
2014-04-25 06:37:02 +00:00
Michael Gottesman
a75de1c9a5 [sil-aa] Teach AA::getMemoryBehavior about a bunch more instructions which do
not have their normal memory behavior if the value we are trying to find memory
behavior relative to does not alias their arguments.

Also cond_fail is inert from an AA perspective.

Swift SVN r16806
2014-04-25 06:37:01 +00:00
Michael Gottesman
9401b1b0f4 [sil-aa] Refactor memory behavior implementation to use a visitor instead of a large switch to make things more readable.
This is in preparation for increasing the amount of instructions handled
by memory behavior.

Swift SVN r16788
2014-04-25 00:52:02 +00:00
Michael Gottesman
20ef9c08fc [sil-aa] Globals are identified objects at compile time. <rdar://problem/16696826>.
Swift SVN r16694
2014-04-23 08:53:25 +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
Michael Gottesman
b04b14e0fa Refactor isNonEscapingLocalObject/getUnderlying object into their own file ValueTracking.cpp.
This is because I need them in ARCAnalysis.cpp and from a modeling
perspective it is no longer just going to be used just in AA since they
are of larger functionality.

Swift SVN r16297
2014-04-14 04:44:53 +00:00
Mark Lacey
1452d24671 Small cleanup: Remove unnecessary calls to getDef(), mostly in dyn_cast<>(...).
Swift SVN r16235
2014-04-11 23:05:16 +00:00
Joe Groff
fd9a9b5881 SIL: Add a CopyBlockInst instruction.
This maps down to a _Block_copy call that gives us the result, which may be different from the original object, back.

Swift SVN r16042
2014-04-08 02:43:17 +00:00
Chris Lattner
afea47b621 rename "destroy_value" to "release_value", part of rdar://15889208.
Swift SVN r15777
2014-04-02 05:33:52 +00:00
Chris Lattner
6540423613 rename CopyValueInst -> RetainValueInst. The .sil syntax
isn't changed yet.


Swift SVN r15775
2014-04-02 05:11:31 +00:00
Michael Gottesman
62eb79eb7b [sil-aa] Change aggregateContainsRecord to compare CanonicalTypes instead of Types. One should never compare non-canonicalized types.
Swift SVN r15698
2014-03-31 22:57:01 +00:00
Joe Groff
584009d27e SIL: Remove copy_value's result.
We won't have any types where copying has an effect on the bit pattern (except for blocks, which need special handling anyway), and copy_value having a result makes optimizations more complex, so remove it.

Swift SVN r15640
2014-03-30 03:40:45 +00:00
Joe Groff
afd59130f0 SIL: Add a FixLifetime instruction.
This will be a signal to ARC optimization, RVO, and other lifetime-affecting optimizations that they should not shorten the lifetime of a value past a certain point. We need this for C pointer bridging. This adds the instruction, but does not add any knowledge of it to the ARC optimizers.

Swift SVN r15601
2014-03-29 02:50:34 +00:00
Nadav Rotem
722c5f8817 Reverse the boolean logic of the function to make it more readable. NFC.
Swift SVN r15488
2014-03-26 05:51:23 +00:00
Nadav Rotem
da6a9fe7b3 TBAA: Recurse into unbound generic types when analyzing nonimal types.
This allows us to inspect UnsafePointer<T> that does not store T anywhere.
This commit removes the retains and releases in RC4 again.



Swift SVN r15483
2014-03-26 05:19:16 +00:00
Nadav Rotem
35f00fd23a TBAA: Fix the type relationship between aggregate types by scanning the record types recursively.
Example: Float* may alias Point* because Point may contain a float.

This commit regresses RC4::swapByIndex.



Swift SVN r15477
2014-03-26 00:31:12 +00:00
Nadav Rotem
fe1e135413 Add more alias analysis TBAA rules.
These new rules remove all of the redundant retains and releases in RC4::swapByIndex.



Swift SVN r15383
2014-03-23 07:02:14 +00:00
Nadav Rotem
1bfa103362 Add a basic TBAA rule.
Swift SVN r15358
2014-03-22 01:12:09 +00:00
Doug Gregor
82c1ba2e29 Remove peer_method instruction; we're no longer using it.
Swift SVN r14599
2014-03-03 17:13:06 +00:00
Doug Gregor
5d8bd84dfa Introduce the SIL instruction alloc_ref_dynamic.
alloc_ref_dynamic allocates an instance of a class type based on the
value in its metatype operand. Start emitting these instructions for
the allocating constructor of a complete object initializer (not yet
tested) and for the allocating constructor synthesized for an imported
Objective-C init method.

Still missing:
  - IRGen still does the same thing as alloc_ref right now. That
  change will follow.
  - There are devirtualization opportunities when we know the value of
  the metatype that would turn an alloc_ref_dynamic into an alloc_ref;
  I'm not planning to do this optimization.



Swift SVN r14560
2014-03-01 21:55:50 +00:00
Joe Groff
67ca7ce1e9 SIL: Rename 'protocol_metatype' to 'existential_metatype'.
It's not forming the metatype for the protocol type (exists t: P. t).metatype, it's forming the existential of a metatype of a conforming type, exists t: P. (t.metatype).

Swift SVN r14520
2014-02-28 16:14:00 +00:00
Joe Groff
88b6efcc43 Rename ArchetypeMethodInst -> WitnessMethodInst more thoroughly.
Swift SVN r14501
2014-02-28 06:41:18 +00:00
Joe Groff
9424de6787 SIL: Rename 'archetype_metatype' to 'value_metatype'.
Since it can grab a metatype from any value now.

Swift SVN r14500
2014-02-28 06:33:05 +00:00
Joe Groff
545f173507 SIL: Fold 'archetype_metatype' and 'class_metatype'.
Having one instruction to get the dynamic metatype of a (non-existential) value makes more sense from a generic specialization standpoint and should stave off inevitable crashers when archetype_metatypes get specialized. protocol_metatype remains separate because metatype existentials are more interesting.

Swift SVN r14499
2014-02-28 06:32:58 +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
Doug Gregor
3182cd3910 Introduce thick/Objective-C metatype conversion instructions.
Introduce the SIL instructions thick_to_objc_metatype and
objc_to_thick_metatype to convert between the 'thick' and
'Objective-C' representations of a metatype. Most of this code is
trivial support code for these conversions: printing, parsing,
(de-)serialization, etc., for which testing will come online in
subsequent patches or is incidental in other tests.

Lower Objective-C metatype values down to objc_class* at the IR level
and implement IRGen support for these SIL instructions. SIL-only test
case at the moment because SILGen never creates these instructions.



Swift SVN r14087
2014-02-19 18:20:21 +00:00
Michael Gottesman
8305814733 [sil-aa] Make sure we do not use too much compile time in valueMayBeCaptured by limiting the size of the use lists we will process to 32.
Swift SVN r14040
2014-02-18 15:50:14 +00:00
Michael Gottesman
6924925bff [sil-aa] Small cleanups. NFC.
Swift SVN r14014
2014-02-17 23:41:22 +00:00
Michael Gottesman
6570c169c0 Teach SILArgument how to determine if it is a function argument or not.
A SILArgument is a function argument if the argument's parent BB is the entry BB
of the function containing the argument.

This is an interesting distinction since function arguments have special
aliasing properties with respect to indirect arguments which normal basic block
arguments do not.

Swift SVN r14012
2014-02-17 23:24:06 +00:00
Doug Gregor
2134072285 Split open_existential[_ref] out as their own instructions.
Riding off of project_existential[_ref] was convenient, but the
resuls are used quite differently. Note that open_existential[_ref]
still don't print/parse reasonably yet.



Swift SVN r13878
2014-02-13 23:42:23 +00:00
Michael Gottesman
060a6b59fa [sil-aa] Make the comment descriptor of transitive escape inst clearer and use a refactored method to determine if a builtin is read none instead of doing it manually.
Swift SVN r13793
2014-02-12 00:14:30 +00:00
Michael Gottesman
f70a1d8d1b [sil-aa] InitExistentialInst is a transitive escape inst.
Swift SVN r13792
2014-02-12 00:14:30 +00:00
Michael Gottesman
9453993493 [sil-aa] Create convenience methods isMustAlias, isNoAlias, isMayAlias and update AA uses to use these instead.
Swift SVN r13788
2014-02-11 22:56:56 +00:00
Michael Gottesman
4a37141f08 [sil-aa] Added in a quick fixme to notate for posterity that when in the way
future variadic address projections land, getUnderlyinObject and
findAddressProjectionPath should never disagree due to the former handling casts
in contrast with the later.

Swift SVN r13769
2014-02-11 01:03:43 +00:00
Michael Gottesman
de48699d49 [sil-aa] Teach SILAA how to prove that two GEPs from the same base pointer with the same projections must alias.
Swift SVN r13768
2014-02-11 00:55:09 +00:00
Michael Gottesman
10e529782c [sil-aa] Add support for distinguishing non escaping local objects and escape sources.
Swift SVN r13729
2014-02-10 01:48:14 +00:00
Michael Gottesman
bc8b8a521d Ensure that all uses of DisableAliasAnalysis are also conditionally compiled out when not compiling with Debug.
Swift SVN r13669
2014-02-08 00:56:56 +00:00
Michael Gottesman
d75da69b2f [sil-aa] Compile out DisableAliasAnalysis flag when not building Debug. Put in a comment making it clear that it should be removed once AA bringup is complete.
Swift SVN r13664
2014-02-08 00:07:13 +00:00
Michael Gottesman
2576075210 [sil-aa] Change disable-aa to be a hidden argument.
Swift SVN r13661
2014-02-07 23:00:52 +00:00
Michael Gottesman
d8f9e188b0 [sil-aa] Add command line option to turn off alias analysis. This is useful for measuring the effect of AA.
Swift SVN r13660
2014-02-07 22:57:00 +00:00
Michael Gottesman
94fb218a5e [sil-aa] Two SILValues that are the same without any stripping trivially alias each other.
Swift SVN r13609
2014-02-07 00:21:40 +00:00
Michael Gottesman
69d738e24c [sil-aa] A SILArgument is only a no-alias SILArgument if it is an argument to the first BB of a function.
Swift SVN r13608
2014-02-07 00:17:42 +00:00
Michael Gottesman
9a297333f9 Enable printing of AliasAnalysis::AliasResult and SILValues.
Swift SVN r13577
2014-02-06 10:06:20 +00:00
Michael Gottesman
abc9a8d7b6 [sil-aa] Teach SILAA that a SILArgument and something that is identifiable as a local object can not alias.
Swift SVN r13557
2014-02-06 04:31:06 +00:00
Michael Gottesman
d37ba66864 [sil-aa] Change isAllocationInst => isa<AllocationInst>. Remove isAllocationInst since it is dead code.
Swift SVN r13556
2014-02-06 04:31:06 +00:00
Michael Gottesman
098fda670f [sil-aa] Change SIL AliasAnalysis into an Analysis.
Swift SVN r13550
2014-02-06 02:29:41 +00:00
Michael Gottesman
7461dbd70a Now that we have a PM, separate passes from analyses by creating a separate library swiftSILAnalysis and a separate folder/etc.
Swift SVN r13511
2014-02-05 22:17:50 +00:00