mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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
This commit is contained in:
@@ -46,9 +46,8 @@ private:
|
||||
friend class SILBasicBlock;
|
||||
friend class SILModule;
|
||||
|
||||
/// ModuleAndLinkage - The SIL module that the function belongs to, and
|
||||
/// the function's linkage.
|
||||
llvm::PointerIntPair<SILModule*, 2, SILLinkage> ModuleAndLinkage;
|
||||
/// Module - The SIL module that the function belongs to.
|
||||
SILModule &Module;
|
||||
|
||||
/// The mangled name of the SIL function, which will be propagated
|
||||
/// to the binary. A pointer into the module's lookup table.
|
||||
@@ -79,6 +78,9 @@ private:
|
||||
|
||||
/// The function's transparent attribute.
|
||||
unsigned Transparent : 1; // FIXME: pack this somewhere
|
||||
|
||||
/// The linkage of the function.
|
||||
unsigned Linkage : NumSILLinkageBits;
|
||||
|
||||
/// This is the number of function_ref instructions using this SILFunction.
|
||||
friend class FunctionRefInst;
|
||||
@@ -106,7 +108,7 @@ public:
|
||||
DeclContext *DC = nullptr);
|
||||
~SILFunction();
|
||||
|
||||
SILModule &getModule() const { return *ModuleAndLinkage.getPointer(); }
|
||||
SILModule &getModule() const { return Module; }
|
||||
|
||||
SILType getLoweredType() const {
|
||||
return SILType::getPrimitiveObjectType(LoweredType);
|
||||
@@ -128,10 +130,11 @@ public:
|
||||
|
||||
/// True if this is a declaration of a function defined in another module.
|
||||
bool isExternalDeclaration() const { return BlockList.empty(); }
|
||||
bool isDefinition() const { return !isExternalDeclaration(); }
|
||||
|
||||
/// Get this function's linkage attribute.
|
||||
SILLinkage getLinkage() const { return ModuleAndLinkage.getInt(); }
|
||||
void setLinkage(SILLinkage L) { ModuleAndLinkage.setInt(L); }
|
||||
SILLinkage getLinkage() const { return SILLinkage(Linkage); }
|
||||
void setLinkage(SILLinkage linkage) { Linkage = unsigned(linkage); }
|
||||
|
||||
/// Get the DeclContext of this function. (Debug info only).
|
||||
DeclContext *getDeclContext() const { return DeclCtx; }
|
||||
|
||||
Reference in New Issue
Block a user