diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h index b2481815d7a..c8f8083cdbf 100644 --- a/include/swift/SIL/SILBuilder.h +++ b/include/swift/SIL/SILBuilder.h @@ -727,12 +727,6 @@ public: EndBorrowInst(getSILDebugLocation(Loc), BorrowedValue)); } - EndBorrowArgumentInst *createEndBorrowArgument(SILLocation Loc, - SILValue Arg) { - return insert(new (getModule()) EndBorrowArgumentInst( - getSILDebugLocation(Loc), cast(Arg))); - } - BeginAccessInst *createBeginAccess(SILLocation loc, SILValue address, SILAccessKind accessKind, SILAccessEnforcement enforcement, diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h index d53c7c82877..124f1d8bc17 100644 --- a/include/swift/SIL/SILCloner.h +++ b/include/swift/SIL/SILCloner.h @@ -778,15 +778,6 @@ void SILCloner::visitEndBorrowInst(EndBorrowInst *Inst) { getOpValue(Inst->getOperand()), SILValue())); } -template -void SILCloner::visitEndBorrowArgumentInst( - EndBorrowArgumentInst *Inst) { - getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope())); - doPostProcess( - Inst, getBuilder().createEndBorrowArgument( - getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()))); -} - template void SILCloner::visitBeginAccessInst(BeginAccessInst *Inst) { getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope())); diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index 2af0272ecbd..ca7706e8285 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -3221,18 +3221,6 @@ public: } }; -/// Represents the end of a borrow scope for an argument. The reason why this is -/// separate from end_borrow is that an argument is not borrowed from a -/// specific SSA value. Instead it is borrowed from potentially many different -/// incoming values. -class EndBorrowArgumentInst - : public UnaryInstructionBase { - friend class SILBuilder; - - EndBorrowArgumentInst(SILDebugLocation DebugLoc, SILArgument *Arg); -}; - /// Different kinds of access. enum class SILAccessKind : uint8_t { /// An access which takes uninitialized memory and initializes it. diff --git a/include/swift/SIL/SILNodes.def b/include/swift/SIL/SILNodes.def index f609bd902a8..2e34f668396 100644 --- a/include/swift/SIL/SILNodes.def +++ b/include/swift/SIL/SILNodes.def @@ -598,8 +598,6 @@ NON_VALUE_INST(DestroyValueInst, destroy_value, SILInstruction, MayHaveSideEffects, MayRelease) NON_VALUE_INST(EndBorrowInst, end_borrow, SILInstruction, MayHaveSideEffects, DoesNotRelease) -NON_VALUE_INST(EndBorrowArgumentInst, end_borrow_argument, - SILInstruction, MayHaveSideEffects, DoesNotRelease) NON_VALUE_INST(EndAccessInst, end_access, SILInstruction, MayHaveSideEffects, DoesNotRelease) NON_VALUE_INST(BeginUnpairedAccessInst, begin_unpaired_access, diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 63b77d34758..1a82515d168 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -1049,9 +1049,6 @@ public: void visitEndBorrowInst(EndBorrowInst *i) { llvm_unreachable("unimplemented"); } - void visitEndBorrowArgumentInst(EndBorrowArgumentInst *i) { - llvm_unreachable("unimplemented"); - } void visitStoreBorrowInst(StoreBorrowInst *i) { llvm_unreachable("unimplemented"); } diff --git a/lib/ParseSIL/ParseSIL.cpp b/lib/ParseSIL/ParseSIL.cpp index 9ca5b9e4159..763588e849c 100644 --- a/lib/ParseSIL/ParseSIL.cpp +++ b/lib/ParseSIL/ParseSIL.cpp @@ -2680,7 +2680,6 @@ bool SILParser::parseSILInstruction(SILBuilder &B) { UNARY_INSTRUCTION(CopyValue) UNARY_INSTRUCTION(DestroyValue) UNARY_INSTRUCTION(CondFail) - UNARY_INSTRUCTION(EndBorrowArgument) UNARY_INSTRUCTION(EndBorrow) UNARY_INSTRUCTION(DestructureStruct) UNARY_INSTRUCTION(DestructureTuple) diff --git a/lib/SIL/MemAccessUtils.cpp b/lib/SIL/MemAccessUtils.cpp index 1d17c193fcc..6fb57134527 100644 --- a/lib/SIL/MemAccessUtils.cpp +++ b/lib/SIL/MemAccessUtils.cpp @@ -695,7 +695,6 @@ void swift::visitAccessedAddress(SILInstruction *I, case SILInstructionKind::DestroyValueInst: case SILInstructionKind::EndAccessInst: case SILInstructionKind::EndApplyInst: - case SILInstructionKind::EndBorrowArgumentInst: case SILInstructionKind::EndBorrowInst: case SILInstructionKind::EndUnpairedAccessInst: case SILInstructionKind::EndLifetimeInst: diff --git a/lib/SIL/SILInstructions.cpp b/lib/SIL/SILInstructions.cpp index f54c9cc2afd..21cd6ae6909 100644 --- a/lib/SIL/SILInstructions.cpp +++ b/lib/SIL/SILInstructions.cpp @@ -790,10 +790,6 @@ StoreBorrowInst::StoreBorrowInst(SILDebugLocation DebugLoc, SILValue Src, : InstructionBase(DebugLoc, Dest->getType()), Operands(this, Src, Dest) {} -EndBorrowArgumentInst::EndBorrowArgumentInst(SILDebugLocation DebugLoc, - SILArgument *Arg) - : UnaryInstructionBase(DebugLoc, SILValue(Arg)) {} - StringRef swift::getSILAccessKindName(SILAccessKind kind) { switch (kind) { case SILAccessKind::Init: return "init"; diff --git a/lib/SIL/SILOwnershipVerifier.cpp b/lib/SIL/SILOwnershipVerifier.cpp index 1a70d3b2442..77d8cebcc85 100644 --- a/lib/SIL/SILOwnershipVerifier.cpp +++ b/lib/SIL/SILOwnershipVerifier.cpp @@ -610,21 +610,6 @@ OwnershipCompatibilityUseChecker::visitDeallocPartialRefInst( UseLifetimeConstraint::MustBeLive}; } -OwnershipUseCheckerResult -OwnershipCompatibilityUseChecker::visitEndBorrowArgumentInst( - EndBorrowArgumentInst *I) { - // If we are currently checking an end_borrow_argument as a subobject, then we - // treat this as just a use. - if (isCheckingSubObject()) - return {true, UseLifetimeConstraint::MustBeLive}; - - // Otherwise, we must be checking an actual argument. Make sure it is guaranteed! - auto lifetimeConstraint = hasExactOwnership(ValueOwnershipKind::Guaranteed) - ? UseLifetimeConstraint::MustBeInvalidated - : UseLifetimeConstraint::MustBeLive; - return {true, lifetimeConstraint}; -} - OwnershipUseCheckerResult OwnershipCompatibilityUseChecker::visitSelectEnumInst(SelectEnumInst *I) { if (getValue() == I->getEnumOperand()) { @@ -1551,10 +1536,10 @@ void SILValueOwnershipChecker::gatherUsers( continue; } - // Otherwise if we have a terminator, add any as uses any - // end_borrow_argument to ensure that the subscope is completely enclsed - // within the super scope. all of the arguments to the work list. We require - // all of our arguments to be either trivial or guaranteed. + // Otherwise if we have a terminator, add any as uses any end_borrow to + // ensure that the subscope is completely enclsed within the super + // scope. all of the arguments to the work list. We require all of our + // arguments to be either trivial or guaranteed. for (auto &Succ : TI->getSuccessors()) { auto *BB = Succ.getBB(); diff --git a/lib/SIL/SILPrinter.cpp b/lib/SIL/SILPrinter.cpp index 74d75eb1f68..ff4804ac893 100644 --- a/lib/SIL/SILPrinter.cpp +++ b/lib/SIL/SILPrinter.cpp @@ -1278,10 +1278,6 @@ public: *this << getIDAndType(EBI->getOperand()); } - void visitEndBorrowArgumentInst(EndBorrowArgumentInst *EBAI) { - *this << getIDAndType(EBAI->getOperand()); - } - void visitAssignInst(AssignInst *AI) { *this << Ctx.getID(AI->getSrc()) << " to " << getIDAndType(AI->getDest()); } diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index 66303f8fda2..a234b860168 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -163,22 +163,21 @@ SILGenFunction::emitManagedBeginBorrow(SILLocation loc, SILValue v, namespace { struct EndBorrowCleanup : Cleanup { - SILValue originalValue; SILValue borrowedValue; - EndBorrowCleanup(SILValue originalValue, SILValue borrowedValue) - : originalValue(originalValue), borrowedValue(borrowedValue) {} + EndBorrowCleanup(SILValue borrowedValue) + : borrowedValue(borrowedValue) {} void emit(SILGenFunction &SGF, CleanupLocation l, ForUnwind_t forUnwind) override { - SGF.B.createEndBorrow(l, borrowedValue, originalValue); + SGF.B.createEndBorrow(l, borrowedValue); } void dump(SILGenFunction &) const override { #ifndef NDEBUG llvm::errs() << "EndBorrowCleanup " << "State:" << getState() << "\n" - << "original:" << originalValue << "borrowed:" << borrowedValue + << "borrowed:" << borrowedValue << "\n"; #endif } @@ -271,29 +270,6 @@ SILGenFunction::emitFormalEvaluationManagedBorrowedRValueWithCleanup( return ManagedValue(borrowed, CleanupHandle::invalid()); } -namespace { - -struct EndBorrowArgumentCleanup : Cleanup { - SILPHIArgument *arg; - - EndBorrowArgumentCleanup(SILPHIArgument *arg) : arg(arg) {} - - void emit(SILGenFunction &SGF, CleanupLocation l, - ForUnwind_t forUnwind) override { - SGF.B.createEndBorrowArgument(l, arg); - } - - void dump(SILGenFunction &) const override { -#ifndef NDEBUG - llvm::errs() << "EndBorrowArgumentCleanup " - << "State:" << getState() << "\n" - << "argument: " << *arg << "\n"; -#endif - } -}; - -} // end anonymous namespace - ManagedValue SILGenFunction::emitManagedBorrowedArgumentWithCleanup(SILPHIArgument *arg) { if (arg->getOwnershipKind() == ValueOwnershipKind::Trivial || @@ -302,7 +278,7 @@ SILGenFunction::emitManagedBorrowedArgumentWithCleanup(SILPHIArgument *arg) { } assert(arg->getOwnershipKind() == ValueOwnershipKind::Guaranteed); - Cleanups.pushCleanup(arg); + Cleanups.pushCleanup(arg); return ManagedValue(arg, CleanupHandle::invalid()); } @@ -327,7 +303,7 @@ ManagedValue SILGenFunction::emitManagedBorrowedRValueWithCleanup( return ManagedValue::forUnmanaged(borrowed); if (borrowed->getType().isObject()) { - Cleanups.pushCleanup(original, borrowed); + Cleanups.pushCleanup(borrowed); } return ManagedValue(borrowed, CleanupHandle::invalid()); diff --git a/lib/SILOptimizer/Utils/SILInliner.cpp b/lib/SILOptimizer/Utils/SILInliner.cpp index a933e4c7ed9..bbe12366678 100644 --- a/lib/SILOptimizer/Utils/SILInliner.cpp +++ b/lib/SILOptimizer/Utils/SILInliner.cpp @@ -507,7 +507,6 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) { case SILInstructionKind::ConstStringLiteralInst: case SILInstructionKind::FixLifetimeInst: case SILInstructionKind::EndBorrowInst: - case SILInstructionKind::EndBorrowArgumentInst: case SILInstructionKind::BeginBorrowInst: case SILInstructionKind::MarkDependenceInst: case SILInstructionKind::FunctionRefInst: diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index 31003bb4a31..8f3533aa8ba 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -1641,7 +1641,6 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB, REFCOUNTING_INSTRUCTION(SetDeallocating) UNARY_INSTRUCTION(DeinitExistentialAddr) UNARY_INSTRUCTION(DeinitExistentialValue) - UNARY_INSTRUCTION(EndBorrowArgument) UNARY_INSTRUCTION(EndBorrow) UNARY_INSTRUCTION(DestroyAddr) UNARY_INSTRUCTION(Return) diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index a5712cb6e09..6a2120e41bb 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -1215,7 +1215,6 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) { case SILInstructionKind::DestructureTupleInst: case SILInstructionKind::RetainValueAddrInst: case SILInstructionKind::UnmanagedRetainValueInst: - case SILInstructionKind::EndBorrowArgumentInst: case SILInstructionKind::EndBorrowInst: case SILInstructionKind::CopyValueInst: case SILInstructionKind::DestroyValueInst: diff --git a/test/SIL/Parser/borrow_argument.sil b/test/SIL/Parser/borrow_argument.sil index 2e4b291bf4a..a4149125fea 100644 --- a/test/SIL/Parser/borrow_argument.sil +++ b/test/SIL/Parser/borrow_argument.sil @@ -6,13 +6,13 @@ import Builtin // CHECK-LABEL: sil @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { // CHECK: bb1([[PHIBBARG:%.*]] : @guaranteed $Builtin.NativeObject): -// CHECK: end_borrow_argument [[PHIBBARG]] : $Builtin.NativeObject +// CHECK: end_borrow [[PHIBBARG]] : $Builtin.NativeObject sil @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { bb0(%0 : @guaranteed $Builtin.NativeObject): br bb1(%0 : $Builtin.NativeObject) bb1(%1 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %1 : $Builtin.NativeObject + end_borrow %1 : $Builtin.NativeObject %4 = tuple() return %4 : $() } diff --git a/test/SIL/Parser/ownership_arguments.sil b/test/SIL/Parser/ownership_arguments.sil index f2d962ca535..309a6b19b37 100644 --- a/test/SIL/Parser/ownership_arguments.sil +++ b/test/SIL/Parser/ownership_arguments.sil @@ -14,7 +14,7 @@ bb0(%0 : @owned $Builtin.NativeObject, %1 : @unowned $Builtin.NativeObject, %2 : bb1(%4 : @owned $Builtin.NativeObject, %5 : @unowned $Builtin.NativeObject, %6 : @guaranteed $Builtin.NativeObject, %7 : @trivial $Builtin.Int32): destroy_value %4 : $Builtin.NativeObject - end_borrow_argument %6 : $Builtin.NativeObject + end_borrow %6 : $Builtin.NativeObject %9999 = tuple() return %9999 : $() } diff --git a/test/SIL/Serialization/borrow_argument.sil b/test/SIL/Serialization/borrow_argument.sil index 40ff4193116..d19b1aff189 100644 --- a/test/SIL/Serialization/borrow_argument.sil +++ b/test/SIL/Serialization/borrow_argument.sil @@ -10,13 +10,13 @@ import Builtin // CHECK-LABEL: sil [serialized] @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { // CHECK: bb1([[PHIBBARG:%.*]] : @guaranteed $Builtin.NativeObject): -// CHECK: end_borrow_argument [[PHIBBARG]] : $Builtin.NativeObject +// CHECK: end_borrow [[PHIBBARG]] : $Builtin.NativeObject sil [serialized] @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { bb0(%0 : @guaranteed $Builtin.NativeObject): br bb1(%0 : $Builtin.NativeObject) bb1(%1 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %1 : $Builtin.NativeObject + end_borrow %1 : $Builtin.NativeObject %4 = tuple() return %4 : $() } diff --git a/test/SIL/ownership-verifier/over_consume.sil b/test/SIL/ownership-verifier/over_consume.sil index 11acbc6f306..c4e2096c793 100644 --- a/test/SIL/ownership-verifier/over_consume.sil +++ b/test/SIL/ownership-verifier/over_consume.sil @@ -208,7 +208,7 @@ bb0(%0 : @owned $Optional): switch_enum %0 : $Optional, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2 bb1(%1 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %1 : $Builtin.NativeObject + end_borrow %1 : $Builtin.NativeObject br bb3 bb2: @@ -220,12 +220,12 @@ bb3: } -// CHECK-LABEL: Function: 'switch_enum_guaranteed_arg_outlives_original_value' -// CHECK: Found use after free?! -// CHECK: Value: %1 = begin_borrow %0 : $Optional -// CHECK: Consuming User: end_borrow %1 : $Optional -// CHECK: Non Consuming User: end_borrow_argument %3 : $Builtin.NativeObject -// CHECK: Block: bb1 +// TEMP-DISABLED-CHECK-LABEL: Function: 'switch_enum_guaranteed_arg_outlives_original_value' +// TEMP-DISABLED-CHECK: Found use after free?! +// TEMP-DISABLED-CHECK: Value: %1 = begin_borrow %0 : $Optional +// TEMP-DISABLED-CHECK: Consuming User: end_borrow %1 : $Optional +// TEMP-DISABLED-CHECK: Non Consuming User: end_borrow %3 : $Builtin.NativeObject +// TEMP-DISABLED-CHECK: Block: bb1 sil @switch_enum_guaranteed_arg_outlives_original_value : $@convention(thin) (@owned Optional) -> () { bb0(%0 : @owned $Optional): %1 = begin_borrow %0 : $Optional @@ -233,7 +233,7 @@ bb0(%0 : @owned $Optional): bb1(%2 : @guaranteed $Builtin.NativeObject): end_borrow %1 : $Optional - end_borrow_argument %2 : $Builtin.NativeObject + end_borrow %2 : $Builtin.NativeObject br bb3 bb2: @@ -287,7 +287,7 @@ bb0(%0 : @guaranteed $Builtin.NativeObject): checked_cast_br %0 : $Builtin.NativeObject to $SuperKlass, bb1, bb2 bb1(%1 : @guaranteed $SuperKlass): - end_borrow_argument %1 : $SuperKlass + end_borrow %1 : $SuperKlass br bb3 bb2(%2 : @owned $Builtin.NativeObject): @@ -314,7 +314,7 @@ bb1(%1 : @owned $SuperKlass): br bb3 bb2(%2 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %2 : $Builtin.NativeObject + end_borrow %2 : $Builtin.NativeObject br bb3 bb3: @@ -339,11 +339,11 @@ bb0(%0 : @owned $Builtin.NativeObject): checked_cast_br %0 : $Builtin.NativeObject to $SuperKlass, bb1, bb2 bb1(%1 : @guaranteed $SuperKlass): - end_borrow_argument %1 : $SuperKlass + end_borrow %1 : $SuperKlass br bb3 bb2(%2 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %2 : $Builtin.NativeObject + end_borrow %2 : $Builtin.NativeObject br bb3 bb3: @@ -363,7 +363,7 @@ bb0(%0 : @owned $Builtin.NativeObject): checked_cast_br %0 : $Builtin.NativeObject to $SuperKlass, bb1, bb2 bb1(%1 : @guaranteed $SuperKlass): - end_borrow_argument %1 : $SuperKlass + end_borrow %1 : $SuperKlass br bb3 bb2(%2 : @owned $Builtin.NativeObject): @@ -390,7 +390,7 @@ bb1(%1 : @owned $SuperKlass): br bb3 bb2(%2 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %2 : $Builtin.NativeObject + end_borrow %2 : $Builtin.NativeObject br bb3 bb3: @@ -398,25 +398,25 @@ bb3: return %9999 : $() } -// CHECK-LABEL: Function: 'checked_cast_br_guaranteed_arg_outlives_original_value' -// CHECK: Found use after free?! -// CHECK: Value: %1 = begin_borrow %0 : $Builtin.NativeObject -// CHECK: Consuming User: end_borrow %1 : $Builtin.NativeObject -// CHECK: Non Consuming User: end_borrow_argument %7 : $Builtin.NativeObject -// CHECK: Block: bb2 +// TEMP-DISABLED-CHECK-LABEL: Function: 'checked_cast_br_guaranteed_arg_outlives_original_value' +// TEMP-DISABLED-CHECK: Found use after free?! +// TEMP-DISABLED-CHECK: Value: %1 = begin_borrow %0 : $Builtin.NativeObject +// TEMP-DISABLED-CHECK: Consuming User: end_borrow %1 : $Builtin.NativeObject +// TEMP-DISABLED-CHECK: Non Consuming User: end_borrow %7 : $Builtin.NativeObject +// TEMP-DISABLED-CHECK: Block: bb2 sil @checked_cast_br_guaranteed_arg_outlives_original_value : $@convention(thin) (@owned Builtin.NativeObject) -> () { bb0(%0 : @owned $Builtin.NativeObject): %1 = begin_borrow %0 : $Builtin.NativeObject checked_cast_br %1 : $Builtin.NativeObject to $SuperKlass, bb1, bb2 bb1(%2 : @guaranteed $SuperKlass): - end_borrow_argument %2 : $SuperKlass + end_borrow %2 : $SuperKlass end_borrow %1 : $Builtin.NativeObject br bb3 bb2(%3 : @guaranteed $Builtin.NativeObject): end_borrow %1 : $Builtin.NativeObject - end_borrow_argument %3 : $Builtin.NativeObject + end_borrow %3 : $Builtin.NativeObject br bb3 bb3: diff --git a/test/SIL/ownership-verifier/use_verifier.sil b/test/SIL/ownership-verifier/use_verifier.sil index fe3a661cf94..54ab89d23e6 100644 --- a/test/SIL/ownership-verifier/use_verifier.sil +++ b/test/SIL/ownership-verifier/use_verifier.sil @@ -448,85 +448,6 @@ bb3: return %9999 : $() } -// Make sure that we can properly handle a guaranteed switch_enum. -sil @switch_enum_guaranteed_arg_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () { -bb0(%0 : @guaranteed $Builtin.NativeObject): - %1 = enum $Optional, #Optional.some!enumelt.1, %0 : $Builtin.NativeObject - switch_enum %1 : $Optional, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2 - -bb1(%2 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %2 : $Builtin.NativeObject - br bb3 - -bb2: - br bb3 - -bb3: - %9999 = tuple() - return %9999 : $() -} - -sil @switch_enum_guaranteed_beginborrow_test_1a : $@convention(thin) (@owned Builtin.NativeObject) -> () { -bb0(%0 : @owned $Builtin.NativeObject): - %1 = begin_borrow %0 : $Builtin.NativeObject - %2 = enum $Optional, #Optional.some!enumelt.1, %1 : $Builtin.NativeObject - switch_enum %2 : $Optional, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2 - -bb1(%3 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %3 : $Builtin.NativeObject - end_borrow %1 : $Builtin.NativeObject - br bb3 - -bb2: - end_borrow %1 : $Builtin.NativeObject - br bb3 - -bb3: - destroy_value %0 : $Builtin.NativeObject - %9999 = tuple() - return %9999 : $() -} - -sil @switch_enum_guaranteed_beginborrow_test_1b : $@convention(thin) (@owned Builtin.NativeObject) -> () { -bb0(%0 : @owned $Builtin.NativeObject): - %1 = begin_borrow %0 : $Builtin.NativeObject - %2 = enum $Optional, #Optional.some!enumelt.1, %1 : $Builtin.NativeObject - switch_enum %2 : $Optional, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2 - -bb1(%3 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %3 : $Builtin.NativeObject - br bb3 - -bb2: - br bb3 - -bb3: - end_borrow %1 : $Builtin.NativeObject - destroy_value %0 : $Builtin.NativeObject - %9999 = tuple() - return %9999 : $() -} - -sil @switch_enum_guaranteed_beginborrow_test_2 : $@convention(thin) (@owned Builtin.NativeObject) -> () { -bb0(%0 : @owned $Builtin.NativeObject): - %1 = enum $Optional, #Optional.some!enumelt.1, %0 : $Builtin.NativeObject - %2 = begin_borrow %1 : $Optional - switch_enum %2 : $Optional, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2 - -bb1(%3 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %3 : $Builtin.NativeObject - br bb3 - -bb2: - br bb3 - -bb3: - end_borrow %2 : $Optional - destroy_value %1 : $Optional - %9999 = tuple() - return %9999 : $() -} - // Make sure that we can properly handle a switch enum case where the input // argument is an enum, but the final argument is trivial. sil @switch_enum_no_payload_test : $@convention(thin) () -> () { @@ -694,45 +615,6 @@ bb51: return %9999 : $() } -// We check first for objects and then for metatypes. -sil @checked_cast_br_test : $@convention(thin) (@owned Builtin.NativeObject, @guaranteed Builtin.NativeObject) -> () { -bb0(%0 : @owned $Builtin.NativeObject, %6 : @guaranteed $Builtin.NativeObject): - checked_cast_br %0 : $Builtin.NativeObject to $SuperKlass, bb1, bb2 - -bb1(%1 : @owned $SuperKlass): - destroy_value %1 : $SuperKlass - br bb3 - -bb2(%2 : @owned $Builtin.NativeObject): - destroy_value %2 : $Builtin.NativeObject - br bb3 - -bb3: - %3 = metatype $@thick SuperKlass.Type - checked_cast_br %3 : $@thick SuperKlass.Type to $@thick SubKlass.Type, bb4, bb5 - -bb4(%4 : @trivial $@thick SubKlass.Type): - br bb6 - -bb5(%5 : @trivial $@thick SuperKlass.Type): - br bb6 - -bb6: - checked_cast_br %6 : $Builtin.NativeObject to $SuperKlass, bb7, bb8 - -bb7(%7 : @guaranteed $SuperKlass): - end_borrow_argument %7 : $SuperKlass - br bb9 - -bb8(%8 : @guaranteed $Builtin.NativeObject): - end_borrow_argument %8 : $Builtin.NativeObject - br bb9 - -bb9: - %9999 = tuple() - return %9999 : $() -} - sil @dynamic_method_br_test : $@convention(thin) (@owned AnyObject, @thick AnyObject.Type) -> () { bb0(%0 : @owned $AnyObject, %1 : @trivial $@thick AnyObject.Type): %2 = open_existential_ref %0 : $AnyObject to $@opened("01234567-89ab-cdef-0123-000000000000") AnyObject @@ -833,7 +715,7 @@ bb4: bb5(%5 : @guaranteed $ThreeDifferingPayloadEnum): %6 = copy_value %5 : $ThreeDifferingPayloadEnum - end_borrow_argument %5 : $ThreeDifferingPayloadEnum + end_borrow %5 : $ThreeDifferingPayloadEnum return %6 : $ThreeDifferingPayloadEnum } @@ -860,7 +742,7 @@ bb4: bb5(%6 : @guaranteed $ThreeDifferingPayloadEnum): %7 = copy_value %6 : $ThreeDifferingPayloadEnum - end_borrow_argument %6 : $ThreeDifferingPayloadEnum + end_borrow %6 : $ThreeDifferingPayloadEnum end_borrow %1 : $Builtin.NativeObject br bb6(%7 : $ThreeDifferingPayloadEnum) diff --git a/utils/sil-mode.el b/utils/sil-mode.el index bb29bcaf3f5..c8122ce0d32 100644 --- a/utils/sil-mode.el +++ b/utils/sil-mode.el @@ -76,7 +76,7 @@ 'words) . font-lock-keyword-face) ;; SIL Instructions - Borrowing - `(,(regexp-opt '("load_borrow" "begin_borrow" "store_borrow" "end_borrow_argument" "end_borrow") 'words) . font-lock-keyword-face) + `(,(regexp-opt '("load_borrow" "begin_borrow" "store_borrow" "end_borrow") 'words) . font-lock-keyword-face) ;; SIL Instructions - Exclusivity `(,(regexp-opt '("begin_access" "end_access") 'words) . font-lock-keyword-face)