Commit Graph

19 Commits

Author SHA1 Message Date
Michael Gottesman
f45ea97a8b [arc-analysis] ReadNone builtins that do not take values with reference semantics can not use values with reference semantics.
Swift SVN r19909
2014-07-13 22:26:46 +00:00
Michael Gottesman
8685173e21 [arc-analysis] Add two functions for applying canUseValue and canDecrementValue to a contiguous range of instructions in the same BB.
The two functions are:

1. valueHasARCUsesInInstructionRange.
2. valueHasARCDecrementsInInstructionRange.

They operate on the range [Start, End).

I am going to use them in enum simplification and sil code motion.

Swift SVN r19893
2014-07-13 06:32:44 +00:00
Manman Ren
357640494a [global-arc] treat isUniquelyReferenced as known to not decrement ref count.
This removes a pair of retain|release from MD5.hash().
rdar://17360691


Swift SVN r19024
2014-06-20 01:20:17 +00:00
Michael Gottesman
6db91f76c9 [g-arc-opts] swift_keepAlive does not decrement reference counts.
Swift SVN r18708
2014-06-05 05:14:17 +00:00
Michael Gottesman
5def9ae5dc [local-arc-analysis] Teach ARC analysis about more instructions that only use pointers via users. These uses will be caught by the dataflow.
Swift SVN r18695
2014-06-03 08:58:29 +00:00
Michael Gottesman
fc7438b79c [sil-arc] Casts do not use pointers in an interesting way.
The reason that this is true is that if the cast is dead, we will delete
it. If it is not dead there must be some other use after the cast that
uses our pointer via the cast. If that is true and there is a release
after that use we will not move the release over the use. On the other
hand if the release is in between the cast and the use it is of course
safe to move the release forward.

Swift SVN r16797
2014-04-25 02:16:43 +00:00
Michael Gottesman
5283a351e4 [sil-arc] Fix up a few comments and teach the optimizer that fix_lifetime_inst, copy_block, and retain_value can not decrement ref counts.
Swift SVN r16790
2014-04-25 01:27:44 +00:00
Michael Gottesman
9b09c562cd [sil-arc-optimizer] Teach the ARC optimizer that it needs to check if a ptr escapes in order to say that a callee can not affect the ptr.
<rdar://problem/16424681>

Swift SVN r16298
2014-04-14 04:44:54 +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
8adaab0233 Fold ExtInfo::isThin and ::isBlock into a "Representation" enum.
These bits are orthogonal to each other, so combine them into one, and diagnose attempts to produce a type that's both. Spot-fix a bunch of places this revealed by inspection that we would have crashed in SILGen or IRGen if blocks were be handled.

Swift SVN r16088
2014-04-09 00:37:26 +00:00
Nadav Rotem
a72cd1af2a ARCOpt: fix an object ownership bug.
When checking for users of an object we need to consider all values
because any use of the object may increase its lifetime. 

For example, in the sil code below, instruction %26 increases the lifetime of
object %9. If we remove the retain-release pair then the apply inst may
release %9 and the load would become invalid. 

  strong_retain %9#0 : $Builtin.ObjectPointer
  %24 = apply %19<>()
  %26 = load %9#1 : $*Int
  strong_release %9#0 : $Builtin.ObjectPointer
  return %26 : $Int

This fixes rdar://16233340



Swift SVN r14745
2014-03-06 19:46:18 +00:00
Nadav Rotem
e620ed323c Additional negative logic changes. NFC.
Swift SVN r14743
2014-03-06 19:10:32 +00:00
Nadav Rotem
15ec637128 Reverse the negative logic. NFC.
Swift SVN r14742
2014-03-06 19:02:42 +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
88b6efcc43 Rename ArchetypeMethodInst -> WitnessMethodInst more thoroughly.
Swift SVN r14501
2014-02-28 06:41:18 +00:00
Michael Gottesman
0044c1d379 [arc-opts] Teach cannotDecrementRefCount how to use alias information to prove
that an apply which may decrement ref counts can not decrement a value with
reference semantics if we can prove the value does not alias any of the applies
arguments.

Swift SVN r14120
2014-02-20 01:08:49 +00:00
Michael Gottesman
fbe2ccf0d6 [sil-aa] Add in convenience methods for querying AliasAnalysis::getMemoryBehavior.
The methods are:

 * mayWriteToMemory()
 * mayReadFromMemory()
 * mayReadOrWriteMemory()
 * mayHaveSideEffects() [Side effects + writing to memory]
 * mayHavePureSideEffects() [Only side effects, ignores writes to memory]

Swift SVN r13791
2014-02-12 00:14:29 +00:00
Michael Gottesman
8cb9693830 [sil-arc-opts] Teach SILARCOpts how to use alias analysis to determine if a store/load could use a value.
Swift SVN r13658
2014-02-07 22:56:59 +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