Skip to content

Commit d813b75

Browse files
authored
---
yaml --- r: 314361 b: refs/heads/master c: 0fd8d07 h: refs/heads/master i: 314359: ac56655
1 parent 25d3422 commit d813b75

File tree

4 files changed

+1
-146
lines changed

4 files changed

+1
-146
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f9266b9670b07d90d7b64746f4a4308bb17c0095
2+
refs/heads/master: 0fd8d07a9c69e5176deacc0912fe20ae65230838
33
refs/heads/master-next: 66a7e661ff8e88e2d4efab3e430197a7a941e352
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/SIL/InstructionUtils.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -142,48 +142,6 @@ bool onlyUsedByAssignByWrapper(PartialApplyInst *PAI);
142142
void findClosuresForFunctionValue(SILValue V,
143143
TinyPtrVector<PartialApplyInst *> &results);
144144

145-
/// A utility class for evaluating whether a newly parsed or deserialized
146-
/// function has qualified or unqualified ownership.
147-
///
148-
/// The reason that we are using this is that we would like to avoid needing to
149-
/// add code to the SILParser or to the Serializer to support this temporary
150-
/// staging concept of a function having qualified or unqualified
151-
/// ownership. Once SemanticARC is complete, SILFunctions will always have
152-
/// qualified ownership, so the notion of an unqualified ownership function will
153-
/// no longer exist.
154-
///
155-
/// Thus we note that there are three sets of instructions in SIL from an
156-
/// ownership perspective:
157-
///
158-
/// a. ownership qualified instructions
159-
/// b. ownership unqualified instructions
160-
/// c. instructions that do not have ownership semantics (think literals,
161-
/// geps, etc).
162-
///
163-
/// The set of functions can be split into ownership qualified and ownership
164-
/// unqualified using the rules that:
165-
///
166-
/// a. a function can never contain both ownership qualified and ownership
167-
/// unqualified instructions.
168-
/// b. a function that contains only instructions without ownership semantics
169-
/// is considered ownership qualified.
170-
///
171-
/// Thus we can know when parsing/serializing what category of function we have
172-
/// and set the bit appropriately.
173-
class FunctionOwnershipEvaluator {
174-
NullablePtr<SILFunction> F;
175-
bool HasOwnershipQualifiedInstruction = false;
176-
177-
public:
178-
FunctionOwnershipEvaluator() {}
179-
FunctionOwnershipEvaluator(SILFunction *F) : F(F) {}
180-
void reset(SILFunction *NewF) {
181-
F = NewF;
182-
HasOwnershipQualifiedInstruction = false;
183-
}
184-
bool evaluate(SILInstruction *I);
185-
};
186-
187145
} // end namespace swift
188146

189147
#endif

trunk/lib/ParseSIL/ParseSIL.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ namespace {
229229
SILParserTUState &TUState;
230230
SILFunction *F = nullptr;
231231
GenericEnvironment *ContextGenericEnv = nullptr;
232-
FunctionOwnershipEvaluator OwnershipEvaluator;
233232

234233
private:
235234
/// HadError - Have we seen an error parsing this function?
@@ -5335,16 +5334,6 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
53355334
do {
53365335
if (parseSILInstruction(B))
53375336
return true;
5338-
// Evaluate how the just parsed instruction effects this functions Ownership
5339-
// Qualification. For more details, see the comment on the
5340-
// FunctionOwnershipEvaluator class.
5341-
SILInstruction *ParsedInst = &*BB->rbegin();
5342-
if (BB->getParent()->hasOwnership() &&
5343-
!OwnershipEvaluator.evaluate(ParsedInst)) {
5344-
P.diagnose(ParsedInst->getLoc().getSourceLoc(),
5345-
diag::found_unqualified_instruction_in_qualified_function,
5346-
F->getName());
5347-
}
53485337
} while (isStartOfSILInstruction());
53495338

53505339
return false;
@@ -5460,7 +5449,6 @@ bool SILParserTUState::parseDeclSIL(Parser &P) {
54605449
}
54615450

54625451
// Parse the basic block list.
5463-
FunctionState.OwnershipEvaluator.reset(FunctionState.F);
54645452
SILOpenedArchetypesTracker OpenedArchetypesTracker(FunctionState.F);
54655453
SILBuilder B(*FunctionState.F);
54665454
// Track the archetypes just like SILGen. This

trunk/lib/SIL/InstructionUtils.cpp

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -527,94 +527,3 @@ void swift::findClosuresForFunctionValue(
527527
// Ignore other unrecognized values that feed this applied argument.
528528
}
529529
}
530-
531-
namespace {
532-
533-
enum class OwnershipQualifiedKind {
534-
NotApplicable,
535-
Qualified,
536-
Unqualified,
537-
};
538-
539-
struct OwnershipQualifiedKindVisitor : SILInstructionVisitor<OwnershipQualifiedKindVisitor, OwnershipQualifiedKind> {
540-
541-
OwnershipQualifiedKind visitSILInstruction(SILInstruction *I) {
542-
return OwnershipQualifiedKind::NotApplicable;
543-
}
544-
545-
#define QUALIFIED_INST(CLASS) \
546-
OwnershipQualifiedKind visit ## CLASS(CLASS *I) { \
547-
return OwnershipQualifiedKind::Qualified; \
548-
}
549-
QUALIFIED_INST(EndBorrowInst)
550-
QUALIFIED_INST(LoadBorrowInst)
551-
QUALIFIED_INST(CopyValueInst)
552-
QUALIFIED_INST(DestroyValueInst)
553-
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
554-
QUALIFIED_INST(Copy##Name##ValueInst)
555-
#include "swift/AST/ReferenceStorage.def"
556-
#undef QUALIFIED_INST
557-
558-
OwnershipQualifiedKind visitLoadInst(LoadInst *LI) {
559-
if (LI->getOwnershipQualifier() == LoadOwnershipQualifier::Unqualified)
560-
return OwnershipQualifiedKind::Unqualified;
561-
return OwnershipQualifiedKind::Qualified;
562-
}
563-
564-
OwnershipQualifiedKind visitStoreInst(StoreInst *SI) {
565-
if (SI->getOwnershipQualifier() == StoreOwnershipQualifier::Unqualified)
566-
return OwnershipQualifiedKind::Unqualified;
567-
return OwnershipQualifiedKind::Qualified;
568-
}
569-
};
570-
571-
} // end anonymous namespace
572-
573-
bool FunctionOwnershipEvaluator::evaluate(SILInstruction *I) {
574-
assert(I->getFunction() == F.get() && "Can not evaluate function ownership "
575-
"implications of an instruction that "
576-
"does not belong to the instruction "
577-
"that we are evaluating");
578-
579-
switch (OwnershipQualifiedKindVisitor().visit(I)) {
580-
case OwnershipQualifiedKind::Unqualified: {
581-
// If we already know that the function has unqualified ownership, just
582-
// return early.
583-
if (!F.get()->hasOwnership())
584-
return true;
585-
586-
// Ok, so we know at this point that we have qualified ownership. If we have
587-
// seen any instructions with qualified ownership, we have an error since
588-
// the function mixes qualified and unqualified instructions.
589-
if (HasOwnershipQualifiedInstruction)
590-
return false;
591-
592-
// Otherwise, set the function to have unqualified ownership. This will
593-
// ensure that no more Qualified instructions can be added to the given
594-
// function.
595-
F.get()->setOwnershipEliminated();
596-
return true;
597-
}
598-
case OwnershipQualifiedKind::Qualified: {
599-
// First check if our function has unqualified ownership. If we already do
600-
// have unqualified ownership, then we know that we have already seen an
601-
// unqualified ownership instruction. This means the function has both
602-
// qualified and unqualified instructions. =><=.
603-
if (!F.get()->hasOwnership())
604-
return false;
605-
606-
// Ok, at this point we know that we are still qualified. Since functions
607-
// start as qualified, we need to set the HasOwnershipQualifiedInstructions
608-
// so we do not need to look back through the function if we see an
609-
// unqualified instruction later on.
610-
HasOwnershipQualifiedInstruction = true;
611-
return true;
612-
}
613-
case OwnershipQualifiedKind::NotApplicable: {
614-
// Not Applicable instr
615-
return true;
616-
}
617-
}
618-
619-
llvm_unreachable("Unhandled OwnershipQualifiedKind in switch.");
620-
}

0 commit comments

Comments
 (0)