Commit Graph

887 Commits

Author SHA1 Message Date
Joe Groff
584009d27e SIL: Remove copy_value's result.
We won't have any types where copying has an effect on the bit pattern (except for blocks, which need special handling anyway), and copy_value having a result makes optimizations more complex, so remove it.

Swift SVN r15640
2014-03-30 03:40:45 +00:00
Joe Groff
afd59130f0 SIL: Add a FixLifetime instruction.
This will be a signal to ARC optimization, RVO, and other lifetime-affecting optimizations that they should not shorten the lifetime of a value past a certain point. We need this for C pointer bridging. This adds the instruction, but does not add any knowledge of it to the ARC optimizers.

Swift SVN r15601
2014-03-29 02:50:34 +00:00
Chris Lattner
ce7bc53f50 implement <rdar://problem/16310561> Property vtables not set up correctly
This switches property/subscript dispatch to use virtual dispatch instead of static
dispatch.  This currently only works for computed properties (and subscripts of 
course), not stored ones yet.

Long story short, this:

class Base {
  subscript() -> Int {
    return 42
  }
}

class Derived : Base {
  @override
  subscript() -> Int {
    return 9
  }
}

var a : Base = Derived()
print(a[])

now prints 9 instead of 42.



Swift SVN r15142
2014-03-17 16:37:37 +00:00
Adrian Prantl
d1fed3b520 silence warnings
Swift SVN r14921
2014-03-11 16:55:15 +00:00
Mark Lacey
c4ef5d3e9a Coerce the self argument of @objc methods to the appropriate type.
When lowering @objc entrypoints, we need to set the argument explosion
to a value with the proper type for use within the body of the function.

Change r13931 worked around the lack of proper entrypoint lowering by
adding a cast at a use site. Now that this is fixed we can remove that
work-around.

Fixes <rdar://problem/16075395>.

Swift SVN r14666
2014-03-05 00:51:32 +00:00
Mark Lacey
2a2b0a068e Support (non-byval) indirect parameters.
Also add some ABI test output for ARM64.

Resolves the core issue with <rdar://problem/16135769>.

Swift SVN r14658
2014-03-04 22:41:16 +00:00
Doug Gregor
82c1ba2e29 Remove peer_method instruction; we're no longer using it.
Swift SVN r14599
2014-03-03 17:13:06 +00:00
Michael Gottesman
4c3ae242d9 Disable debug info for "*_external" linkage functions and an assertion on certain SILLocations to avoid the fact we don't serialize DebugScopes.
The specific SILLocations are: SILFileKind, InlineKind, and
MandatoryInlineKind.

This was done in coordination with Adrian Prantl.

Swift SVN r14580
2014-03-03 03:15:36 +00:00
Dmitri Hrybenko
be7759b149 Track uptstream LLVM API change: llvm::next() was removed, use std::next() instead
Swift SVN r14572
2014-03-02 13:32:30 +00:00
Doug Gregor
1d733d5646 IR generation for alloc_ref_dynamic.
Swift SVN r14561
2014-03-01 22:33:01 +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
Adrian Prantl
8948375658 Debug Info: Cleanup: Remove debug scope from DebugTypeInfo.
Swift SVN r14548
2014-03-01 00:50:50 +00:00
Adrian Prantl
990ad90c56 Debug info: Emit the object type for variables that reside in an alloca.
rdar://problem/16076982.

Swift SVN r14535
2014-02-28 20:53:05 +00:00
Joe Groff
67ca7ce1e9 SIL: Rename 'protocol_metatype' to 'existential_metatype'.
It's not forming the metatype for the protocol type (exists t: P. t).metatype, it's forming the existential of a metatype of a conforming type, exists t: P. (t.metatype).

Swift SVN r14520
2014-02-28 16:14:00 +00:00
Joe Groff
88b6efcc43 Rename ArchetypeMethodInst -> WitnessMethodInst more thoroughly.
Swift SVN r14501
2014-02-28 06:41:18 +00:00
Joe Groff
9424de6787 SIL: Rename 'archetype_metatype' to 'value_metatype'.
Since it can grab a metatype from any value now.

Swift SVN r14500
2014-02-28 06:33:05 +00:00
Joe Groff
545f173507 SIL: Fold 'archetype_metatype' and 'class_metatype'.
Having one instruction to get the dynamic metatype of a (non-existential) value makes more sense from a generic specialization standpoint and should stave off inevitable crashers when archetype_metatypes get specialized. protocol_metatype remains separate because metatype existentials are more interesting.

Swift SVN r14499
2014-02-28 06:32:58 +00:00
Joe Groff
855ea99063 SIL: Combine 'archetype_ref_to_super' and 'upcast'.
We were wantonly applying 'upcast' to archetypes in some cases, and really, that's OK, since these instructions do the same thing (and generic specialization could turn archetype_ref_to_super into upcast). Make everyone's life easier by folding archetype_to_super into upcast. Fixes <rdar://problem/16192324>.

Swift SVN r14496
2014-02-28 04:33:18 +00:00
John McCall
3d5d8fdc03 Resilience expansion is really an aspect of a SILDeclRef.
We should also remove it from IRGen's Explosion API; IRGen
should always use maximal explosion, and SILGen will tell us
whether or not we need to put that in memory somewhere.
But that can be a later commit.

Swift SVN r14242
2014-02-21 23:28:43 +00:00
Doug Gregor
fb6806abe5 Bridge 'self' for class methods.
The Objective-C entry point for a class method expects 'self' to be an
Objective-C metatype. Bridge it accordingly.


Swift SVN r14160
2014-02-20 19:10:55 +00:00
Doug Gregor
38cad0c284 Lower metatype and class_metatype to IR based on the requested representation.
Make IRGen just a little bit dumber: rather than inferring whether we
need the Swift or Objective-C metatype based on the uses of that
metatype, produce the metadata in the representation requested by the
'metatype' or 'class_metatype' instruction. SILGen will eventually
need to get smarter about asking for the representation it wants.


Swift SVN r14117
2014-02-20 00:31:24 +00:00
Doug Gregor
27ae27bf04 Start using objc_class* to describe Objective-C class metatypes in IRGen.
Swift SVN r14099
2014-02-19 21:24:00 +00:00
Doug Gregor
3182cd3910 Introduce thick/Objective-C metatype conversion instructions.
Introduce the SIL instructions thick_to_objc_metatype and
objc_to_thick_metatype to convert between the 'thick' and
'Objective-C' representations of a metatype. Most of this code is
trivial support code for these conversions: printing, parsing,
(de-)serialization, etc., for which testing will come online in
subsequent patches or is incidental in other tests.

Lower Objective-C metatype values down to objc_class* at the IR level
and implement IRGen support for these SIL instructions. SIL-only test
case at the moment because SILGen never creates these instructions.



Swift SVN r14087
2014-02-19 18:20:21 +00:00
Joe Groff
bca066498f IRGen: Emit calls into blocks.
Add a 'Block' ExtraData kind, and teach IRGen how to pull the invocation pointer out of a block structure and pass the block object in the right place.

Swift SVN r13940
2014-02-15 08:17:09 +00:00
Chris Lattner
bd8323dff0 Add an irgen hack fix the rest of rdar://16006333 - observing properties don't work in @objc classes
This is a hack in that the bitcast it introduces shouldn't be needed, I've filed
rdar://16006333 to track a proper fix for this when Mark gets back.



Swift SVN r13931
2014-02-14 23:44:43 +00:00
Doug Gregor
cf5aaa2112 Properly extract the archetype type from open_existential[_ref] in IRGen.
Swift SVN r13897
2014-02-14 03:46:25 +00:00
Doug Gregor
2134072285 Split open_existential[_ref] out as their own instructions.
Riding off of project_existential[_ref] was convenient, but the
resuls are used quite differently. Note that open_existential[_ref]
still don't print/parse reasonably yet.



Swift SVN r13878
2014-02-13 23:42:23 +00:00
Mark Lacey
112e5c1dc2 Remove obsolete comments.
Swift SVN r13865
2014-02-13 09:27:10 +00:00
Mark Lacey
df975185ac Handle padding arguments in C/ObjC entrypoints and calls.
Swift SVN r13864
2014-02-13 08:49:31 +00:00
Mark Lacey
8fd86aa79b Only coerce when necessary when lowering C/ObjC entrypoints.
This avoids storing and then loading arguments when the ABI type matches
the type used in the body of the function. This is important for types
like a boolean type represented as i1 where the storage type differs.

Fixes <rdar://problem/16040488>.

Swift SVN r13844
2014-02-12 23:37:04 +00:00
Chris Lattner
3f7d3877a4 Re-commit r13836 with more correctness this time:
Sink the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down to
AbstractStorageDecl.  NFC.



Swift SVN r13842
2014-02-12 22:49:47 +00:00
Mark Lacey
525c9323cc Revert "since the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down"
This reverts commit r13836, since it broke the build.

Swift SVN r13839
2014-02-12 20:59:24 +00:00
Chris Lattner
c23185d9ba since the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down
to AbstractStorageDecl, NFC.


Swift SVN r13836
2014-02-12 19:16:40 +00:00
Mark Lacey
70fa0dead0 Select ABI types for all arguments of a C/ObjC function together.
Updates to signature expansion, entrypoint lowering, and callsite
lowering so that each selects the ABI types for all arguments at once
rather than an argument at a time (as well as considering whether the
return value is returned indirectly). This is required to get the
correct behavior in cases where we run out of argument registers and
need to pass arguments as indirect byvals.

This is mostly just refactoring existing code to move loops inside inner
functions as well as dealing with return values at the same time as
arguments.

Swift SVN r13781
2014-02-11 06:45:53 +00:00
Doug Gregor
12c064d501 IR generation for DynamicSelf method invocations on existentials.
When projecting an existential into an opened archetype, bind the
archetype with metadata and witness tables extracted from the
existential. Tweak SILGen so that it doesn't destroy the opened
archetype value an extra two times.

Use an executable testcase to ensure end-to-end operation, because we
still don't have a parsable form existential projection to opened
archetype instructions.



Swift SVN r13755
2014-02-10 18:47:24 +00:00
Joe Groff
7275b2f34c IRGen: Pass in the debug DeclContext when building debug info for boxes.
So we don't crash when emitting debug info for a box of archetype type.

Swift SVN r13721
2014-02-09 22:25:57 +00:00
Joe Groff
05daca8e79 IRGen: Use interface types to implement the PolymorphicConvention.
Refactor the base PolymorphicConvention implementation to work using generic signatures and dependent types instead of GenericParamLists and archetypes, using an ArchetypeBuilder to produce representative archetypes as a convenience when we need to consider all of the requirements attached to a dependent type. In EmitPolymorphicParameters, map the dependent types into context to resolve the archetypes that should be bound in the body of the function.

Swift SVN r13685
2014-02-08 21:04:15 +00:00
Mark Lacey
660bb20909 Select correct IR types for direct arguments to C/@objc functions.
Reapply r13532 fixes for dealing with arguments that should be exploded
for C/Obj-C functions.

This gets us a bit closer to properly generating the correct types for
arguments. The remaining piece is generating all the argument types at
once rather than one at a time, which also requires being able to always
generate Clang types for the Swift types we see in the signatures of
these functions.

Swift SVN r13638
2014-02-07 18:04:45 +00:00
Adrian Prantl
bacd2d3c04 Debug info: Fix the locations for branches in case statements.
<rdar://problem/15899195> Step from a case the middle of a switch goes to the beginning of the containing function

Swift SVN r13623
2014-02-07 02:37:36 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +00:00
Mark Lacey
d335817783 Revert "Generate arguments with the correct ABI types for C/Obj-C functions."
This reverts commit r13532 which broke the build.

Swift SVN r13547
2014-02-06 02:07:17 +00:00
Mark Lacey
fd8e10fa68 Generate arguments with the correct ABI types for C/Obj-C functions.
This gets us a bit closer to properly generating the correct types for
arguments. The remaining piece is generating all the argument types at
once rather than one at a time.

That part cannot happen until we can always generate Clang types for
the Swift types we see in the signatures of these functions.

Swift SVN r13532
2014-02-06 01:06:32 +00:00
Mark Lacey
0d62463ce3 Revert "Refactor argument emission for apply. NFC."
This was r13282, and it turned out to be unnecessary.

Swift SVN r13490
2014-02-05 18:44:35 +00:00
Chris Lattner
7532213f4a simplify the SIL string_literal instruction to only produce a single value,
which is the address of the string data.  Have SILGen compute and produce the
isASCII bit as an integer literal, and remove the logic from IRGen.

This overall approach is simpler and enables better SIL-level optimizations.


Swift SVN r13363
2014-02-03 19:10:37 +00:00
Mark Lacey
03d5cb233f Refactor argument emission for apply. NFC.
Split out argument emission into a function that handles calling into
Swift calling convention functions and a function that handles
foreign ("external") calling conventions.

The emission for foreign calling conventions simply falls back on the
one for Swift calling conventions at the moment, i.e. there is no change
in behavior yet.

Swift SVN r13282
2014-02-01 02:36:38 +00:00
Mark Lacey
52ae907e5d Remove unused SILValue.
Swift SVN r13209
2014-01-31 09:41:07 +00:00
Joe Groff
53ed008acb IRGen: Add an "unimplemented" error when trying to call ObjC blocks.
Beats crashing.

Swift SVN r13083
2014-01-29 01:32:29 +00:00
Adrian Prantl
0b40f0bda3 Debug info: Use a small dense map to keep track of argument numbers.
Swift SVN r12872
2014-01-23 19:46:33 +00:00
Adrian Prantl
7468054191 Debug info: Emit O0 shadow copies more consistently for (most) debuggable
values.

Swift SVN r12803
2014-01-22 22:42:07 +00:00
Adrian Prantl
69c58421ec Debug info: emit alloca shadow copies for DebugValues at -O0.
<rdar://problem/15849532> iteration variables in "for X in Y" statements don't have debug information

Swift SVN r12675
2014-01-21 23:58:37 +00:00