Commit Graph

266 Commits

Author SHA1 Message Date
Erik Eckstein
88c674161c refactoring: Add operator for comparing OperandValueArrayRefs.
And use it in SimplifyCFG. NFC



Swift SVN r23581
2014-11-25 09:43:35 +00:00
Roman Levenstein
ab7b1c26ca Move stripClassCasts into SILValue. NFC.
Swift SVN r23539
2014-11-21 22:21:52 +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
855657511a Document ValueBase::getParentBB
Swift SVN r21931
2014-09-12 21:12:11 +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
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
b30b212d04 Remove the term non-PHI and instead use SinglePredecessor.
Swift SVN r21340
2014-08-21 04:13:27 +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
19fd2ce0d2 Clean-up hashing in CSE by using the stored kind of the inst.
Swift SVN r18703
2014-06-04 18:21:59 +00:00
Joe Groff
d6957d0328 Make existential-to-concrete metatype casts work.
This mostly falls out from the metatype cast infrastructure, but we need to generalize some Sema and SILGen code to accept AnyMetatypeType. Concrete-to-existential metatypes will need more runtime checking that isn't implemented, so raise a 'not implemented' error on those for now.

Swift SVN r17798
2014-05-09 20:57:55 +00:00
Michael Gottesman
fd0a78b301 [sil-combine] Canonicalize index_raw_addr byte indexing operations => index_addr object size indexing operations.
This should eliminate pointless operations that get added to our inline
cost itinerary.

rdar://15567647
rdar://16762768
rdar://16832529

Swift SVN r17644
2014-05-07 22:01:30 +00:00
Mark Lacey
739eba9f2e Reformat assert so that the message isn't split.
Swift SVN r16507
2014-04-18 07:19:30 +00:00
Mark Lacey
6ac1e51370 Add an assert to detect an instruction being added as an operand of itself.
Swift SVN r16303
2014-04-14 05:40:31 +00:00
Joe Groff
d149851607 SILGen: Copy blocks received as function arguments.
We want to generally treat blocks as heap objects until proven stack-able by escape analysis, like we do generally with other heap entities. The only place we should be exposed to stack blocks is when they're passed as arguments, so handle this by copy_block'ing any block arguments we get in the function prolog. Optimization can eliminate them when analysis shows the block doesn't escape or is already on the heap.

Swift SVN r16096
2014-04-09 04:35:17 +00:00
Michael Gottesman
8740666034 Change SILCloner to be able to remap additional non-instruction based SILValues such as SILUndef.
Previously we only supported SILArguments. In the process of changing this I
noticed that our densemap implementation for SILValues only hashes the wrapped
ValueBase instead of hash combining that hash with a hash of the result number.

The main use case for this is to enable the insertion of a Builtin.trap + RAUW
SILUndef of uses of an unconditional_checked_cast that is invalid after
specialization.

rdar://16490450

Swift SVN r15747
2014-04-01 21:09:41 +00:00
Michael Gottesman
5327c3b089 Print out the result number of the SILValue when you print it out.
Swift SVN r13613
2014-02-07 00:50:19 +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
2afa5075fd Add SILValue::stripIndexingInsts() which strips of index_addr, index_raw_pointer from SILValues.
Swift SVN r13444
2014-02-04 20:25:48 +00:00
Michael Gottesman
35d1f4aa1c Rename SILValue::stripObjectProjections() => SILValue::stripAggregateProjections.
Swift SVN r12931
2014-01-24 19:48:02 +00:00
Michael Gottesman
bbc1093efd Add SILValue::stripObjectProjections().
This method looks recursively through the operand chain of the given SILValue
until it finds a non-object projection instruction. It then returns that value.

An object projection instruction is one of:

1. struct_extract.
2. tuple_extract.

Swift SVN r12918
2014-01-24 18:20:10 +00:00
Michael Gottesman
8db21be9e5 Fix typo from last night.
Swift SVN r12917
2014-01-24 18:12:13 +00:00
Michael Gottesman
6fd616c95b Add SILValue::stripPointerProjections().
An address projection instruction is one of the following instructions:

1. struct_element_addr.
2. tuple_element_addr.
3. ref_element_addr.

This method takes in the given SILValue and continually searches up its
operand chain until it finds a non address projection, non-cast
value (where cast is defined as in SILValue::stripCasts()). The found
SILValue is then returned.

Swift SVN r12909
2014-01-24 07:30:34 +00:00
Michael Gottesman
15e087bb90 Added SILValue::stripCasts().
This method takes in a SILValue and returns the SILValue created by continually
moving up the operand chain of the SILValue until a non-cast instruction is hit.
The non-cast instruction is then returned.

Swift SVN r12906
2014-01-24 07:01:52 +00:00
Michael Gottesman
26f23c1ea8 Revert "Create is<INSERT_VALUE_RANGE_HERE> VALUE_RANGE predicates to SILValue.h"
This reverts commit r12749.

I did not know about the connection in between VALUE_RANGES and abstract SIL
Base types. Using those you can perform the same operation via the isa
operation.

Swift SVN r12763
2014-01-22 19:23:10 +00:00
Michael Gottesman
d509fb9093 Create is<INSERT_VALUE_RANGE_HERE> VALUE_RANGE predicates to SILValue.h
Thus if one wishes to match a method inst, instead of using a switch one could
just go isMethodInst(Kind) and get the appropriate result.

My hope is this will make life easier by allowing us to use less switches.

Swift SVN r12749
2014-01-22 18:17:27 +00:00
Joe Groff
402f4daa58 SILGen: Emit protocol witnesses.
Reuse John's abstraction thunking machinery in SILGenPoly to emit the abstraction change from a protocol requirement to a concrete witness. There are potentially two abstraction changes necessary; if a witness is generic, we need to reabstract again from the concrete substituted type of the witness to the generic witness function's original signature. This currently leads to a bunch of extra temporaries in cases where an argument or return gets unabstracted to a loadable value then reabstracted to a generic parameter, but optimizations should be able to clean this up. Protocol witnesses also have additional potential abstraction changes in their 'self' parameter: the 'self' parameter of the protocol requirement is always considered @inout, but class 'self' parameters are not; also, an operator requirement can be satisfied by a free function, in which case 'self' is discarded.

Also, fix a bug in return value thunking where, if the thunk could reuse its @out parameter as the @out parameter of the underlying function, we would not disable the cleanup we install on the result value, leading to the result getting overreleased.

Swift SVN r11245
2013-12-13 05:58:51 +00:00
Chris Lattner
e4c2231718 Add some operator-> implementations to iterators to match their operator*
implementations.


Swift SVN r10777
2013-12-04 06:04:07 +00:00
Michael Gottesman
301a42f140 Move SILInstruction::replaceAllUsesWith -> SILValue::replaceAllUsesWith.
This commit corrects, as Jim likes to put it, a "thinko".

Swift SVN r10760
2013-12-03 22:37:10 +00:00
Michael Gottesman
55a05b4951 [cse] Actually follow the directions from Hashing.h and put hash_value into swift namespace. Also remove a few const.
Swift SVN r10754
2013-12-03 21:38:17 +00:00
Michael Gottesman
faea4d5f60 [cse] Implement hash_value for SILValue and SILType.
*NOTE* I followed the hashing conventions used in the DenseMap hashing
implementations.

Swift SVN r10745
2013-12-03 01:07:54 +00:00
Michael Gottesman
9e77cf2103 Canonicalize the header guards for SILType.h and SILValue.h.
Swift SVN r10744
2013-12-03 01:06:14 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Chris Lattner
f6d339526d fix typo
Swift SVN r9934
2013-11-04 22:43:52 +00:00
Jordan Rose
553983f584 Fix misuse of alignof, which returns alignment as 2^N instead of N.
If we constexpr'd some of the functions in MathExtras we could use
log2(alignof(T)), but for now just hardcode a literal "3".

Swift SVN r9928
2013-11-04 18:22:25 +00:00
Chris Lattner
db86f4dad1 Bump SILValue up to allow 2 bits of result number, enabling instructions to produce up to 4 results.
Swift SVN r9924
2013-11-04 18:02:08 +00:00
Chris Lattner
82567f9ffb SILValue is just a wrapper around its ValueAndResultNumber. Derive
the number of low bits available in it from the #bits in ValueAndResultNumber,
instead of computing it independently.


Swift SVN r9922
2013-11-04 17:54:42 +00:00
Chris Lattner
03e7b756d0 teach simplify-cfg to merge blocks connected by an uncond branch, when
the dest has no other predecessors.  This fires 6926 times on the stdlib.


Swift SVN r9794
2013-10-30 16:48:59 +00:00
Chris Lattner
681ad64db3 teach simplifycfg's dead block deletion to correctly handle blocks with
instructions that are used cross-block.


Swift SVN r9788
2013-10-30 14:23:51 +00:00
Chris Lattner
6c23f3e8f8 Add an important assert to ValueBase, to make it a hard error to delete
a value that still has uses.  Doing so leaves dangling pointers and is
unwise.  Nothing in the testsuite triggers this, but simplify-cfg can
on real code.


Swift SVN r9770
2013-10-29 23:44:51 +00:00
Chris Lattner
c118613de3 Fix SILValue use_iterators to type the user as a SILInstruction, not just a ValueBase.
There are no values other than instructions that can use other values.  BBArguments are
defs, not uses.  This eliminates a bunch of casts in clients that use getUser().


Swift SVN r9701
2013-10-27 23:32:14 +00:00
Chris Lattner
1687382e95 Checkpoint some progress on inout deshadowing, since I'm about to
take a direction change and remove it all. :-)


Swift SVN r8965
2013-10-07 17:18:21 +00:00
Joe Groff
82a18333ed SIL: Purge SpecializeInst.
Make ApplyInst and PartialApplyInst directly take substitutions for generic functions instead of trying to stage out substitutions separately. The legacy reasons for doing this are gone.

Swift SVN r8747
2013-09-28 00:15:45 +00:00
Michael Gottesman
85c7a0b5d9 Change SILValue::operator*()'s return type from ValueBase * -> ValueBase & to match the normal canonical implementation of operator*.
Thanks Dave A!

Swift SVN r8740
2013-09-27 21:07:44 +00:00
Michael Gottesman
01840d2011 Added operator->()'s brother operator*() to SILValue.
Swift SVN r8722
2013-09-27 05:24:00 +00:00
Anna Zaks
b073815e7d [SIL] Remove ValueBase::replaceAllUses, which should never have been added.
I’ve added it without understanding the full consequences. If a variant of this is added, it
should take a list of values as the argument. Currently, there is no use for it, so just remove it.

Swift SVN r7238
2013-08-14 22:01:58 +00:00
Anna Zaks
359695acbd [SIL] Add dropAllReferences and a mutable version of getAllOperands
Swift SVN r7236
2013-08-14 22:01:57 +00:00
Anna Zaks
342dff1c80 [SIL CCP] Add the early constant propagation pass skeleton.
The pass folds a single operation: int_sadd_with_overflow and issues an
error on detectable overflow.

Swift SVN r7204
2013-08-13 17:36:35 +00:00
John McCall
2eabba0faa Add a getUser() to ValueBase::use_iterator.
Swift SVN r6973
2013-08-07 03:21:11 +00:00