Skip to content

Commit 12ea649

Browse files
Merge pull request swiftlang#21637 from aschwaighofer/remove_escaped_on_convert_escape_to_noescape
SIL: Remove isEscapedByUser flag on convert_escape_to_noescape instruction
2 parents 95e0c66 + cb0c53a commit 12ea649

18 files changed

+25
-70
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,10 @@ class SILBuilder {
927927

928928
ConvertEscapeToNoEscapeInst *
929929
createConvertEscapeToNoEscape(SILLocation Loc, SILValue Op, SILType Ty,
930-
bool isEscapedByUser, bool lifetimeGuaranteed) {
930+
bool lifetimeGuaranteed) {
931931
return insert(ConvertEscapeToNoEscapeInst::create(
932932
getSILDebugLocation(Loc), Op, Ty, getFunction(), C.OpenedArchetypes,
933-
isEscapedByUser, lifetimeGuaranteed));
933+
lifetimeGuaranteed));
934934
}
935935

936936
ThinFunctionToPointerInst *

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,7 @@ void SILCloner<ImplClass>::visitConvertEscapeToNoEscapeInst(
12671267
recordClonedInstruction(
12681268
Inst, getBuilder().createConvertEscapeToNoEscape(
12691269
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()),
1270-
getOpType(Inst->getType()), Inst->isEscapedByUser(),
1271-
Inst->isLifetimeGuaranteed()));
1270+
getOpType(Inst->getType()), Inst->isLifetimeGuaranteed()));
12721271
}
12731272

12741273
template<typename ImplClass>

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,36 +4037,26 @@ class ConvertEscapeToNoEscapeInst final
40374037
friend SILBuilder;
40384038

40394039
bool lifetimeGuaranteed;
4040-
bool isEscaped; // Even if we can analyze this
4041-
// instruction the user might have
4042-
// escaped it.
40434040

40444041
ConvertEscapeToNoEscapeInst(SILDebugLocation DebugLoc, SILValue Operand,
40454042
ArrayRef<SILValue> TypeDependentOperands,
4046-
SILType Ty, bool isEscapedByUser,
4043+
SILType Ty,
40474044
bool isLifetimeGuaranteed)
40484045
: UnaryInstructionWithTypeDependentOperandsBase(
40494046
DebugLoc, Operand, TypeDependentOperands, Ty),
4050-
lifetimeGuaranteed(isLifetimeGuaranteed),
4051-
isEscaped(isEscapedByUser) {
4047+
lifetimeGuaranteed(isLifetimeGuaranteed) {
40524048
assert(!Operand->getType().castTo<SILFunctionType>()->isNoEscape());
40534049
assert(Ty.castTo<SILFunctionType>()->isNoEscape());
40544050
}
40554051

40564052
static ConvertEscapeToNoEscapeInst *
40574053
create(SILDebugLocation DebugLoc, SILValue Operand, SILType Ty,
40584054
SILFunction &F, SILOpenedArchetypesState &OpenedArchetypes,
4059-
bool isEscapedByUser, bool lifetimeGuaranteed);
4055+
bool lifetimeGuaranteed);
40604056
public:
40614057
bool isLifetimeGuaranteed() const {
40624058
return lifetimeGuaranteed;
40634059
}
4064-
4065-
bool isEscapedByUser() const {
4066-
return isEscaped;
4067-
}
4068-
4069-
void setEscapedByUser(bool isEscaped = true) { this->isEscaped = isEscaped; }
40704060
};
40714061

40724062
/// ThinFunctionToPointerInst - Convert a thin function pointer to a

lib/IRGen/LoadableByAddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,7 @@ void LoadableByAddress::recreateConvInstrs() {
26322632
auto instr = cast<ConvertEscapeToNoEscapeInst>(convInstr);
26332633
newInstr = convBuilder.createConvertEscapeToNoEscape(
26342634
instr->getLoc(), instr->getOperand(), newType,
2635-
instr->isEscapedByUser(), instr->isLifetimeGuaranteed());
2635+
instr->isLifetimeGuaranteed());
26362636
break;
26372637
}
26382638
case SILInstructionKind::MarkDependenceInst: {

lib/ParseSIL/ParseSIL.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,20 +3120,15 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
31203120
Identifier ToToken;
31213121
SourceLoc ToLoc;
31223122
bool not_guaranteed = false;
3123-
bool escaped = false;
31243123
bool without_actually_escaping = false;
31253124
if (Opcode == SILInstructionKind::ConvertEscapeToNoEscapeInst) {
31263125
StringRef attrName;
31273126
if (parseSILOptional(attrName, *this)) {
3128-
if (attrName.equals("escaped"))
3129-
escaped = true;
3130-
else if (attrName.equals("not_guaranteed"))
3127+
if (attrName.equals("not_guaranteed"))
31313128
not_guaranteed = true;
31323129
else
31333130
return true;
31343131
}
3135-
if (parseSILOptional(escaped, *this, "escaped"))
3136-
return true;
31373132
}
31383133
if (parseTypedValueRef(Val, B)
31393134
|| parseSILIdentifier(ToToken, ToLoc, diag::expected_tok_in_sil_instr,
@@ -3178,8 +3173,8 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
31783173
B.createConvertFunction(InstLoc, Val, Ty, without_actually_escaping);
31793174
break;
31803175
case SILInstructionKind::ConvertEscapeToNoEscapeInst:
3181-
ResultVal = B.createConvertEscapeToNoEscape(InstLoc, Val, Ty, escaped,
3182-
!not_guaranteed);
3176+
ResultVal =
3177+
B.createConvertEscapeToNoEscape(InstLoc, Val, Ty, !not_guaranteed);
31833178
break;
31843179
case SILInstructionKind::AddressToPointerInst:
31853180
ResultVal = B.createAddressToPointer(InstLoc, Val, Ty);

lib/SIL/SILInstructions.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,18 +1993,16 @@ ConvertFunctionInst *ConvertFunctionInst::create(
19931993

19941994
ConvertEscapeToNoEscapeInst *ConvertEscapeToNoEscapeInst::create(
19951995
SILDebugLocation DebugLoc, SILValue Operand, SILType Ty, SILFunction &F,
1996-
SILOpenedArchetypesState &OpenedArchetypes, bool isEscapedByUser,
1997-
bool isLifetimeGuaranteed) {
1996+
SILOpenedArchetypesState &OpenedArchetypes, bool isLifetimeGuaranteed) {
19981997
SILModule &Mod = F.getModule();
19991998
SmallVector<SILValue, 8> TypeDependentOperands;
20001999
collectTypeDependentOperands(TypeDependentOperands, OpenedArchetypes, F,
20012000
Ty.getASTType());
20022001
unsigned size =
20032002
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size());
20042003
void *Buffer = Mod.allocateInst(size, alignof(ConvertEscapeToNoEscapeInst));
2005-
auto *CFI = ::new (Buffer)
2006-
ConvertEscapeToNoEscapeInst(DebugLoc, Operand, TypeDependentOperands, Ty,
2007-
isEscapedByUser, isLifetimeGuaranteed);
2004+
auto *CFI = ::new (Buffer) ConvertEscapeToNoEscapeInst(
2005+
DebugLoc, Operand, TypeDependentOperands, Ty, isLifetimeGuaranteed);
20082006
// If we do not have lowered SIL, make sure that are not performing
20092007
// ABI-incompatible conversions.
20102008
//

lib/SIL/SILPrinter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,6 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
14141414
}
14151415
void visitConvertEscapeToNoEscapeInst(ConvertEscapeToNoEscapeInst *CI) {
14161416
*this << (CI->isLifetimeGuaranteed() ? "" : "[not_guaranteed] ")
1417-
<< (CI->isEscapedByUser() ? "[escaped] " : "")
14181417
<< getIDAndType(CI->getOperand()) << " to " << CI->getType();
14191418
}
14201419
void visitThinFunctionToPointerInst(ThinFunctionToPointerInst *CI) {

lib/SIL/SILVerifier.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,9 +3683,6 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
36833683
// '[not_guaranteed]' or '[escaped]' attributes.
36843684
if (!SkipConvertEscapeToNoescapeAttributes &&
36853685
F.getModule().getStage() != SILStage::Raw) {
3686-
require(!ICI->isEscapedByUser(),
3687-
"convert_escape_to_noescape [escaped] not "
3688-
"allowed after mandatory passes");
36893686
require(ICI->isLifetimeGuaranteed(),
36903687
"convert_escape_to_noescape [not_guaranteed] not "
36913688
"allowed after mandatory passes");

lib/SILGen/SILGenBridging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ SILGenFunction::emitBlockToFunc(SILLocation loc,
973973
// Handle the escaping to noescape conversion.
974974
assert(loweredFuncTy->isNoEscape());
975975
return B.createConvertEscapeToNoEscape(
976-
loc, thunkedFn, SILType::getPrimitiveObjectType(loweredFuncTy), false);
976+
loc, thunkedFn, SILType::getPrimitiveObjectType(loweredFuncTy));
977977
}
978978

979979
static ManagedValue emitCBridgedToNativeValue(SILGenFunction &SGF,

lib/SILGen/SILGenBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ SILGenBuilder::createConvertFunction(SILLocation loc, ManagedValue fn,
218218
}
219219

220220
ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(
221-
SILLocation loc, ManagedValue fn, SILType resultTy,
222-
bool isEscapedByUser) {
221+
SILLocation loc, ManagedValue fn, SILType resultTy) {
223222

224223
auto fnType = fn.getType().castTo<SILFunctionType>();
225224
auto resultFnType = resultTy.castTo<SILFunctionType>();
@@ -234,8 +233,8 @@ ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(
234233
(void)fnType;
235234
(void)resultFnType;
236235
SILValue fnValue = fn.getValue();
237-
SILValue result = createConvertEscapeToNoEscape(
238-
loc, fnValue, resultTy, isEscapedByUser, false);
236+
SILValue result =
237+
createConvertEscapeToNoEscape(loc, fnValue, resultTy, false);
239238
return ManagedValue::forTrivialObjectRValue(result);
240239
}
241240

0 commit comments

Comments
 (0)