Commit Graph

521 Commits

Author SHA1 Message Date
Erik Eckstein
ee988e21cb SIL: Add stack attributes to alloc_ref and dealloc_ref.
For details see docs/SIL.rst.
This is needed for the stack promotion optimization.



Swift SVN r32908
2015-10-27 15:29:20 +00:00
Slava Pestov
7cc59e01d7 SIL: Add DeallocPartialRefInst
This instruction destroys instance variables in a partially-initialized
object, then frees it.

Swift SVN r32661
2015-10-13 19:56:20 +00:00
Slava Pestov
090d723763 SIL: Remove null_class instruction
Swift SVN r32605
2015-10-11 02:11:22 +00:00
Andrew Trick
c20370a664 Remove the last remnants of unchecked_ref_bit_cast
Swift SVN r32598
2015-10-10 05:42:57 +00:00
Andrew Trick
665e5169d5 Add unchecked_ref_cast_addr SIL instruction.
Swift SVN r32587
2015-10-10 03:39:32 +00:00
Joe Groff
0cd5aa8c7c Change mangling for the Swift module from 'Ss' to 's'.
'Ss' appears in manglings tens of thousands of times in the standard library and is also incredibly frequent in other modules. This alone is enough to shrink the standard library by 59KB.

Swift SVN r32409
2015-10-02 22:39:44 +00:00
Erik Eckstein
2f2c7d571d Verify that a SILFunction has not multiple throw instructions.
...and document it.



Swift SVN r31351
2015-08-19 21:47:09 +00:00
Ben Langmuir
b38067ba97 Revert "Teach SILPrinter/Parser how to parse the conformances associated with an init_existential_metatype."
This broke some validation tests.

This reverts commit r31277.

Swift SVN r31282
2015-08-17 23:55:07 +00:00
Michael Gottesman
b1f336b0cf Teach SILPrinter/Parser how to parse the conformances associated with an init_existential_metatype.
Now we can IRGen Richards.sil produced via a *.sib file.

rdar://22302277

Swift SVN r31277
2015-08-17 21:05:53 +00:00
Erik Eckstein
388bc31ba7 Add a nothrow flag to the SIL apply_inst.
If the compiler can prove that a throwing function actually does not throw it can
replace a try_apply with an "apply [nothrow]". Such an apply_inst calls a function
with an error result but does not have the overhead of checking for the error case.

Currently this flag is not set, yet.



Swift SVN r31151
2015-08-12 00:18:36 +00:00
Michael Gottesman
c197c627ad Add some missing instructions to SIL.rst and order it more along the lines of SILNodes.def.
Swift SVN r31007
2015-08-04 21:12:59 +00:00
Joe Groff
767e1ff6b3 Update SIL.rst to discuss @box types.
Swift SVN r29773
2015-06-28 17:36:30 +00:00
Andrew Trick
a32a0af02b Allow unchecked_trivial_bit_cast to cast to smaller types.
I'm sure this is totally safe, why wouldn't it be?

Fixes <rdar://problem/21095584> Swift: UnsafePointer on tuple works in
debug but compiles crashing binary in release

Swift SVN r29614
2015-06-24 20:25:15 +00:00
Andrew Trick
7565a65235 Introduce unchecked_bitwise_cast SIL instruction.
We need a SIL level unsafe cast that supports arbitrary usage of
UnsafePointer, generalizes Builtin.reinterpretCast, and has the same
semantics on generic vs. nongeneric code. In other words, we need to
be able to promote the cast of an address type to the cast of an
object type without changing semantics, and that cast needs to support
types that are not layout identical.

This patch introduces an unchecked_bitwise_cast instruction for that
purpose. It is different from unsafe_addr_cast, which has been our
fall-back "unknown" cast in the past. With unchecked_bitwise_cast we
cannot assume layout or RC identity. The cast implies a store and
reload of the value to obtain the low order bytes. I know that
bit_cast is just an abbreviation for bitwise_cast, but we use
"bitcast" throught to imply copying a same sized value. No one could
come up with a better name for copying an objects low bytes via:

  @addr = alloca $wideTy
    store @addr, $wideTy
      load  @addr, $narrowTy

Followup patches will optimize unchecked_bitwise_cast into more
semantically useful unchecked casts when enough type information is
present. This way, the optimizer will rarely need to be taught about
the bitwise case.

Swift SVN r29510
2015-06-19 16:29:35 +00:00
Dmitri Hrybenko
23d474cab3 Fix documentation build
Swift SVN r28710
2015-05-18 18:16:40 +00:00
Slava Pestov
b06c45b9b3 Attempt to document checked_cast_addr_br and unconditional_checked_cast_addr
Swift SVN r28693
2015-05-18 00:26:21 +00:00
Chris Lattner
6f7caf8335 fix a past-o in the dox.
Swift SVN r28149
2015-05-05 04:26:19 +00:00
Erik Eckstein
40c1160713 Revert r28111 "rework the peephole for optional-to-optional casts to be more specific"
and r28105: "implement <rdar://problem/17013042> T! <-> T? conversions should not produce a diamond"

r28111 broke the stdlib build. I also reverted r28105, because r28111 fixes regressions introduced in r2805.



Swift SVN r28114
2015-05-04 07:24:13 +00:00
Chris Lattner
add4909d35 implement <rdar://problem/17013042> T! <-> T? conversions should not produce a diamond
Two pieces to this:
 - Peephole InjectOptionalExpr(BindOptionalExpr(X)) to bitcast x to the result type.
 - Enhance OptionalEvaluationExpr to delete the failure block if not needed.



Swift SVN r28105
2015-05-04 01:12:23 +00:00
Andrew Trick
41cf8608cb Add is_unique documentation.
I also added a placeholder for ARC optimization docs. I wanted anyone
reading about swift ARC optimization to run across my discussion on
correctness w.r.t. COW.

Swift SVN r27890
2015-04-28 22:54:26 +00:00
Joe Groff
8293f3f444 Update SIL.rst to discuss @convention instead of the old attributes.
Swift SVN r27611
2015-04-22 22:51:20 +00:00
Joe Groff
fd138326ba SIL: Reject '@cc', '@thin', and '@objc_block' in SIL.
Since it's an internal interface, there's no need for migration in SIL.

Swift SVN r27610
2015-04-22 22:40:08 +00:00
Chris Lattner
5df6b054db fix the dox build
Swift SVN r27527
2015-04-21 06:18:13 +00:00
Chris Lattner
42b4a966b0 Introduce a new null_class SIL instruction for forming a null pointer
reference to something of class type.  This is required to model
RebindSelfInConstructorExpr correctly to DI, since in the class case, 
self.init and super.init *take* a value out of class box so that it 
can pass the +1 value without performing an extra retain.  Nothing
else in the compiler uninitializes a DI-controlled memory object
like this, so nothing else needs this.  DI really doesn't like something
going from initialized to uninitialized.

Yes, I feel super-gross about this and am really unhappy about it.  I
may end up reverting this if I can find an alternate solution to this
problem.



Swift SVN r27525
2015-04-21 05:56:55 +00:00
Michael Gottesman
11e8cfa06f State in the uncurry level examples which reference is the "natural uncurry level" explicitly.
Swift SVN r27143
2015-04-08 23:30:52 +00:00
Chris Lattner
379cae70d9 unbreak the dox build.
Swift SVN r26761
2015-03-31 16:40:43 +00:00
John McCall
6d8fff9c06 Parsing and basic structure of try_apply. Not yet properly
threaded into IRGen; tests to follow when that's done.

I made a preliminary effort to make the inliner do the
right thing with try_apply, but otherwise tried to avoid
touching the optimizer any more than was required by the
removal of ApplyInstBase.

Swift SVN r26747
2015-03-31 02:41:03 +00:00
Chris Lattner
209d9d6f5b fix the dox build.
Swift SVN r26623
2015-03-27 05:46:33 +00:00
John McCall
35b7db3ae1 Parsing support for error results from SILFunctionType.
Swift SVN r26566
2015-03-26 00:01:32 +00:00
Joe Groff
7431234bd2 SIL.rst: trim
Swift SVN r26496
2015-03-24 19:41:59 +00:00
Joe Groff
a5fb34fea1 SIL.rst: Hook up links to existential box insns.
Swift SVN r26468
2015-03-24 01:10:01 +00:00
Joe Groff
fdde2a8e99 SIL: Add instructions for boxed existential operations.
Parsing and serialization for {Alloc,Open,Dealloc}ExistentialBox instructions to represent operations on ErrorType boxes.

Swift SVN r26145
2015-03-15 03:32:37 +00:00
Joe Groff
daf3ec67de SIL.rst: Pre-document instructions for boxed existential containers.
Swift SVN r26085
2015-03-13 02:40:22 +00:00
Joe Groff
3d466312c9 SIL.rst: Add docs for existential metatype instructions.
Swift SVN r26083
2015-03-13 02:40:13 +00:00
Joe Groff
84e2d4e8ba SIL.rst: Add discussion of existential container representations.
And adjust the names of ExistentialRepresentation cases to match the existing nomenclature instead of needlessly inventing new names.

Swift SVN r26069
2015-03-12 22:26:00 +00:00
Chris Lattner
d55d2f052f fix build error in dox
Swift SVN r25912
2015-03-10 04:00:42 +00:00
Joe Groff
962a87f444 SIL: Rename address-only existential instructions to '{init,deinit,open}_existential_addr'.
For better consistency with other address-only instruction variants, and to open the door to new exciting existential representations (such as a refcounted boxed representation for ErrorType).

Swift SVN r25902
2015-03-09 23:55:31 +00:00
Chris Lattner
3fb3cd6033 remove gunk
Swift SVN r24227
2015-01-06 23:18:23 +00:00
Chris Lattner
76f60998f0 mention how noescape works in SIL
Swift SVN r24226
2015-01-06 23:17:37 +00:00
Dmitri Hrybenko
94541a5ced Revert "Change select* instructions so that all of them have the same tail allocated"
This reverts commit r24159 because it breaks building the stdandard
library.

Swift SVN r24161
2014-12-28 08:04:45 +00:00
Michael Gottesman
a6bd0cce0f Change select* instructions so that all of them have the same tail allocated
memory layout and add a SelectInst API that allows for one to access select inst
operands when one does not care about what the cases actually are.

Previously select_enum, select_enum_addr had the following memory layout:

  [operands], [cases]

In constrast, select_value had the following layout:

  [operand1, case1, operand2, case 2, ...]

The layout for select_value makes it impossible to just visit operands in a
generic way via a higher level API. This is an important operation for many
analyses such as AA on select insts.

This commit does the following:

1. Adds a new abstract parent class for all select instructions called
SelectInst.
2. Adds a new templated implementation parent class that inherits from
SelectInst called SelectInstBase. This handles the complete implementation of
select for all types by templating on CaseTy.
3. Changes SelectEnumAddrInst, SelectEnumInst, SelectValueInst to be thin
classes that inherit from the appropriately specialized SelectInstBase.

I left in SelectEnumInstBase for now as a subclass of SelectInstBase and parent
class of SelectEnum{,Addr}Inst since it provides specific enum APIs that are
used all over the compiler. All of these methods have equivalent methods on
SelectInstBase. I just want to leave them for a later commit so that this commit
stays small.

Swift SVN r24159
2014-12-27 05:33:18 +00:00
Chris Lattner
74bd5e2b42 fix "title underline too short" build failures.
Swift SVN r23911
2014-12-13 06:27:58 +00:00
John McCall
169e4fe319 Add Builtin.UnsafeValueBuffer, which provides opaque
storage for arbitrary values.

A buffer doesn't provide any way to identify the type of
value it stores, and so it cannot be copied, moved, or
destroyed independently; thus it's not available as a
first-class type in Swift, which is why I've labelled
it Unsafe.  But it does allow an efficient means of
opaquely preserving information between two cooperating
functions.  This will be useful for the adjustments I
need to make to materializeForSet to support safe
addressors.

I considered making this a SIL type category instead,
like $@value_buffer T.  This is an attractive idea because
it's generally better-typed.  The disadvantages are that:
- it would need its own address_to_pointer equivalents and
- alloc_stack doesn't know what type will be stored in
  any particular buffer, so there still needs to be
  something opaque.

This representation is a bit gross, but it'll do.

Swift SVN r23903
2014-12-13 01:27:12 +00:00
Chris Lattner
af1ea0b8f1 document @in_guaranteed.
Swift SVN r23868
2014-12-11 21:16:27 +00:00
Erik Eckstein
3b9805b246 Disallow cond_br with identical destinations.
It avoids generation of llvm phi nodes with identical predecessors and differing values.
This change replaces my previous fix of this problem in r23580, where I handled it in IRGen.

There were some discussions about it with the conclusion that it's better to just disallow such cond_br instructions in SIL.
It makes the life easier for some SIL optimizations which can't deal with cond_br with identical destinations.

The original radar is <rdar://problem/18568272> Swift compiler fails with "PHI node has multiple entries for the same basic block with different incoming values!"



Swift SVN r23861
2014-12-11 15:03:49 +00:00
Doug Gregor
5119580d5c Fix broken reST in SIL document.
Swift SVN r23726
2014-12-05 05:28:15 +00:00
John McCall
dd07c8ca10 Add 'mark_dependence', which indicates that an address
or pointer depends on another for validity in a
non-obvious way.

Also, document some basic value-propagation rules
based roughly on the optimization rules for ARC.

Swift SVN r23695
2014-12-04 22:38:09 +00:00
Mark Lacey
1b2d617157 Fix typo.
Swift SVN r23644
2014-12-03 06:08:04 +00:00
Dmitri Hrybenko
e2b974d3d6 docs: fix ReST warnings
Swift SVN r23051
2014-11-01 00:51:34 +00:00
Roman Levenstein
c8d180e660 Generalize the switch_int instruction into switch_value instruction, which may switch on arguments of builtin integer types or function types. The later is required for implementing a more efficient speculative devirtualizaiton implementation. Implement lowering of switch_value into LLVM code. In case of integer operands, it reuses LLVM's switch optimizations. Support for switching on function types is not yet bullet-proof and will be refined in the subsequent patches.
rdar://18508812

Swift SVN r23042
2014-10-31 22:55:56 +00:00