Commit Graph

37 Commits

Author SHA1 Message Date
Michael Gottesman
ae18e7bedd [g-arc-opts] Change fatalName checking to use endswith instead of equals.
Specialization manglings always prepend the specialization information to the
beginning of a function name. Thus we can (until we support multiple @semantic
tags) get better dylib performance.

Swift SVN r25006
2015-02-05 19:11:34 +00:00
Michael Gottesman
7acd7def16 [verifier] Make sure that applies of no-return functions have an unreachable as the next instruction.
This makes it easy to find no-return functions since one must iterate
through all BB with unreachable terminators and check the previous
instruction.

Swift SVN r25004
2015-02-05 19:11:33 +00:00
Michael Gottesman
3b5e703d68 [g-arc-opts] Teach the ARC Optimizer how to understand @guaranteed parameters directly.
Swift SVN r24602
2015-01-21 14:52:37 +00:00
Michael Gottesman
38a0c69fc1 Rename some arc routines to use may instead of can as a prefix to match AliasAnalysis more closely.
Swift SVN r24509
2015-01-19 10:03:06 +00:00
Michael Gottesman
39817d5fd8 Remove arc namespace.
Swift SVN r24500
2015-01-19 00:10:48 +00:00
Michael Gottesman
3d396f8b12 [arc-analysis] Refactor OwnedArgToEpilogueReleaseMatcher from FunctionSigOpts.
Given a function F, this utility class attempts to match up owned arguments with
releases in the epilogue of the function.

I am refactoring this from FunctionSigOpts so I can use it in the ARC optimizer.

<rdar://problem/18923030>

Swift SVN r23219
2014-11-11 00:42:30 +00:00
Michael Gottesman
a014c65205 Expose canInstUseRefCountValues as swift::canNeverUseValues.
canInstUseRefCountValues should have always been named
canInstNotUseRefCountValues. I don't remember how it get renamed as such. Even
though it is a little weird to have a "canNever" in a function name, it makes
sense here to contrast it with canUseValue which returns if a specific user can
use a ptr in a way that requires the ptr to be alive. This in contrast says that
a user can never use a ptr in a manner where the ptr must be alive. I.e. this is
a universal quantifier.

Swift SVN r22961
2014-10-27 09:15:57 +00:00
Joe Groff
ea65d1e60b SIL: Remove the builtin_function_ref instruction.
Swift SVN r22797
2014-10-16 16:18:40 +00:00
Joe Groff
e3f9a2035c SIL: Move SILGen and passes over to use "builtin" instead of "apply (builtin_function_ref)".
Swift SVN r22785
2014-10-15 23:37:22 +00:00
Dave Abrahams
74e27aaab1 [stdlib] uniqueness checking for users
Make unique reference checking available to users, making ManagedBuffer
a complete facility for building COW value types.  Also rationalize the
way we name and organize the runtime primitives we ultimately call.

Swift SVN r22594
2014-10-08 04:48:52 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Joe Groff
a3126706da SIL: Eliminate the dead 'alloc_array' insn.
Swift SVN r22292
2014-09-26 02:28:10 +00:00
Michael Gottesman
f541019660 [codemotion] Extract out isARCInertTrapBB into ARCAnalysis from GARCOpts and teach SILCodeMotion to use it to not move retains into trap bbs.
This reduces the number of retains, releases in the stdlib by another 5% to
15167.

rdar://18328074

Swift SVN r21936
2014-09-13 03:15:29 +00:00
Michael Gottesman
5561b3f538 Convert Nothing_t::Nothing => Nothing.
Swift SVN r21605
2014-08-30 03:11:55 +00:00
Michael Gottesman
b617d1b6d1 [arc] Change valueHasARC*InInstructionRange to return either the offending instruction or Nothing_t::None instead of a bool.
This enables us to both check if any instructions may use or decrement a value
in an instruction range and if we find such an instruction know the furthest
where we can move the retain or release.

Swift SVN r21522
2014-08-28 08:00:44 +00:00
Andrew Trick
292d9b3bb2 Fix SILCodeMotion: do not move retains across isUniquelyReferenced.
Sinking retains will simply make the unique check useless and eliminate
Array copies even when we need them.

Fix for:
<rdar://problem/18109082> ARC: make _isUniquelyReferenced a barrier to avoid lost copies

Swift SVN r21485
2014-08-27 18:28:36 +00:00
Michael Gottesman
2ee9dab15a [arc-analysis] unchecked_ref_bit_cast can never use reference count values in a way we care about. Trivial bit casts do not either as long as we are not converting a ref count value to a trivial value.
Swift SVN r19911
2014-07-13 23:44:13 +00:00
Michael Gottesman
4f115c63c3 [arc-analysis] {struct,tuple}_element_addr, unchecked_take_enum_data_addr do not use reference counted objects in a way we care about.
The reason we do not care is since this predicate is meant to be used in a
backward dataflow pass implying that we will see the GEPs users before we see
the GEP itself.

Swift SVN r19910
2014-07-13 22:26:47 +00:00
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