Merge pull request #5445 from gottesmm/use_bit_for_ownershipqualification_when_deserializing
diff --git a/include/swift/Serialization/ModuleFormat.h b/include/swift/Serialization/ModuleFormat.h
index 8d30b2b..4982edf 100644
--- a/include/swift/Serialization/ModuleFormat.h
+++ b/include/swift/Serialization/ModuleFormat.h
@@ -54,7 +54,7 @@
/// in source control, you should also update the comment to briefly
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
-const uint16_t VERSION_MINOR = 279; // Last change: copy_value, destroy_value
+const uint16_t VERSION_MINOR = 280; // Last change: function qualified ownership
using DeclID = PointerEmbeddedInt<unsigned, 31>;
using DeclIDField = BCFixed<31>;
diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp
index cd81a31..ad7c1b3 100644
--- a/lib/Serialization/DeserializeSIL.cpp
+++ b/lib/Serialization/DeserializeSIL.cpp
@@ -380,13 +380,13 @@
DeclID clangNodeOwnerID;
TypeID funcTyID;
unsigned rawLinkage, isTransparent, isFragile, isThunk, isGlobal,
- inlineStrategy, effect, numSpecAttrs;
+ inlineStrategy, effect, numSpecAttrs, hasQualifiedOwnership;
ArrayRef<uint64_t> SemanticsIDs;
// TODO: read fragile
SILFunctionLayout::readRecord(scratch, rawLinkage, isTransparent, isFragile,
isThunk, isGlobal, inlineStrategy, effect,
- numSpecAttrs, funcTyID, clangNodeOwnerID,
- SemanticsIDs);
+ numSpecAttrs, hasQualifiedOwnership, funcTyID,
+ clangNodeOwnerID, SemanticsIDs);
if (funcTyID == 0) {
DEBUG(llvm::dbgs() << "SILFunction typeID is 0.\n");
@@ -454,6 +454,8 @@
for (auto ID : SemanticsIDs) {
fn->addSemanticsAttr(MF->getIdentifier(ID).str());
}
+ if (!hasQualifiedOwnership)
+ fn->setUnqualifiedOwnership();
if (Callback) Callback->didDeserialize(MF->getAssociatedModule(), fn);
}
@@ -538,7 +540,6 @@
LocalValues.clear();
ForwardLocalValues.clear();
- FunctionOwnershipEvaluator OwnershipEvaluator(fn);
SILOpenedArchetypesTracker OpenedArchetypesTracker(*fn);
SILBuilder Builder(*fn);
// Track the archetypes just like SILGen. This
@@ -572,8 +573,7 @@
return fn;
// Handle a SILInstruction record.
- if (readSILInstruction(fn, CurrentBB, Builder, OwnershipEvaluator, kind,
- scratch)) {
+ if (readSILInstruction(fn, CurrentBB, Builder, kind, scratch)) {
DEBUG(llvm::dbgs() << "readSILInstruction returns error.\n");
MF->error();
return fn;
@@ -659,10 +659,10 @@
return DRef;
}
-bool SILDeserializer::readSILInstruction(
- SILFunction *Fn, SILBasicBlock *BB, SILBuilder &Builder,
- FunctionOwnershipEvaluator &OwnershipEvaluator, unsigned RecordKind,
- SmallVectorImpl<uint64_t> &scratch) {
+bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
+ SILBuilder &Builder,
+ unsigned RecordKind,
+ SmallVectorImpl<uint64_t> &scratch) {
// Return error if Basic Block is null.
if (!BB)
return true;
@@ -1900,11 +1900,6 @@
llvm_unreachable("todo");
}
- // Evaluate ResultVal's ownership. If we find that as a result of ResultVal,
- // we are mixing qualified and unqualified ownership instructions, bail.
- if (!OwnershipEvaluator.evaluate(ResultVal))
- return true;
-
if (ResultVal->hasValue()) {
LastValueID = LastValueID + 1;
setLocalValue(ResultVal, LastValueID);
@@ -1973,12 +1968,12 @@
DeclID clangOwnerID;
TypeID funcTyID;
unsigned rawLinkage, isTransparent, isFragile, isThunk, isGlobal,
- inlineStrategy, effect, numSpecAttrs;
+ inlineStrategy, effect, numSpecAttrs, hasQualifiedOwnership;
ArrayRef<uint64_t> SemanticsIDs;
SILFunctionLayout::readRecord(scratch, rawLinkage, isTransparent, isFragile,
isThunk, isGlobal, inlineStrategy, effect,
- numSpecAttrs, funcTyID, clangOwnerID,
- SemanticsIDs);
+ numSpecAttrs, hasQualifiedOwnership, funcTyID,
+ clangOwnerID, SemanticsIDs);
auto linkage = fromStableSILLinkage(rawLinkage);
if (!linkage) {
DEBUG(llvm::dbgs() << "invalid linkage code " << rawLinkage
diff --git a/lib/Serialization/DeserializeSIL.h b/lib/Serialization/DeserializeSIL.h
index 1e06332..9b0cafd 100644
--- a/lib/Serialization/DeserializeSIL.h
+++ b/lib/Serialization/DeserializeSIL.h
@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
#include "SILFormat.h"
-#include "swift/SIL/InstructionUtils.h"
#include "swift/SIL/SILModule.h"
#include "swift/Serialization/ModuleFile.h"
#include "swift/Serialization/SerializedSILLoader.h"
@@ -84,7 +83,6 @@
/// Read a SIL instruction within a given SIL basic block.
bool readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
SILBuilder &Builder,
- FunctionOwnershipEvaluator &OwnershipEvaluator,
unsigned RecordKind,
SmallVectorImpl<uint64_t> &scratch);
diff --git a/lib/Serialization/SILFormat.h b/lib/Serialization/SILFormat.h
index 3cba3bb..50758ac 100644
--- a/lib/Serialization/SILFormat.h
+++ b/lib/Serialization/SILFormat.h
@@ -238,15 +238,16 @@
using SILFunctionLayout =
BCRecordLayout<SIL_FUNCTION, SILLinkageField,
- BCFixed<1>, // transparent
- BCFixed<1>, // fragile
- BCFixed<2>, // thunk/reabstraction_thunk
- BCFixed<1>, // global_init
- BCFixed<2>, // inlineStrategy
- BCFixed<2>, // side effect info.
- BCFixed<2>, // number of specialize attributes
- TypeIDField,// SILFunctionType
- DeclIDField,// ClangNode owner
+ BCFixed<1>, // transparent
+ BCFixed<1>, // fragile
+ BCFixed<2>, // thunk/reabstraction_thunk
+ BCFixed<1>, // global_init
+ BCFixed<2>, // inlineStrategy
+ BCFixed<2>, // side effect info.
+ BCFixed<2>, // number of specialize attributes
+ BCFixed<1>, // has qualified ownership
+ TypeIDField, // SILFunctionType
+ DeclIDField, // ClangNode owner
BCArray<IdentifierIDField> // Semantics Attribute
// followed by specialize attributes
// followed by generic param list, if any
diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp
index ed29901..c1bc9e4 100644
--- a/lib/Serialization/SerializeSIL.cpp
+++ b/lib/Serialization/SerializeSIL.cpp
@@ -358,7 +358,8 @@
(unsigned)F.isTransparent(), (unsigned)F.isFragile(),
(unsigned)F.isThunk(), (unsigned)F.isGlobalInit(),
(unsigned)F.getInlineStrategy(), (unsigned)F.getEffectsKind(),
- (unsigned)numSpecAttrs, FnID, clangNodeOwnerID, SemanticsIDs);
+ (unsigned)numSpecAttrs, (unsigned)F.hasQualifiedOwnership(), FnID,
+ clangNodeOwnerID, SemanticsIDs);
if (NoBody)
return;