Skip to content

Commit 1fbfdd9

Browse files
authored
---
yaml --- r: 210439 b: refs/heads/swift-5.0-branch c: dbcab4b h: refs/heads/master i: 210437: 617ae28 210435: 2de1810 210431: 6e2f0eb
1 parent 99cc6e6 commit 1fbfdd9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+566
-160
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2017-12-23-a: b7c074342459a645779f106c42bf4
644644
refs/heads/master-llvm-swift5-transition: 8ace18c8953afb3d7d94cf04cacc0b51a7e5f1e3
645645
"refs/heads/revert-12883-disable_modelio_test_ios": a77ae373b809a0d8cb460cf3d1585d618510d242
646646
refs/heads/revert-13597-master: cccee1df039d072215f9bddc2cbc1e32a8d5d5ee
647-
refs/heads/swift-5.0-branch: 73895a3f22852058512f850c8f8635b0fe3a1959
647+
refs/heads/swift-5.0-branch: dbcab4b0029f494063fffe3271043764a35b4f14
648648
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2017-12-23-a: b32214f7e04339dfada623b6b76dbebfb41e4541
649649
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2017-12-24-a: 1eb0be506c0744c7eff0550a10240286046e181d
650650
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2017-12-25-a: f35a91502bad0065c83d8760407c23be7b899f48

branches/swift-5.0-branch/cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,11 @@ function(_add_variant_c_compile_link_flags)
123123
list(APPEND result "-target" "${SWIFT_SDK_${CFLAGS_SDK}_ARCH_${CFLAGS_ARCH}_TRIPLE}${DEPLOYMENT_VERSION}")
124124
endif()
125125

126+
set(_sysroot "${SWIFT_SDK_${CFLAGS_SDK}_ARCH_${CFLAGS_ARCH}_PATH}")
126127
if(IS_DARWIN)
127-
list(APPEND result "-isysroot" "${SWIFT_SDK_${CFLAGS_SDK}_PATH}")
128-
elseif(NOT SWIFT_COMPILER_IS_MSVC_LIKE AND NOT "${SWIFT_SDK_${CFLAGS_SDK}_PATH}" STREQUAL "/")
129-
list(APPEND result "--sysroot=${SWIFT_SDK_${CFLAGS_SDK}_PATH}")
128+
list(APPEND result "-isysroot" "${_sysroot}")
129+
elseif(NOT SWIFT_COMPILER_IS_MSVC_LIKE AND NOT "${_sysroot}" STREQUAL "/")
130+
list(APPEND result "--sysroot=${_sysroot}")
130131
endif()
131132

132133
if("${CFLAGS_SDK}" STREQUAL "ANDROID")
@@ -294,9 +295,9 @@ function(_add_variant_swift_compile_flags
294295
sdk arch build_type enable_assertions result_var_name)
295296
set(result ${${result_var_name}})
296297

297-
# On Windows, we don't set SWIFT_SDK_WINDOWS_PATH, so don't include it.
298+
# On Windows, we don't set SWIFT_SDK_WINDOWS_PATH_ARCH_{ARCH}_PATH, so don't include it.
298299
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
299-
list(APPEND result "-sdk" "${SWIFT_SDK_${sdk}_PATH}")
300+
list(APPEND result "-sdk" "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}")
300301
endif()
301302

302303
is_darwin_based_sdk("${sdk}" IS_DARWIN)
@@ -314,7 +315,7 @@ function(_add_variant_swift_compile_flags
314315

315316
if(IS_DARWIN)
316317
list(APPEND result
317-
"-F" "${SWIFT_SDK_${sdk}_PATH}/../../../Developer/Library/Frameworks")
318+
"-F" "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/../../../Developer/Library/Frameworks")
318319
endif()
319320

320321
is_build_type_optimized("${build_type}" optimized)
@@ -1619,7 +1620,7 @@ function(add_swift_library name)
16191620
# Add PrivateFrameworks, rdar://28466433
16201621
set(swiftlib_link_flags_all ${SWIFTLIB_LINK_FLAGS})
16211622
if(SWIFTLIB_IS_SDK_OVERLAY)
1622-
list(APPEND swiftlib_swift_compile_flags_all "-Fsystem" "${SWIFT_SDK_${sdk}_PATH}/System/Library/PrivateFrameworks/")
1623+
list(APPEND swiftlib_swift_compile_flags_all "-Fsystem" "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/System/Library/PrivateFrameworks/")
16231624
endif()
16241625

16251626
if("${sdk}" STREQUAL "IOS_SIMULATOR")

branches/swift-5.0-branch/cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ function(_report_sdk prefix)
2222
message(STATUS " ${arch} LIB: ${${arch}_LIB}")
2323
endforeach()
2424
else()
25-
message(STATUS " Path: ${SWIFT_SDK_${prefix}_PATH}")
2625
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
2726
message(STATUS " ${arch} Path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_PATH}")
2827
endforeach()
@@ -145,7 +144,6 @@ macro(configure_sdk_unix
145144

146145
# Todo: this only supports building an SDK for one target arch only.
147146
set(SWIFT_SDK_${prefix}_NAME "${name}")
148-
set(SWIFT_SDK_${prefix}_PATH "${sdkpath}")
149147
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "${sdkpath}")
150148
set(SWIFT_SDK_${prefix}_VERSION "don't use")
151149
set(SWIFT_SDK_${prefix}_BUILD_NUMBER "don't use")
@@ -173,10 +171,6 @@ macro(configure_sdk_windows prefix sdk_name environment architectures)
173171
# variables.
174172

175173
set(SWIFT_SDK_${prefix}_NAME "${sdk_name}")
176-
# NOTE: set the path to / to avoid a spurious `--sysroot` from being passed
177-
# to the driver -- rely on the `INCLUDE` AND `LIB` environment variables
178-
# instead.
179-
set(SWIFT_SDK_${prefix}_PATH "/")
180174
set(SWIFT_SDK_${prefix}_VERSION "NOTFOUND")
181175
set(SWIFT_SDK_${prefix}_BUILD_NUMBER "NOTFOUND")
182176
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "")
@@ -194,6 +188,9 @@ macro(configure_sdk_windows prefix sdk_name environment architectures)
194188
set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE
195189
"${arch}-unknown-windows-${environment}")
196190
endif()
191+
# NOTE: set the path to / to avoid a spurious `--sysroot` from being passed
192+
# to the driver -- rely on the `INCLUDE` AND `LIB` environment variables
193+
# instead.
197194
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/")
198195
endforeach()
199196

branches/swift-5.0-branch/include/swift/SIL/SILBuilder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,11 @@ class SILBuilder {
794794
}
795795

796796
ConvertEscapeToNoEscapeInst *
797-
createConvertEscapeToNoEscape(SILLocation Loc, SILValue Op, SILType Ty) {
797+
createConvertEscapeToNoEscape(SILLocation Loc, SILValue Op, SILType Ty,
798+
bool lifetimeGuaranteed) {
798799
return insert(ConvertEscapeToNoEscapeInst::create(
799-
getSILDebugLocation(Loc), Op, Ty, getFunction(), OpenedArchetypes));
800+
getSILDebugLocation(Loc), Op, Ty, getFunction(), OpenedArchetypes,
801+
lifetimeGuaranteed));
800802
}
801803

802804
ThinFunctionToPointerInst *

branches/swift-5.0-branch/include/swift/SIL/SILCloner.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,10 +984,10 @@ template <typename ImplClass>
984984
void SILCloner<ImplClass>::visitConvertEscapeToNoEscapeInst(
985985
ConvertEscapeToNoEscapeInst *Inst) {
986986
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
987-
doPostProcess(Inst, getBuilder().createConvertEscapeToNoEscape(
988-
getOpLocation(Inst->getLoc()),
989-
getOpValue(Inst->getOperand()),
990-
getOpType(Inst->getType())));
987+
doPostProcess(
988+
Inst, getBuilder().createConvertEscapeToNoEscape(
989+
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()),
990+
getOpType(Inst->getType()), Inst->isLifetimeGuaranteed()));
991991
}
992992

993993
template<typename ImplClass>

branches/swift-5.0-branch/include/swift/SIL/SILInstruction.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3951,18 +3951,26 @@ class ConvertEscapeToNoEscapeInst final
39513951
ConvertEscapeToNoEscapeInst, ConversionInst> {
39523952
friend SILBuilder;
39533953

3954+
bool lifetimeGuaranteed;
3955+
39543956
ConvertEscapeToNoEscapeInst(SILDebugLocation DebugLoc, SILValue Operand,
3955-
ArrayRef<SILValue> TypeDependentOperands,
3956-
SILType Ty)
3957+
ArrayRef<SILValue> TypeDependentOperands,
3958+
SILType Ty, bool isLifetimeGuaranteed)
39573959
: UnaryInstructionWithTypeDependentOperandsBase(
3958-
DebugLoc, Operand, TypeDependentOperands, Ty) {
3960+
DebugLoc, Operand, TypeDependentOperands, Ty),
3961+
lifetimeGuaranteed(isLifetimeGuaranteed) {
39593962
assert(!Operand->getType().castTo<SILFunctionType>()->isNoEscape());
39603963
assert(Ty.castTo<SILFunctionType>()->isNoEscape());
39613964
}
39623965

39633966
static ConvertEscapeToNoEscapeInst *
39643967
create(SILDebugLocation DebugLoc, SILValue Operand, SILType Ty,
3965-
SILFunction &F, SILOpenedArchetypesState &OpenedArchetypes);
3968+
SILFunction &F, SILOpenedArchetypesState &OpenedArchetypes,
3969+
bool lifetimeGuaranteed);
3970+
public:
3971+
bool isLifetimeGuaranteed() const {
3972+
return lifetimeGuaranteed;
3973+
}
39663974
};
39673975

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

branches/swift-5.0-branch/include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const uint16_t VERSION_MAJOR = 0;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
5858

59-
const uint16_t VERSION_MINOR = 406; // Last change: EnumElementDecl resilience expansion
59+
const uint16_t VERSION_MINOR = 407; // Last change: convert_escape_to_noescape
6060

6161
using DeclIDField = BCFixed<31>;
6262

branches/swift-5.0-branch/lib/AST/DeclContext.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,14 @@ static Type computeExtensionType(const ExtensionDecl *ED, DeclTypeKind kind) {
146146
return type->getAnyNominal()->getDeclaredType();
147147
case DeclTypeKind::DeclaredTypeInContext:
148148
return type;
149-
case DeclTypeKind::DeclaredInterfaceType:
149+
case DeclTypeKind::DeclaredInterfaceType: {
150150
// FIXME: Need a sugar-preserving getExtendedInterfaceType for extensions
151-
return type->getAnyNominal()->getDeclaredInterfaceType();
151+
if (auto nominal = type->getAnyNominal())
152+
return nominal->getDeclaredInterfaceType();
153+
154+
auto typealias = cast<TypeAliasDecl>(type->getAnyGeneric());
155+
return typealias->getUnderlyingTypeLoc().getType();
156+
}
152157
}
153158

154159
llvm_unreachable("Unhandled DeclTypeKind in switch.");

branches/swift-5.0-branch/lib/IDE/SourceEntityWalker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ bool SemaAnnotator::walkToDeclPost(Decl *D) {
197197
ExtDecls.pop_back();
198198
}
199199

200-
if (!isa<ValueDecl>(D) && !isa<ExtensionDecl>(D) && !isa<ImportDecl>(D))
200+
if (!isa<ValueDecl>(D) && !isa<ExtensionDecl>(D) && !isa<ImportDecl>(D) &&
201+
!isa<IfConfigDecl>(D))
201202
return true;
202203

203204
bool Continue = SEWalker.walkToDeclPost(D);

branches/swift-5.0-branch/lib/IRGen/LoadableByAddress.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,8 @@ void LoadableByAddress::recreateConvInstrs() {
24952495
case SILInstructionKind::ConvertEscapeToNoEscapeInst: {
24962496
auto instr = cast<ConvertEscapeToNoEscapeInst>(convInstr);
24972497
newInstr = convBuilder.createConvertEscapeToNoEscape(
2498-
instr->getLoc(), instr->getOperand(), newType);
2498+
instr->getLoc(), instr->getOperand(), newType,
2499+
instr->isLifetimeGuaranteed());
24992500
break;
25002501
}
25012502
case SILInstructionKind::MarkDependenceInst: {

branches/swift-5.0-branch/lib/ParseSIL/ParseSIL.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2979,6 +2979,10 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
29792979
SILType Ty;
29802980
Identifier ToToken;
29812981
SourceLoc ToLoc;
2982+
bool guaranteed = true;
2983+
if (Opcode == SILInstructionKind::ConvertEscapeToNoEscapeInst)
2984+
if(parseSILOptional(guaranteed, *this, "not_guaranteed"))
2985+
return true;
29822986
if (parseTypedValueRef(Val, B) ||
29832987
parseSILIdentifier(ToToken, ToLoc,
29842988
diag::expected_tok_in_sil_instr, "to") ||
@@ -3012,7 +3016,7 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
30123016
ResultVal = B.createConvertFunction(InstLoc, Val, Ty);
30133017
break;
30143018
case SILInstructionKind::ConvertEscapeToNoEscapeInst:
3015-
ResultVal = B.createConvertEscapeToNoEscape(InstLoc, Val, Ty);
3019+
ResultVal = B.createConvertEscapeToNoEscape(InstLoc, Val, Ty, guaranteed);
30163020
break;
30173021
case SILInstructionKind::AddressToPointerInst:
30183022
ResultVal = B.createAddressToPointer(InstLoc, Val, Ty);

branches/swift-5.0-branch/lib/SIL/SILInstructions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ ConvertFunctionInst::create(SILDebugLocation DebugLoc, SILValue Operand,
19981998

19991999
ConvertEscapeToNoEscapeInst *ConvertEscapeToNoEscapeInst::create(
20002000
SILDebugLocation DebugLoc, SILValue Operand, SILType Ty, SILFunction &F,
2001-
SILOpenedArchetypesState &OpenedArchetypes) {
2001+
SILOpenedArchetypesState &OpenedArchetypes, bool isLifetimeGuaranteed) {
20022002
SILModule &Mod = F.getModule();
20032003
SmallVector<SILValue, 8> TypeDependentOperands;
20042004
collectTypeDependentOperands(TypeDependentOperands, OpenedArchetypes, F,
@@ -2007,7 +2007,7 @@ ConvertEscapeToNoEscapeInst *ConvertEscapeToNoEscapeInst::create(
20072007
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size());
20082008
void *Buffer = Mod.allocateInst(size, alignof(ConvertEscapeToNoEscapeInst));
20092009
auto *CFI = ::new (Buffer) ConvertEscapeToNoEscapeInst(
2010-
DebugLoc, Operand, TypeDependentOperands, Ty);
2010+
DebugLoc, Operand, TypeDependentOperands, Ty, isLifetimeGuaranteed);
20112011
// If we do not have lowered SIL, make sure that are not performing
20122012
// ABI-incompatible conversions.
20132013
//

branches/swift-5.0-branch/lib/SIL/SILPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
14351435
printUncheckedConversionInst(CI, CI->getOperand());
14361436
}
14371437
void visitConvertEscapeToNoEscapeInst(ConvertEscapeToNoEscapeInst *CI) {
1438-
printUncheckedConversionInst(CI, CI->getOperand());
1438+
*this << (CI->isLifetimeGuaranteed() ? "" : "[not_guaranteed] ")
1439+
<< getIDAndType(CI->getOperand()) << " to " << CI->getType();
14391440
}
14401441
void visitThinFunctionToPointerInst(ThinFunctionToPointerInst *CI) {
14411442
printUncheckedConversionInst(CI, CI->getOperand());

branches/swift-5.0-branch/lib/SILGen/SILGenBuilder.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ ManagedValue SILGenBuilder::createConvertFunction(SILLocation loc,
207207
return cloner.clone(result);
208208
}
209209

210-
ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(SILLocation loc,
211-
ManagedValue fn,
212-
SILType resultTy) {
210+
ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(
211+
SILLocation loc, ManagedValue fn, SILType resultTy,
212+
bool postponeToNoEscapeCleanup) {
213+
213214
auto fnType = fn.getType().castTo<SILFunctionType>();
214215
auto resultFnType = resultTy.castTo<SILFunctionType>();
215216

@@ -221,9 +222,13 @@ ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(SILLocation loc,
221222
!fnType->isNoEscape() && resultFnType->isNoEscape() &&
222223
"Expect a escaping to noescape conversion");
223224

224-
SILValue fnValue = fn.ensurePlusOne(SGF, loc).forward(SGF);
225-
SILValue result = createConvertEscapeToNoEscape(loc, fnValue, resultTy);
226-
getSILGenFunction().enterPostponedCleanup(fnValue);
225+
SILValue fnValue = postponeToNoEscapeCleanup
226+
? fn.ensurePlusOne(SGF, loc).forward(SGF)
227+
: fn.getValue();
228+
SILValue result = createConvertEscapeToNoEscape(loc, fnValue, resultTy,
229+
postponeToNoEscapeCleanup);
230+
if (postponeToNoEscapeCleanup)
231+
getSILGenFunction().enterPostponedCleanup(fnValue);
227232
return ManagedValue::forTrivialObjectRValue(result);
228233
}
229234

branches/swift-5.0-branch/lib/SILGen/SILGenBuilder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ class SILGenBuilder : public SILBuilder {
361361
SILType resultTy);
362362

363363
using SILBuilder::createConvertEscapeToNoEscape;
364-
ManagedValue createConvertEscapeToNoEscape(SILLocation loc, ManagedValue fn,
365-
SILType resultTy);
364+
ManagedValue
365+
createConvertEscapeToNoEscape(SILLocation loc, ManagedValue fn,
366+
SILType resultTy,
367+
bool postponeToNoEscapeCleanup = true);
366368

367369
using SILBuilder::createStore;
368370
/// Forward \p value into \p address.

branches/swift-5.0-branch/lib/SILGen/SILGenExpr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,8 +2090,11 @@ RValue RValueEmitter::visitFunctionConversionExpr(FunctionConversionExpr *e,
20902090
if (srcRepTy != srcTy)
20912091
result = convertFunctionRepresentation(SGF, e, result, srcRepTy, srcTy);
20922092

2093-
if (srcTy != destTy)
2094-
result = SGF.emitTransformedValue(e, result, srcTy, destTy);
2093+
if (srcTy != destTy) {
2094+
bool postponeToNoEscapeCleanup = !isa<BindOptionalExpr>(e->getSubExpr());
2095+
result = SGF.emitTransformedValue(e, result, srcTy, destTy, SGFContext(),
2096+
postponeToNoEscapeCleanup);
2097+
}
20952098

20962099
if (destTy != destRepTy)
20972100
result = convertFunctionRepresentation(SGF, e, result, destTy, destRepTy);

branches/swift-5.0-branch/lib/SILGen/SILGenFunction.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,15 +1617,17 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
16171617
ManagedValue emitTransformedValue(SILLocation loc, ManagedValue input,
16181618
CanType inputType,
16191619
CanType outputType,
1620-
SGFContext ctx = SGFContext());
1620+
SGFContext ctx = SGFContext(),
1621+
bool postponeToNoEscapeCleanup = true);
16211622

16221623
/// Most general form of the above.
16231624
ManagedValue emitTransformedValue(SILLocation loc, ManagedValue input,
16241625
AbstractionPattern inputOrigType,
16251626
CanType inputSubstType,
16261627
AbstractionPattern outputOrigType,
16271628
CanType outputSubstType,
1628-
SGFContext ctx = SGFContext());
1629+
SGFContext ctx = SGFContext(),
1630+
bool postponeToNoEscapeCleanup = true);
16291631
RValue emitTransformedValue(SILLocation loc, RValue &&input,
16301632
AbstractionPattern inputOrigType,
16311633
CanType inputSubstType,

0 commit comments

Comments
 (0)