Commit Graph

38 Commits

Author SHA1 Message Date
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
Chris Lattner
f6e87dec54 Rework SILGen's emission of release_value to have it auto-merge into
retain_value instructions, just like we do for strong_retain/release.

This wraps up rdar://15889208, which is admittedly more of a moral 
victory than a practical one.


Swift SVN r15804
2014-04-02 16:39:53 +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
Doug Gregor
50a7d66112 SILBuilder: peephole 'metatype' instruction used only by a thick/ObjC conversion instruction.
The 'metatype' instruction can produce either a thick or Objective-C
metatype value for a class. Sometimes SILGen picks the "wrong" one,
and ends up converting the value directly, which is sub-optimal. Clean
this up in SILBuilder.

I didn't add a corresponding SILCombine optimization, nor did I add
this for class_metatype, because it seems unlikely that those will
occur in practice.


Swift SVN r14183
2014-02-20 23:39:44 +00:00
Joe Groff
b19cfb27ea Drop the context generic params from SILFunctionType.
SILFunctionType is now 100% context free!

Swift SVN r13775
2014-02-11 04:21:20 +00:00
Joe Groff
481fbb7b91 Drop the non-interface types from SILFunctionType.
There are some straggling references to the context generic param list, but nothing uses the non-interface param or result types anymore!

Swift SVN r13725
2014-02-09 22:39:01 +00:00
Joe Groff
0776c4b6b8 SIL: Reorient function type lowering toward interface types.
Lower types for SILDeclRefs from the interface types of their referents, dragging the old type along for the ride so we can still offer the context to clients that haven't been weaned off of it. Make SILFunctionType's interface types and generic signature independent arguments of its  Derive the context types of SILFunctionType from the interface types, instead of the other way around. Do a bunch of annoying inseparable work in the AST and IRGen to accommodate the switchover.

Swift SVN r12536
2014-01-18 19:42:02 +00:00
Joe Groff
b2f0b90ba2 SIL: Switch to SILFunctionType interface types in easy-to-reach places.
In nongeneric contexts, or contexts where we only care about the indirectness of parameters or have already substituted the generic parameters for a function, the interface types are interchangeable, so just switch over.

Swift SVN r12044
2014-01-08 04:48:29 +00:00
Chris Lattner
b689013ad3 fix comment header.
Swift SVN r11931
2014-01-06 18:00:30 +00:00
Chris Lattner
a30e8730f4 teach SILBuilder::emitStrongRelease that copyaddr and assign instructions
cannot decrement a retain count when they are initializations or of trivial
types.  This allows us to zap some retain/releases being emitted by silgen,
particularly when accessing self ivars.



Swift SVN r11019
2013-12-09 15:20:57 +00:00
Chris Lattner
510ed4ccfa Introduce a new use classifier: "Initialization". This allows us to
tag things known from SILGen to be initializers (e.g., copyaddrs with
the bit set) and when we analyze the DI properties for an assign, we
can move it to this classification.  This allows stuff that wants to
reason about the difference (e.g. the conditional destroy logic) to
do so precisely.


Swift SVN r10658
2013-11-22 06:17:32 +00:00
Chris Lattner
0e6bec9fb0 Enhance emitDestroyAddr to return the instruction it produces, if it does.
Swift SVN r10628
2013-11-21 07:18:31 +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
4968cc208b A couple of related changes:
- Enhance SILBuilder::emitStrongRelease to be smarter.
- Start using emitStrongRelease in type lowering, SILGen,
  CapturePromotion (replacing its implementation of the
  same logic), and MandatoryInlining (one more place)
- Rename the primitive createStrongRetain/ReleaseInst
  instructions to lose their suffix.
- Now that createStrongRetain/ReleaseInst are not special
  cases from the naming perspective, remove some special cases
  from DeserializeSIL and ParseSIL.
  


Swift SVN r10449
2013-11-14 02:21:27 +00:00
Chris Lattner
b2ac1db9f6 introduce a new helper to SILBuilder that emits a StrongRelease operation,
scanning up the local block to see if it immediately cancels a retain 
operation.

Use this in mandatory inlining to zap more retains and release.  Before
this patch, the result LogicValue allocation blocked this optimization,
preventing the partial_apply from being deleted from the case in 
rdar://15328833.




Swift SVN r10447
2013-11-14 01:50:28 +00:00
John McCall
2ed33e4ffa Make convenient accessors for getting a lowered SILType for
a struct/class field or a tuple element.

Make DefiniteInitialization traffic in SILTypes more.

Swift SVN r10055
2013-11-08 22:04:04 +00:00
Joe Groff
61360ba7a4 SIL: Remove ConvertCCInst.
Swift SVN r9577
2013-10-22 03:16:27 +00:00
Chris Lattner
a6cde9cd8d Add a convenience function to map a CanType+StructDecl to the mapped
CanType.  This doesn't really fit on SILBuilder, but until StructType 
and BoundGenericStructType are merged, this will do.


Swift SVN r9336
2013-10-14 23:42:41 +00:00
Joe Groff
8f68e1b68b SIL: Add create(Struct,Tuple)ElementAddr helpers that derive the element type.
To be consistent with create(Struct,Tuple)Extract.

Swift SVN r9138
2013-10-10 15:34:17 +00:00
Joe Groff
5650130518 SIL: Substitute struct field types when creating struct ops in passes.
The AST type of the VarDecl is incorrect for bound generic structs and needs to be substituted.

Swift SVN r9130
2013-10-10 04:35:57 +00:00
John McCall
b880e60100 Remove SILFunctionTypeInfo in favor of SILFunctionType.
We still don't actually use this as a type, however.

Swift SVN r9091
2013-10-09 20:55:55 +00:00
Chris Lattner
c6d7c2941e make the scan for copy_addr slightly stronger when emitting a destroy_addr.
Swift SVN r8969
2013-10-07 18:02:56 +00:00
Chris Lattner
607114f6c6 Introduce a new "emitDestroyAddr" function, which attempts to fold destroy_addr into
preceding copy_addr instruction when totally trivial.  Adopt this in SILGen, eliminating
a couple dozen destroy_addr instructions from the stdlib and producing more canonical SIL.


Swift SVN r8968
2013-10-07 17:47:17 +00:00
Stephen Lin
3f5c0dbf0e Update SILArgument::getModule(), SILBasicBlock::getModule() and SILInstruction::getModule() signatures to match SILFunction::getModule(), for consistency; standardize usage of SILFunction::getParent() to SILFunction::getModule().
Swift SVN r8932
2013-10-04 21:12:20 +00:00
Stephen Lin
2b509fc32c Use visitor to avoid O(N^2) behavior when getting destructured Swift argument types for computing partial apply result type
Swift SVN r8337
2013-09-17 17:16:14 +00:00
Stephen Lin
694f56e2a1 Implement helper to compute partial apply return type; insert convert_function as necessary where this type does not match the needed type
Swift SVN r8315
2013-09-17 00:39:17 +00:00
Stephen Lin
b0cdee2b9b Move SILBuilder::getTupleElementType and SILBuilder::getStructFieldType to SILBuilder.cpp
Swift SVN r8279
2013-09-16 18:19:14 +00:00
Anna Zaks
04b4901b79 [SIL] Split emitBlock() into 2 to remove dependency on construction of a NULL SILLocation.
Swift SVN r8015
2013-09-06 23:57:19 +00:00
Anna Zaks
1ba2554fb2 [SIL] Ensure that all loop branches have valid locations.
Also, change the location of "looping back to head" branch to point to the closing brace of the body, which is a more natural source location than the beginning of the enclosing loop statement.

Swift SVN r7989
2013-09-06 17:46:15 +00:00
Anna Zaks
4d7de376bb [SIL] Refactor splitBasicBlock() into splitBasicBlock and splitBasicBlockAndBranch
This API is more explicit and avoids relying on passing around empty SILLocation.
(No functional change.)

Swift SVN r7988
2013-09-06 17:46:12 +00:00
Chris Lattner
a864b8ea00 enhance the union retain/release implementations to split the block when
inserting a diamond into the middle of an existing block.  This fixes a
problem that manifests in memory promotion when lowering an assign.


Swift SVN r7917
2013-09-04 22:02:50 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
John McCall
d7b6009374 Introduce the concept of the "semantic" type of a lowered
type and audit a great deal of code to deal with it appropriately.

Spot fixes in a few other places.

Fixes rdar://14615768

Swift SVN r6879
2013-08-03 05:59:19 +00:00
Anna Zaks
ae94c8c48e [DCE] Propagate BB arguments when simplifying a conditional branch into unconditional one
Swift SVN r6819
2013-08-01 21:32:06 +00:00
John McCall
b6d49ea46d Give some dynamic behavior to TypeLowering and lay out
some groundwork for more customization.

Swift SVN r6799
2013-08-01 01:28:39 +00:00
John McCall
f46ffb3382 Shorten "TypeLoweringInfo" to "TypeLowering".
Swift SVN r6795
2013-08-01 01:28:34 +00:00
John McCall
325b86b82a Prepare SIL type lowering to create more expressive type-infos.
Swift SVN r6545
2013-07-24 04:58:49 +00:00
Joe Groff
8ac1bda817 SIL: Move retain/release/destroy helpers onto SILBuilder.
Add a convenience SILModule::getTypeLoweringInfo forwarder, and move the emitRetainRValue and emitReleaseRValue helpers from SILGenFunction to SILBuilder so they're more readily available to non-SILGen passes. Add an emitDestroyAddress helper that emits nothing, destroy_addr, or load + release based on the value semantics of the referenced type.

Swift SVN r6431
2013-07-21 18:39:56 +00:00