mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[global-variable] When deserializing global variables, only deserialize if the current module does not have a gv with the same name.
This is testing by deserialization not blowing up. <rdar://problem/18562242> Swift SVN r22555
This commit is contained in:
@@ -333,6 +333,18 @@ SILFunction *SILDeserializer::getFuncForReference(StringRef name) {
|
||||
return readSILFunction(*iter, nullptr, name, /*declarationOnly*/ true);
|
||||
}
|
||||
|
||||
/// Helper function to find a SILGlobalVariable given its name. It first checks
|
||||
/// in the module. If we can not find it in the module, we attempt to
|
||||
/// deserialize it.
|
||||
SILGlobalVariable *SILDeserializer::getGlobalForReference(StringRef name) {
|
||||
// Check to see if we have a global by this name already.
|
||||
if (SILGlobalVariable *g = SILMod.lookUpGlobalVariable(name))
|
||||
return g;
|
||||
|
||||
// Otherwise, look for a global with this name in the module.
|
||||
return readGlobalVar(name);
|
||||
}
|
||||
|
||||
/// Deserialize a SILFunction if it is not already deserialized. The input
|
||||
/// SILFunction can either be an empty declaration or null. If it is an empty
|
||||
/// declaration, we fill in the contents. If the input SILFunction is
|
||||
@@ -918,7 +930,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
|
||||
Identifier Name = MF->getIdentifier(ValID);
|
||||
|
||||
// Find the global variable.
|
||||
SILGlobalVariable *g = readGlobalVar(Name.str());
|
||||
SILGlobalVariable *g = getGlobalForReference(Name.str());
|
||||
assert(g && "Can't deserialize global variable");
|
||||
assert(g->getLoweredType().getAddressType() ==
|
||||
getSILType(Ty, (SILValueCategory)TyCategory) &&
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace swift {
|
||||
SILFunction *getFuncForReference(StringRef Name);
|
||||
SILFunction *lookupSILFunction(StringRef Name);
|
||||
SILVTable *readVTable(serialization::DeclID);
|
||||
SILGlobalVariable *getGlobalForReference(StringRef Name);
|
||||
SILGlobalVariable *readGlobalVar(StringRef Name);
|
||||
SILWitnessTable *readWitnessTable(serialization::DeclID,
|
||||
SILWitnessTable *existingWt,
|
||||
|
||||
Reference in New Issue
Block a user