Commit Graph

6634 Commits

Author SHA1 Message Date
Doug Gregor
fdcbfcf5a2 Stop using LLVM_EXPLICIT.
It's gone from LLVM trunk, and all our compilers support it.

Swift SVN r25312
2015-02-16 17:39:03 +00:00
Justin Bogner
59bb06b0fb InstrProf: SIL-level coverage mapping and lowering to LLVM
The adds the sil_coveragemap construct to SIL and the needed IRGen to
turn these into LLVM's coverage maps.

Swift SVN r25210
2015-02-12 00:28:39 +00:00
Joe Groff
96303f4c7f SIL: Factor the vtable override logic from SILGen into a method on SILDeclRef.
rdar://problem/19514920 is caused by a disagreement between IRGen and SILGen about which SILDeclRefs override vtable slots. Factor out the somewhat-hairy code in SILGen to a place IRGen will be able to share it. NFC yet.

Swift SVN r25063
2015-02-07 02:01:37 +00:00
Michael Gottesman
18d6f3cc42 Add small TODO. NFC.
Swift SVN r25047
2015-02-06 21:59:50 +00:00
Arnold Schwaighofer
650b4021f2 ApplyInst: Add asserts to make sure we do have a self argument
Swift SVN r25031
2015-02-06 01:23:42 +00:00
Michael Gottesman
59a1db1933 [silfunction] Add helper for returning arguments of a SILFunction.
Swift SVN r25005
2015-02-05 19:11:34 +00:00
Erik Eckstein
9dfd349faf Add a new Thunk-flag in SILFunction which specifies that a function is a thunk.
This will have an effect on inlining into thunks.
Currently this flag is set for witness thunks and thunks from function signature optimization.
No change in code generation, yet.



Swift SVN r24998
2015-02-05 16:45:05 +00:00
Arnold Schwaighofer
d1ec4772b4 ApplyInst: Add API to get an argument operand as a reference
This is similar to UnaryInstructionBase's getOperandRef(). Sometimes, we want to
store a pointer to an operand in a temporary data structure such as a visited
set.

Swift SVN r24958
2015-02-04 16:39:12 +00:00
Jordan Rose
014fd87928 Treat private type declarations as "hidden" in SIL (rather than public).
Easy cut down on exported symbols. Unless a private type is referenced in
an inlineable function, there's no way to generate a reference to it
outside of the current file, except in the debugger. (That last bit is why
we can't use fully private linkage, which would keep the symbol out of the
symbol table completely.)

We should be doing this for "internal" declarations as well, but the
standard library /does/ have references to internal types in inlineable
functions, and also has tests that directly access these types.

Swift SVN r24838
2015-01-30 03:54:04 +00:00
Michael Gottesman
359d67274e [closure-spec] Add support for propagating thin_to_thick_function closures.
<rdar://problem/18995320>

Swift SVN r24770
2015-01-28 01:36:38 +00:00
Michael Gottesman
0ac649d87b [proj-tree] Use a passed in BumpPtrAllocator instead of SmallVector for memory.
Previously I was using a large SmallVector to create Nodes for the
ProjectionTree. This created an issue when the SmallVector would convert
from small to large representation in the middle of a method on an
object that is stored in the SmallVector. Thus the 'this' pointer will
be invalidated and all sorts of fun times will occur.

I switched now to using a BumpPtrAllocator which is passed into the tree
and used in FunctionSignatureOptimization for all projection trees.

<rdar://problem/19534462>

Swift SVN r24706
2015-01-24 09:12:50 +00:00
Joe Groff
842d8aee03 Recommit r24666, r24667 with a fix for Optional object reference variance.
Give our assumption that T: class and Optional<T> are ABI-compatible a pass.

Swift SVN r24677
2015-01-23 04:15:34 +00:00
Dmitri Hrybenko
e90e1c6ab5 Revert "SIL verifier: Require convert_function not to change function ABI."
This reverts commit r24666.  It broke the performance benchmarks.

Swift SVN r24672
2015-01-23 03:09:54 +00:00
Joe Groff
67009e492c SIL verifier: Require convert_function not to change function ABI.
Write up a requireABICompatibleFunctionTypes check to make sure two function types share the same ABI. The real target here is to be able to apply this to vtable entries in order to uncover variance bugs like rdar://problem/19321484, but convert_function is a convenient testbed.

Swift SVN r24666
2015-01-23 01:15:00 +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
Mark Lacey
6170bbb0ed Minor code clean-up.
Primarily replacing getParent()->getParent() with getFunction().

Swift SVN r24596
2015-01-21 06:35:13 +00:00
Michael Gottesman
c4e6fb5f5f [demangler] Teach the remangler how to handle funcsig nodes and print out values when performing string demangling.
Swift SVN r24507
2015-01-19 09:53:12 +00:00
Michael Gottesman
897325b096 Codebase Gardening. NFC.
1. Eliminate unused variable warnings.
2. Change field names to match capitalization of the rest of the field names in the file.
3. Change method names to match rest of the file.
4. Change get,set method for a field to match the field type.

Swift SVN r24501
2015-01-19 00:34:07 +00:00
Michael Gottesman
3d28921607 Add pass ExternalDefsToDecls that changes all available_external functions into declarations.
This is useful to ascertain how much code size comes from available_external functions.

Swift SVN r24471
2015-01-16 03:17:53 +00:00
Erik Eckstein
c2776c455b Rename SILBasicBlock::getID() -> getDebugID()
Swift SVN r24321
2015-01-09 19:37:03 +00:00
Erik Eckstein
a2f78d768f Add SILBasicBlock::getID() for dumping the block index in debug output.
Swift SVN r24308
2015-01-09 17:04:29 +00:00
Chris Lattner
f460716430 add a SILBasicBlock::removeWithParent method with the obvious semantics
(following LLVM IR), NFC.


Swift SVN r24298
2015-01-09 05:33:32 +00:00
Erik Eckstein
c857f56d93 Allow inlining of recursive functions.
Swift SVN r24277
2015-01-08 13:57:57 +00:00
Roman Levenstein
77fa044c8c Rename lookUpSILFunctionFromVTable into lookUpFunctionFromVTable. NFC.
Swift SVN r24265
2015-01-08 04:05:28 +00:00
Michael Gottesman
ab838481dd Move SILBasicBlock::getSingleSuccessor from the middle of the predecessor code into the successor code. Also add a const version of it.
Swift SVN r24164
2015-01-01 14:34:49 +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
bf43c5cd49 move getDeclCaptureKind to be a method on TypeConverter and simplify a bunch of
clients of CaptureKind by having getDeclCaptureKind map address-only lets onto
Box or NoEscape, instead of having all the clients do it.


Swift SVN r24136
2014-12-24 00:23:24 +00:00
Chris Lattner
d59a2d0490 Teach SILGen about NoEscape:
- Introduce a new 'noescape' CaptureKind and have getDeclCaptureKind()
   use it for by-address captures in noescape closures.
 - Lower NoEscape captures to a simple inout pointer instead of to a
   pointer + refcount.

This includes a test of the SILGen produced code itself along with an
integration test that shows that this enables inout deshadowing to remove
shadows that would otherwise have to be preserved due to closures capturing
them.

This can be more aggressive for address-only let constants, but that will
wait for a follow-up patch.



Swift SVN r24135
2014-12-24 00:03:13 +00:00
Chris Lattner
58e0efc345 Enhance getDeclCaptureKind() to take the closure that is capturing the
given decl, and plumb the information down to it.  NFC since the argument
is currently dead.



Swift SVN r24132
2014-12-23 23:08:38 +00:00
Erik Eckstein
5cffa73bbd Refactoring: extract some code of the inliner to the projection classes.
Michael, thanks for your comments!

This also adds support for tuples and enums in Projection::getOperandForAggregate().



Swift SVN r24112
2014-12-23 16:26:08 +00:00
Erik Eckstein
6d9a7a1045 Helper class for visiting basic blocks in dominance order.
It uses a worklist-based algorithm. In contrast to a recursive traversal algorithm,
it cannot cause a stack overflow for very deep dominator trees.



Swift SVN r24107
2014-12-23 09:09:34 +00:00
Andrew Trick
d84feff62b Add a changeBranchTarget helper.
I refactored, generalized, and cleaned up an existing helper.

I also removed hard-coded assumptions about successor indices.
There's no point giving CondBranch a true/false API if we don't respect it.

Swift SVN r24001
2014-12-18 01:26:45 +00:00
Andrew Trick
0899d2a2bc Resolve a visual name conflict.
Swift SVN r24000
2014-12-18 01:26:43 +00:00
John McCall
b6eb086af8 Add a rather hacky builtin function for constructing
a materializeForSet callback from a closure.

Swift SVN r23993
2014-12-17 22:23:26 +00:00
John McCall
5c8fbc704c Add SIL instructions to convert between thin functions
and raw pointers.

Swift SVN r23992
2014-12-17 22:23:15 +00:00
Michael Gottesman
c0b5b94cfc Move SelectValueInst to where the rest of the Select*Inst instructions are, not next to the switch instructions. NFC.
Swift SVN r23934
2014-12-15 05:22:40 +00:00
Michael Gottesman
b2e766ac04 [aa] Add SILArgument::getIncomingValue({unsigned, SILBasicBlock *}) to get an individual incoming value.
This rounds out the getIncomingValues. I am going to use these routines
when I teach AA about PHI nodes.

Swift SVN r23933
2014-12-15 05:22:40 +00:00
Michael Gottesman
7e39f33f98 [mangle] Include a pass id in the mangling, just to be careful.
I am starting to reuse manglings for different passes. I want to make sure that
when we reuse functions we actually get a function created by the same pass.

Swift SVN r23924
2014-12-14 10:29:11 +00:00
Michael Gottesman
45b5389854 [mangle] Add support for mangling CapturePromotion specializations and wire it up.
<rdar://problem/19216281>

Swift SVN r23923
2014-12-14 08:17:32 +00:00
Michael Gottesman
c4f3043280 [mangle] Specify sizes for various specialization enums and make the underlying type configurable via a using statement.
Also added comments about how various parts of the enum are
used (i.e. options vs option sets).

Swift SVN r23922
2014-12-14 08:17:31 +00:00
Michael Gottesman
1d637f510b [mangle] Convert FunctionSignatureSpecializationMangler::setArgumentClosureProp to use an ArgNo index instead of SILArgument *.
This matches the rest of the methods on FunctionSignatureSpecializationMangler.

Swift SVN r23921
2014-12-14 08:17:30 +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
Erik Eckstein
14af3a57e8 Enable elimination of dead methods which are in classes of higher visibility.
The underlying problem is that e.g. even if a method is private but its class is public, the method can be referenced from another module - from the vtable of a derived class.
So far we handled this by setting the SILLinkage of such methods according to the visibility of the class. But this prevented dead method elimination.
Now I set the SILLinkage according to the visibility of the method. This enables dead method elimination, but it requires the following:
1) Still set the linkage in llvm so that it can be referenced from outside.
2) If the method is dead and eliminated, create a stub for it (which calls swift_reportMissingMethod).



Swift SVN r23889
2014-12-12 17:35:40 +00:00
Michael Gottesman
1e63e0e22d [mangle] Add support for mangling dead, owned2guaranteed, and sroa args. Wire up function sig opts.
Now all SIL function specialization passes use the new mangling infrastructure.
Lets keep it that way for future passes as well. = ).

Implements:
<rdar://problem/18831609>

Fixes:
<rdar://problem/19065735>
<rdar://problem/18906781>
<rdar://problem/18956916>

Swift SVN r23859
2014-12-11 05:51:26 +00:00
Michael Gottesman
185d9aaafd [mangle] Add support for mangling constant propagated specializations and wire CapturePropagation to use it.
I also fixed a few bugs in the mangling that this exposed.

Swift SVN r23858
2014-12-11 03:22:07 +00:00
John McCall
3b4e0d307e Intrinsic support for pinning.
Using the intrinsics is obnoxious because I needed them
to return Builtin.NativeObject?, but there's no reasonable
way to safely generate optional types from Builtins.cpp.
Ugh.

Dave and I also decided that there's no need for
swift_tryPin to allow a null object.

Swift SVN r23824
2014-12-10 00:52:48 +00:00
Chris Lattner
811735657f comment fix, NFC.
Swift SVN r23822
2014-12-10 00:11:40 +00:00
Michael Gottesman
355f791621 [mangle] Add support for function signature specialization mangling and teach closure specialization how to use it.
Swift SVN r23816
2014-12-09 23:21:08 +00:00
Michael Gottesman
4d48d2aaae [mangle] Add initial code for SIL specializations manglings and refactor Generic Specialization mangling code to there from the pass itself.
This is apart of creating the infrastructure for creating special manglings for
all of the passes that we specialize. The main motiviations for this
infrastructure is:

1. Create an easy method with examples on how to create these manglings.
2. Support multiple specializations. This is important once we allow for partial
specialization and can already occur if we perform function signature
optimizations on specialized functions.

The overall scheme is as follows:

_TTS<MANGLINGINFO>__<FUNCNAME>

Thus if we specialize twice, the first specialization will just be treated as
the function name for the second specialization.

<MANGLINGINFO> is defined as:

_<SPECIALIZATIONKINDID>_<SPECIALIZATIONUNIQUEINFO>

Where specialization kind is an enum that specifies the specific sort of
specialization we are performing and specialization unique info is enough
information to ensure that the identity of the function is appropriately
preserved.

Swift SVN r23801
2014-12-09 02:53:05 +00:00