Commit Graph

53 Commits

Author SHA1 Message Date
Manman Ren
ae9f2e25ae [@semantics] add SemanticsAttr to SILFunction.
Enable SIL parsing and SIL serialization of semantics.

We add one more field to SILFunctionLayout for semantics. We should refactor
handling of attributes at SIL level, right now they are in SILFunction as bool
or std::string and in SIL serializer as a 1-bit field or an ID field.

rdar://17525564


Swift SVN r19434
2014-07-01 22:49:46 +00:00
Manman Ren
7667b829bb [noinline attribute] add noinline attribute.
Propagate it to SILFunction and use it in PerformanceInliner. We also serialize
and parse the attribute.

rdar://15882816


Swift SVN r19150
2014-06-24 23:07:45 +00:00
Adrian Prantl
b1a7a7af1b Reference-count inlined functions to keep them alive until we emit debug
info for them and generally clean up the inline scope handling a bit.
Fix the debug scope handling for all clients of SILCloner, especially
the SIL-level spezializers and inliners.
This also adds a ton of additional assertions that will ensure that
future optimization passes won't mess with the debug info in a way that
could confuse the LLVM backend.

Swift SVN r18984
2014-06-18 22:34:10 +00:00
Mark Lacey
c7d3c3cd01 Rename and move a function that checks for unbound generics.
In the short term this will also be used to determine if we can inline
generic functions.

Swift SVN r18972
2014-06-18 02:51:23 +00:00
Mark Lacey
0850bcc4d7 Make TypeSubstCloner take a substitution list directly.
Rather than calling getSubstitutions() in various places on the apply
that we are cloning the body of, pass the substitution list in
directly when creating the cloner.

This is not interesting for the generic specializer, but is important in
mandatory inlining when we go to inline an apply of a partial apply,
where we need to use the full list of substitutions for both.

Swift SVN r18951
2014-06-17 08:28:56 +00:00
Mark Lacey
904d73b71e Remove unused parameters to TypeSubstCloner ctor.
These are used by a helper in the generic specializer, but not
need for the cloner class itself.

Swift SVN r18848
2014-06-12 23:50:19 +00:00
Mark Lacey
70fdc6d9ed Make SpecializingCloner inherit from TypeSubstCloner.
This is mostly cleanup in TypeSubstCloner to make it possible to use
in the CRTP.

Swift SVN r18847
2014-06-12 23:50:19 +00:00
Michael Gottesman
d306d62d08 Remove unused anonymous namespace.
Swift SVN r18843
2014-06-12 22:36:08 +00:00
Bob Wilson
2df66cf8c4 Implement inline scopes for the performance inliner.
Mandatory-inlined (aka transparent functions) are still treated as if they
had the location and scope of the call site. <rdar://problem/14845844>
Support inline scopes once we have an optimizing SIL-based inliner

Patch by Adrian Prantl.

Swift SVN r18835
2014-06-12 19:48:43 +00:00
Mark Lacey
87e94268a6 Move TypeSubstCloner into its own file.
This will allow it to be used both by the generic specializer as well as
the inliner.

Swift SVN r18812
2014-06-11 23:23:01 +00:00
Mark Lacey
dcdcde8c10 Rename TypeSubCloner to TypeSubstCloner.
Swift SVN r18811
2014-06-11 23:22:57 +00:00
Mark Lacey
5d8323ceeb Move initCloned from TypeSubCloner to SpecializingCloner
Swift SVN r18802
2014-06-11 08:19:31 +00:00
Mark Lacey
dcf7d5cc3a Start refactoring type substitution cloning for use in inliner.
Add a new SpecializingCloner that will contain the
generic-specialization-specific functionality needed by that pass. This
inherits from TypeSubCloner, which I will move into a separate file in a
future commit after further refactoring.

Swift SVN r18791
2014-06-10 23:32:46 +00:00
Mark Lacey
b9ac148bc9 Small renaming of a couple members.
Swift SVN r18782
2014-06-10 19:15:30 +00:00
John McCall
fe3a7b0f5e When determining whether we can specialize a generic function,
check whether any of the substitutions are dependent rather
than checking whether the function's substituted type is
dependent.

This can't currently come up for user functions because Swift
doesn't permit type arguments to be given explicitly; hence a
dependent type argument will necessarily appear somewhere in
the substituted signature.  However, it's still possible in
the basic SIL model, and Joe's fix to default argument
initializers was just an obvious example.

Swift SVN r18768
2014-06-10 00:46:32 +00:00
Michael Gottesman
39841c3889 [mangler][specializer] When mangling ExistentialMetatypes or Metatypes, mangle in the representation of the metatype.
rdar://16937175

Swift SVN r18219
2014-05-16 22:28:30 +00:00
Michael Gottesman
d866316e04 [specializer] Teach the specializer how to handle indentity {unconditional_checked_cast,checked_cast_br} super_to_archetype.
This is working under the assumption that every class is in a certain
sense its own super class (or we are allowing it to be so for these
casts).

Swift SVN r18020
2014-05-13 20:15:31 +00:00
Michael Gottesman
0f758c5fad [specializer] Teach the specializer how to handle identity existential->archetype casts.
From discussions with Joe I thought that we were not doing this cast. I
am looking into now if the same thing can happen with super_to_archetype
(i.e. identity cast) is supported.

rdar://16892732

Swift SVN r17988
2014-05-13 01:46:24 +00:00
Joe Pamer
1e5b9116d4 More array casting work:
- Continue adding support for checked downcasts of array types (rdar://problem/16535104)
- Fix non-bridged array conversions post-r17868
- Fix rdar://problem/16773693
- Add tests for NSArray coercions to and from Array<T>

Swift SVN r17957
2014-05-12 20:49:42 +00:00
Michael Gottesman
9b1f4b6517 [specializer] Do not replace generic calls in transparent functions to shared specialized functions.
This eliminates the possibility of references to shared functions
without bodies from being exposed by the mandatory inliner.

This does not affect performance in any manner since after mandatory
inlining, we can always specialize in the function that was just inlined
into.

rdar://16809311

Swift SVN r17803
2014-05-09 21:28:39 +00:00
Michael Gottesman
664c6a0637 Add FIXME to specializer to make it handle type aliases correctly by specializing all self derived types.
Swift SVN r17255
2014-05-02 17:26:30 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +00:00
Michael Gottesman
621f89d267 [specialization] Teach the specializer how to handle checked_cast_br correctly.
rdar://16490450.

Swift SVN r17013
2014-04-29 05:01:59 +00:00
Michael Gottesman
02bdf346bd [specialization] Teach the specializer how to create specialized
protocol conformances.

Without this we can not look up protocol conformances correctly after
specialization if the devirtualization applies to the relevant
specialized type.

Swift SVN r16873
2014-04-26 06:50:59 +00:00
Michael Gottesman
888f72cbbf [specializer] Teach the specializer how to specialize partial apply insts.
<rdar://problem/16696421>

Swift SVN r16871
2014-04-26 04:39:39 +00:00
Michael Gottesman
c9621406ba [specialization] It is incorrect to call getOpConformance on a conformance we already specialized "by hand".
Swift SVN r16766
2014-04-24 19:41:19 +00:00
Andrew Trick
f58ebbc251 Add a global_init attribute to SILFunction.
The implied semantics are:
- side-effects can occur any time before the first invocation.
- all calls to the same global_init function have the same side-effects.
- any operation that may observe the initializer's side-effects must be
  preceded by a call to the initializer.

This is currently true if the function is an addressor that was lazily
generated from a global variable access. Note that the initialization
function itself does not need this attribute. It is private and only
called within the addressor.

Swift SVN r16683
2014-04-23 01:09:47 +00:00
Michael Gottesman
40cbdc31b9 [specialization] Teach the specializer how to specialize existential->archetype and super->archetype unconditional_checked_casts.
<rdar://problem/16490450>

Swift SVN r16350
2014-04-15 01:05:08 +00:00
Michael Gottesman
e74f40e5bb [specialization] Teach the specializer how to specialize unconditional_checked_cast concrete_to_archetype and archetype_to_concrete.
I am handling checked_cast_branch in a later commit due to a SILGen
issue I am running into.

rdar://16490450

Swift SVN r16309
2014-04-14 09:52:18 +00:00
Mark Lacey
1452d24671 Small cleanup: Remove unnecessary calls to getDef(), mostly in dyn_cast<>(...).
Swift SVN r16235
2014-04-11 23:05:16 +00:00
Nadav Rotem
ff5c3f0825 Fix an obvious typo that I found while debugging somethig else. createdFunc was set to false twice on both sides of the branch.
Swift SVN r16231
2014-04-11 21:57:04 +00:00
Adrian Prantl
47bf136af5 More assertion cleanups. Thanks, Joe!
Swift SVN r15842
2014-04-02 23:06:13 +00:00
Adrian Prantl
5385d4e7a7 Clean up a slightly wrong assertion.
<rdar://problem/16499612> assert building Foundation with SWIFT_ASSERTS=NO

Swift SVN r15840
2014-04-02 22:54:35 +00:00
Michael Gottesman
c15862bc1a [specializer] Fix a bug I noticed on inspection. Converted the checked_cast_branch test to a .swift to get around parsing issues that will come up in the next bit of commits.
Swift SVN r15827
2014-04-02 20:46:57 +00:00
Michael Gottesman
2dcc1e7a8e Remove unnecessary Resolver argument from SILType::isSuperclassOf since SILTypes are only used after type checking.
Thanks Joe!

Swift SVN r15759
2014-04-01 22:55:43 +00:00
Michael Gottesman
1e9a6099a2 [specializer] Teach the specializer how to handle unconditional_checked_casts, checked_cast_branches that were originally archetype -> archetype but as a result of specialization are now a different sort of cast or a redundent cast.
I am preparing patches for the other cases, but I think this should unblock
DaveA.

rdar://16490450

Swift SVN r15757
2014-04-01 22:42:20 +00:00
Nadav Rotem
6359cf0a35 Refactor hasUnboundGenericTypes. NFC.
Swift SVN r15381
2014-03-23 06:49:54 +00:00
Michael Gottesman
3ad6f33202 Teach the generic specializer how to create SILWitnessTable declarations if a specialized conformance does not have a witness table.
This also teaches IRGen not to emit WitnessTable declarations. This
causes them to be left as unknown symbols in the resulting executable.

Swift SVN r15361
2014-03-22 05:05:47 +00:00
Michael Gottesman
fbfd9778d4 [deserialization] Teach generic specializer how to link functions.
Swift SVN r15095
2014-03-14 23:46:20 +00:00
Michael Gottesman
13b74af686 [specializer] Do not use the old instructions location when cloning. Instead use getOpLocation.
Swift SVN r15025
2014-03-14 04:35:30 +00:00
Joe Groff
a404b0cd49 Rework Substitution::subst not to depend on the meaningless 'Archetype' field of Substitutions.
Pass in the context generic parameters that correspond to the substitution vector in Substitution::subst. When we build the type substitution map, also collect the conformances from the substitutions into a map we can use to fill in those conformances in substituted substitutions where necessary, without relying on the '.Archetype' field.

Swift SVN r14964
2014-03-12 20:29:46 +00:00
Michael Gottesman
f1c9127a89 [serializer] Add some debug messages to the deserializer.
Swift SVN r14859
2014-03-10 01:17:18 +00:00
Michael Gottesman
3cc621b188 Remove trailing whitespace. NFC.
Swift SVN r14858
2014-03-10 01:17:17 +00:00
Chris Lattner
001c1890e5 put all the SIL*Transform classes in anonymous namespaces, there is
no need for their symbols to be exported out of their implementation
file.


Swift SVN r14714
2014-03-06 01:49:53 +00:00
Joe Groff
88b6efcc43 Rename ArchetypeMethodInst -> WitnessMethodInst more thoroughly.
Swift SVN r14501
2014-02-28 06:41:18 +00:00
Joe Groff
59d2a169f6 SIL: Rename 'archetype_method' to 'witness_method'.
It has been generalized to get a witness out of an arbitrary protocol conformance, not just for archetypes.

Swift SVN r14497
2014-02-28 05:09:11 +00:00
Joe Groff
7b28da3488 SIL: Always substitute SILFunctionTypes using their interface types.
Have SILType::subst and SILFunctionType::subst always visit the interface types of a SILFunctionType. Fix up some problems in the specializer this exposed by having it correctly apply interface type substitutions to the function type of a specialized function and contextualized substitutions to the body.

Swift SVN r13714
2014-02-09 20:23:07 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Nadav Rotem
3227f250cc Reindent the block.
Swift SVN r13648
2014-02-07 19:37:37 +00:00
Nadav Rotem
32d31122ff Generic specialize recursive calls.
With this change we are able to specialize generic recursive functions.
There are a few recursive generic functions in our String representation
and in qsort.

This patch accelerates all of the String benchmarks.



Swift SVN r13643
2014-02-07 19:17:30 +00:00