Merge CheckedCastValueBranch with new master

This commit is contained in:
Joe Shajrawi
2017-03-06 16:50:44 -08:00
425 changed files with 12013 additions and 6421 deletions

View File

@@ -16,6 +16,7 @@
#include "swift/SIL/SILInstruction.h"
#include "swift/SIL/SILModule.h"
#include "swift/SIL/SILVisitor.h"
#include "llvm/ADT/StringSwitch.h"
using namespace swift;
@@ -143,6 +144,19 @@ ValueOwnershipKind::merge(ValueOwnershipKind RHS) const {
return (LHSVal == RHSVal) ? Optional<ValueOwnershipKind>(*this) : None;
}
ValueOwnershipKind::ValueOwnershipKind(StringRef S) {
auto Result = llvm::StringSwitch<Optional<ValueOwnershipKind::innerty>>(S)
.Case("trivial", ValueOwnershipKind::Trivial)
.Case("unowned", ValueOwnershipKind::Unowned)
.Case("owned", ValueOwnershipKind::Owned)
.Case("guaranteed", ValueOwnershipKind::Guaranteed)
.Case("any", ValueOwnershipKind::Any)
.Default(None);
if (!Result.hasValue())
llvm_unreachable("Invalid string representation of ValueOwnershipKind");
Value = Result.getValue();
}
//===----------------------------------------------------------------------===//
// Instruction ValueOwnershipKind Computation
//===----------------------------------------------------------------------===//
@@ -201,6 +215,7 @@ CONSTANT_OWNERSHIP_INST(Owned, PartialApply)
CONSTANT_OWNERSHIP_INST(Owned, StrongPin)
CONSTANT_OWNERSHIP_INST(Owned, ThinToThickFunction)
CONSTANT_OWNERSHIP_INST(Owned, InitExistentialOpaque)
CONSTANT_OWNERSHIP_INST(Owned, UnconditionalCheckedCastOpaque)
// One would think that these /should/ be unowned. In truth they are owned since
// objc metatypes do not go through the retain/release fast path. In their
@@ -333,6 +348,7 @@ NO_RESULT_OWNERSHIP_INST(InjectEnumAddr)
NO_RESULT_OWNERSHIP_INST(DeinitExistentialAddr)
NO_RESULT_OWNERSHIP_INST(DeinitExistentialOpaque)
NO_RESULT_OWNERSHIP_INST(CondFail)
NO_RESULT_OWNERSHIP_INST(EndLifetime)
// Terminators. These do not produce SILValue, so they do not have a
// ValueOwnershipKind. They do have ownership implications in terms of the
@@ -395,6 +411,12 @@ ValueOwnershipKindVisitor::visitForwardingInst(SILInstruction *I,
auto MergedValue = Base.merge(OpKind.Value);
if (!MergedValue.hasValue()) {
// If we have mismatched SILOwnership and sil ownership is not enabled,
// just return Any for staging purposes. If SILOwnership is enabled, then
// we must assert!
if (!I->getModule().getOptions().EnableSILOwnership) {
return ValueOwnershipKind::Any;
}
llvm_unreachable("Forwarding inst with mismatching ownership kinds?!");
}
}
@@ -419,7 +441,6 @@ FORWARDING_OWNERSHIP_INST(Struct)
FORWARDING_OWNERSHIP_INST(Tuple)
FORWARDING_OWNERSHIP_INST(UncheckedRefCast)
FORWARDING_OWNERSHIP_INST(UnconditionalCheckedCast)
FORWARDING_OWNERSHIP_INST(UnconditionalCheckedCastOpaque)
FORWARDING_OWNERSHIP_INST(Upcast)
FORWARDING_OWNERSHIP_INST(MarkUninitialized)
FORWARDING_OWNERSHIP_INST(UncheckedEnumData)
@@ -460,6 +481,12 @@ ValueOwnershipKind ValueOwnershipKindVisitor::visitUncheckedBitwiseCastInst(
return visitForwardingInst(UBCI);
}
ValueOwnershipKind
ValueOwnershipKindVisitor::visitUncheckedOwnershipConversionInst(
UncheckedOwnershipConversionInst *I) {
return I->getConversionOwnershipKind();
}
// An enum without payload is trivial. One with non-trivial payload is
// forwarding.
ValueOwnershipKind