Commit Graph

19 Commits

Author SHA1 Message Date
Slava Pestov
b9951ade1b SIL: Rename some identifiers, NFC
"VTableLookupTable" just doesn't look right to me.
2016-02-04 17:34:55 -08:00
Doug Gregor
7c0e087cd5 [SIL] Extend the string_literal instruction with an 'objc_selector' encoding.
As part of SE-0022, introduce an 'objc_selector' encoding for string
literals that places the UTF-8 string literal into the appropriate
segment for uniquing of Objective-C selector names.
2016-01-27 13:57:40 -08:00
Erik Eckstein
74d44b74e7 SIL: remove SILValue::getDef and add a cast operator to ValueBase * as a repelacement. NFC. 2016-01-25 15:00:49 -08:00
Roman Levenstein
696aad7582 [sil-global-opt] Teach GlobalOpt to handle alloc_global
Global let propagation works again with this change. The corresponding test-case is enabled again.

rdar://24229640
2016-01-20 16:33:58 -08:00
Slava Pestov
046606a8f4 SIL: Add a new alloc_global instruction
If a global variable in a module we are compiling has a type containing
a resilient value type from a different module, we don't know the size
at compile time, so we cannot allocate storage for the global statically.

Instead, we will use a buffer, just like alloc_stack does for archetypes
and resilient value types.

This adds a new SIL instruction but does not yet make use of it.
2016-01-07 13:40:48 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Roman Levenstein
248bfd1b75 [global-opt] Support for tuples in constant initializers.
Globals and static let variables can now contain  tuples in their constant initializers.
The values of tuples and their elements will be propagated into their uses just as we do it for structs and scalars already.

Swift SVN r30240
2015-07-15 23:40:12 +00:00
Roman Levenstein
2278ed9be2 [globalopt] fptrunc(float_literal) can be considered to be a simple static initializer.
Swift SVN r30155
2015-07-13 19:03:25 +00:00
Roman Levenstein
d5650ae210 Propagate a "let" flag from VarDecl into resulting SILGlobalVariables.
This flag is required for performing the propagation of global and static "let" values into their uses.
Let variables have now a [let] attribute in the SIL textual form.

Swift SVN r30153
2015-07-13 19:03:23 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Joe Groff
3f23b82e6d SIL: Rename SILGlobalAddr to GlobalAddr.
All globals are SIL globals now.

Swift SVN r22827
2014-10-18 17:08:28 +00:00
Erik Eckstein
c16c510167 Set SILLinkage according to visibility.
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public).

In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level.
Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect,
because everything was public anyway.

For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all,
i.e. for the stdlib.

For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions.

The benefits of this change are:
*) Enable to eliminate unused private and internal functions
*) It should be possible now to use private in the stdlib
*) The symbol linkage is as one would expect (previously almost all symbols were public).

More details:

Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default
linkage instead of linkonce_odr,hidden, i.e. they have public visibility.
The reason is: if such a function is called from another fragile function (in the same module),
then it has to be visible from a third module, in case the fragile caller is inlined but not
the specialized function.

I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed.

The -sil-serialize-all option is now handled at SILGen and not at the Serializer.
This means that test files in sil format which are compiled with -sil-serialize-all
must have the [fragile] attribute set for all functions and globals.

The -disable-access-control option doesn't help anymore if the accessed module is not compiled
with -sil-serialize-all, because the linker will complain about unresolved symbols.

A final note: I tried to consider all the implications of this change, but it's not a low-risk change.
If you have any comments, please let me know.



Swift SVN r22215
2014-09-23 12:33:18 +00:00
Manman Ren
5ba1930a36 [Global Opt] add helper functions to analyze static initializer in SILGlobalVariable.
Also use the helper function to verify initializers for SILGlobalVariables.


Swift SVN r22082
2014-09-18 17:30:59 +00:00
Manman Ren
53151b90bd [Global Opt] add SILFunction *InitializerF to SILGlobalVariable.
It is defaulted to nullptr. When it is set, we increment the SILFunction's
ref count to keep it alive.

It will be used in followon patches for globals that can be statically
initialized.


Swift SVN r21983
2014-09-16 21:50:56 +00:00
Manman Ren
9491a0e190 [Global Opt] get ready to replace GlobalAddrInst with SILGlobalAddrInst.
We add two more fields to SILGlobalVariable: a VarDecl and a flag to see if this
is a declaration. VarDecl is mainly used for debugger support, it is also used
to check if the variable is weak imported.

We also modify the serializer to serialize the extra two fields.


Swift SVN r21883
2014-09-11 18:13:04 +00:00
John McCall
5da6defa1f Clean up the linkage model and the computation of linkage.
In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.

Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.

Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.

Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration.  This computation should really take
advantage of the relationship between modules, but currently
it does not.

Swift SVN r12090
2014-01-09 08:58:07 +00:00
John McCall
e507341c1b SILModule lookup: now with that magic O(1) flavor.
Swift SVN r11978
2014-01-07 01:21:10 +00:00
John McCall
bb63d2312b Hide the constructors of SILFunction/SILGlobalVariable
behind factory methods.

Swift SVN r11967
2014-01-07 00:22:15 +00:00
Joe Groff
0cc9417fef SIL: Introduce a SILGlobalVariable concept.
This will let us control linkage and emit new variables independent of the AST in SILGen. In particular, for lazy global initialization, we need to emit a unique internal once predicate for every top-level pattern binding. Switching everything over is a bit much to reengineer all at once, so for now, it can coexist with the globals map that is already there.

Swift SVN r10509
2013-11-16 00:50:17 +00:00