Skip to content

Commit d1c3a55

Browse files
committed
---
yaml --- r: 343725 b: refs/heads/master-rebranch c: a9af910 h: refs/heads/master i: 343723: d2b5711
1 parent 28ec72a commit d1c3a55

35 files changed

+300
-642
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 111fb37f743ea8467a9f583636fec5f9520477aa
1458+
refs/heads/master-rebranch: a9af910664e529c521dc4659f26bf8dd81021ffd
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,11 +2680,6 @@ ERROR(rethrows_without_throwing_parameter,none,
26802680
ERROR(autoclosure_function_type,none,
26812681
"@autoclosure attribute only applies to function types",
26822682
())
2683-
2684-
ERROR(invalid_autoclosure_and_convention_attributes,none,
2685-
"'@convention(%0)' attribute is not allowed on '@autoclosure' types",
2686-
(StringRef))
2687-
26882683
ERROR(autoclosure_function_input_nonunit,none,
26892684
"argument type of @autoclosure parameter must be '()'", ())
26902685

branches/master-rebranch/include/swift/Basic/Defer.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@
1818
#ifndef SWIFT_BASIC_DEFER_H
1919
#define SWIFT_BASIC_DEFER_H
2020

21-
#include "llvm/ADT/ScopeExit.h"
21+
#include <type_traits>
2222

2323
namespace swift {
24+
template <typename F>
25+
class DoAtScopeExit {
26+
F Fn;
27+
void operator=(DoAtScopeExit&) = delete;
28+
public:
29+
DoAtScopeExit(F &&Fn) : Fn(std::move(Fn)) {}
30+
~DoAtScopeExit() {
31+
Fn();
32+
}
33+
};
34+
2435
namespace detail {
2536
struct DeferTask {};
2637
template<typename F>
27-
auto operator+(DeferTask, F &&fn) ->
28-
decltype(llvm::make_scope_exit(std::forward<F>(fn))) {
29-
return llvm::make_scope_exit(std::forward<F>(fn));
38+
DoAtScopeExit<typename std::decay<F>::type> operator+(DeferTask, F&& fn) {
39+
return DoAtScopeExit<typename std::decay<F>::type>(std::move(fn));
3040
}
3141
}
3242
} // end namespace swift

branches/master-rebranch/include/swift/Parse/ParsedRawSyntaxNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class ParsedRawSyntaxNode {
141141
case DataKind::DeferredLayout:
142142
return getDeferredLayoutRange();
143143
case DataKind::DeferredToken:
144-
return getDeferredTokenRange();
144+
return getDeferredTokenRangeWithoutBackticks();
145145
default:
146146
llvm_unreachable("node not deferred");
147147
}
@@ -194,7 +194,7 @@ class ParsedRawSyntaxNode {
194194

195195
return CharSourceRange{begin, len};
196196
}
197-
CharSourceRange getDeferredTokenRange() const {
197+
CharSourceRange getDeferredTokenRangeWithoutBackticks() const {
198198
assert(DK == DataKind::DeferredToken);
199199
return CharSourceRange{DeferredToken.TokLoc, DeferredToken.TokLength};
200200
}

branches/master-rebranch/include/swift/Parse/Parser.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,25 @@ class Parser {
695695
/// plain Tok.is(T1) check).
696696
bool skipUntilTokenOrEndOfLine(tok T1);
697697

698+
void ignoreToken();
699+
void ignoreToken(tok Kind) {
700+
assert(Tok.is(Kind));
701+
ignoreToken();
702+
}
703+
bool ignoreIf(tok Kind) {
704+
if (!Tok.is(Kind))
705+
return false;
706+
ignoreToken();
707+
return true;
708+
}
709+
void ignoreSingle();
710+
void ignoreUntil(tok Kind);
711+
712+
/// Ignore tokens until a token that starts with '>', and return true it if
713+
/// found. Applies heuristics that are suitable when trying to find the end
714+
/// of a list of generic parameters, generic arguments.
715+
bool ignoreUntilGreaterInTypeList();
716+
698717
/// If the parser is generating only a syntax tree, try loading the current
699718
/// node from a previously generated syntax tree.
700719
/// Returns \c true if the node has been loaded and inserted into the current

branches/master-rebranch/include/swift/Parse/Token.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,17 @@ class Token {
248248
return CharSourceRange(getLoc(), getLength());
249249
}
250250

251+
CharSourceRange getRangeWithoutBackticks() const {
252+
SourceLoc TokLoc = getLoc();
253+
unsigned TokLength = getLength();
254+
if (isEscapedIdentifier()) {
255+
// Adjust to account for the backticks.
256+
TokLoc = TokLoc.getAdvancedLoc(1);
257+
TokLength -= 2;
258+
}
259+
return CharSourceRange(TokLoc, TokLength);
260+
}
261+
251262
bool hasComment() const {
252263
return CommentLength != 0;
253264
}

branches/master-rebranch/include/swift/Syntax/TokenSyntax.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ class TokenSyntax final : public Syntax {
8080
return getRaw()->getTokenText();
8181
}
8282

83-
StringRef getIdentifierText() const {
84-
StringRef text = getText();
85-
if (text.front() == '`') {
86-
assert(text.back() == '`');
87-
return text.slice(1, text.size() - 1);
88-
}
89-
return text;
90-
}
91-
9283
static bool kindof(SyntaxKind Kind) {
9384
return isTokenKind(Kind);
9485
}

branches/master-rebranch/lib/IRGen/GenExistential.cpp

Lines changed: 36 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,12 @@ namespace {
789789

790790

791791
static llvm::Constant *getAssignBoxedOpaqueExistentialBufferFunction(
792-
IRGenModule &IGM, OpaqueExistentialLayout existLayout);
792+
IRGenModule &IGM, OpaqueExistentialLayout existLayout,
793+
llvm::Type *existContainerPointerTy);
793794

794795
static llvm::Constant *getDestroyBoxedOpaqueExistentialBufferFunction(
795-
IRGenModule &IGM, OpaqueExistentialLayout existLayout);
796+
IRGenModule &IGM, OpaqueExistentialLayout existLayout,
797+
llvm::Type *existContainerPointerTy);
796798

797799
static llvm::Constant *
798800
getProjectBoxedOpaqueExistentialFunction(IRGenFunction &IGF,
@@ -841,14 +843,13 @@ class OpaqueExistentialTypeInfo final :
841843
void assignWithCopy(IRGenFunction &IGF, Address dest, Address src, SILType T,
842844
bool isOutlined) const override {
843845

846+
auto objPtrTy = dest.getAddress()->getType();
847+
844848
// Use copy-on-write existentials?
845849
auto fn = getAssignBoxedOpaqueExistentialBufferFunction(
846-
IGF.IGM, getLayout());
847-
auto *type = IGF.IGM.getExistentialPtrTy(getLayout().getNumTables());
848-
auto *destAddr = IGF.Builder.CreateBitCast(dest.getAddress(), type);
849-
auto *srcAddr = IGF.Builder.CreateBitCast(src.getAddress(), type);
850+
IGF.IGM, getLayout(), objPtrTy);
850851
auto call =
851-
IGF.Builder.CreateCall(fn, {destAddr, srcAddr});
852+
IGF.Builder.CreateCall(fn, {dest.getAddress(), src.getAddress()});
852853
call->setCallingConv(IGF.IGM.DefaultCC);
853854
call->setDoesNotThrow();
854855
return;
@@ -903,15 +904,12 @@ class OpaqueExistentialTypeInfo final :
903904
}
904905
}
905906

906-
void destroy(IRGenFunction &IGF, Address buffer, SILType T,
907+
void destroy(IRGenFunction &IGF, Address addr, SILType T,
907908
bool isOutlined) const override {
908909
// Use copy-on-write existentials?
909910
auto fn = getDestroyBoxedOpaqueExistentialBufferFunction(
910-
IGF.IGM, getLayout());
911-
auto *addr = IGF.Builder.CreateBitCast(
912-
buffer.getAddress(),
913-
IGF.IGM.getExistentialPtrTy(getLayout().getNumTables()));
914-
auto call = IGF.Builder.CreateCall(fn, {addr});
911+
IGF.IGM, getLayout(), addr.getAddress()->getType());
912+
auto call = IGF.Builder.CreateCall(fn, {addr.getAddress()});
915913
call->setCallingConv(IGF.IGM.DefaultCC);
916914
call->setDoesNotThrow();
917915
return;
@@ -1357,36 +1355,6 @@ createErrorExistentialTypeInfo(IRGenModule &IGM,
13571355
refcounting);
13581356
}
13591357

1360-
llvm::Type *TypeConverter::getExistentialType(unsigned numWitnessTables) {
1361-
llvm::StructType *&type = OpaqueExistentialTypes[numWitnessTables];
1362-
if (type)
1363-
return type;
1364-
1365-
SmallVector<llvm::Type*, 5> fields;
1366-
1367-
fields.push_back(IGM.getFixedBufferTy());
1368-
fields.push_back(IGM.TypeMetadataPtrTy);
1369-
1370-
for (auto i : range(numWitnessTables)) {
1371-
fields.push_back(IGM.WitnessTablePtrTy);
1372-
(void) i;
1373-
}
1374-
1375-
llvm::SmallString<40> typeName;
1376-
llvm::raw_svector_ostream(typeName)
1377-
<< "__opaque_existential_type_"
1378-
<< numWitnessTables;
1379-
1380-
type = llvm::StructType::create(IGM.getLLVMContext(), StringRef(typeName));
1381-
type->setBody(fields);
1382-
1383-
return type;
1384-
}
1385-
1386-
llvm::PointerType *IRGenModule::getExistentialPtrTy(unsigned numTables) {
1387-
return Types.getExistentialType(numTables)->getPointerTo();
1388-
}
1389-
13901358
static const TypeInfo *createExistentialTypeInfo(IRGenModule &IGM, CanType T) {
13911359
auto layout = T.getExistentialLayout();
13921360

@@ -1799,26 +1767,24 @@ void irgen::emitExistentialMetatypeContainer(IRGenFunction &IGF,
17991767
});
18001768
}
18011769

1802-
void irgen::emitMetatypeOfOpaqueExistential(IRGenFunction &IGF, Address buffer,
1770+
void irgen::emitMetatypeOfOpaqueExistential(IRGenFunction &IGF, Address addr,
18031771
SILType type, Explosion &out) {
18041772
assert(type.isExistentialType());
18051773
assert(!type.isClassExistentialType());
18061774
auto &baseTI = IGF.getTypeInfo(type).as<OpaqueExistentialTypeInfo>();
18071775

18081776
// Get the static metadata.
18091777
auto existLayout = baseTI.getLayout();
1810-
llvm::Value *metadata = existLayout.loadMetadataRef(IGF, buffer);
1778+
llvm::Value *metadata = existLayout.loadMetadataRef(IGF, addr);
18111779

18121780
// Project the buffer and apply the 'typeof' value witness.
1781+
Address buffer = existLayout.projectExistentialBuffer(IGF, addr);
18131782
llvm::Value *object;
18141783

1815-
auto *addr = IGF.Builder.CreateBitCast(
1816-
buffer.getAddress(),
1817-
IGF.IGM.getExistentialPtrTy(existLayout.getNumTables()));
18181784
auto *projectFunc = getProjectBoxedOpaqueExistentialFunction(
18191785
IGF, OpenedExistentialAccess::Immutable, existLayout);
18201786
auto *addrOfValue =
1821-
IGF.Builder.CreateCall(projectFunc, {addr, metadata});
1787+
IGF.Builder.CreateCall(projectFunc, {buffer.getAddress(), metadata});
18221788
addrOfValue->setCallingConv(IGF.IGM.DefaultCC);
18231789
addrOfValue->setDoesNotThrow();
18241790
object = addrOfValue;
@@ -1830,7 +1796,7 @@ void irgen::emitMetatypeOfOpaqueExistential(IRGenFunction &IGF, Address buffer,
18301796
out.add(dynamicType);
18311797

18321798
// Get the witness tables.
1833-
baseTI.emitLoadOfTables(IGF, buffer, out);
1799+
baseTI.emitLoadOfTables(IGF, addr, out);
18341800
}
18351801

18361802
void irgen::emitMetatypeOfBoxedExistential(IRGenFunction &IGF, Explosion &value,
@@ -2001,9 +1967,10 @@ static Address castToOpaquePtr(IRGenFunction &IGF, Address addr) {
20011967
}
20021968

20031969
static llvm::Constant *getAllocateBoxedOpaqueExistentialBufferFunction(
2004-
IRGenModule &IGM, OpaqueExistentialLayout existLayout) {
1970+
IRGenModule &IGM, OpaqueExistentialLayout existLayout,
1971+
llvm::Type *existContainerPointerTy) {
20051972

2006-
llvm::Type *argTys[] = {IGM.getExistentialPtrTy(existLayout.getNumTables())};
1973+
llvm::Type *argTys[] = {existContainerPointerTy};
20071974

20081975
// __swift_allocate_boxed_opaque_existential__N is the well-known function for
20091976
// allocating buffers in existential containers of types with N witness
@@ -2084,22 +2051,20 @@ Address irgen::emitAllocateBoxedOpaqueExistentialBuffer(
20842051
}
20852052
/// Call a function to handle the non-fixed case.
20862053
auto *allocateFun = getAllocateBoxedOpaqueExistentialBufferFunction(
2087-
IGF.IGM, existLayout);
2088-
auto *existentialAddr = IGF.Builder.CreateBitCast(
2089-
existentialContainer.getAddress(),
2090-
IGF.IGM.getExistentialPtrTy(existLayout.getNumTables()));
2054+
IGF.IGM, existLayout, existentialContainer.getAddress()->getType());
20912055
auto *call =
2092-
IGF.Builder.CreateCall(allocateFun, {existentialAddr});
2056+
IGF.Builder.CreateCall(allocateFun, {existentialContainer.getAddress()});
20932057
call->setCallingConv(IGF.IGM.DefaultCC);
20942058
call->setDoesNotThrow();
20952059
auto addressOfValue = IGF.Builder.CreateBitCast(call, valuePointerType);
20962060
return valueTI.getAddressForPointer(addressOfValue);
20972061
}
20982062

20992063
static llvm::Constant *getDeallocateBoxedOpaqueExistentialBufferFunction(
2100-
IRGenModule &IGM, OpaqueExistentialLayout existLayout) {
2064+
IRGenModule &IGM, OpaqueExistentialLayout existLayout,
2065+
llvm::Type *existContainerPointerTy) {
21012066

2102-
llvm::Type *argTys[] = {IGM.getExistentialPtrTy(existLayout.getNumTables())};
2067+
llvm::Type *argTys[] = {existContainerPointerTy};
21032068

21042069
// __swift_deallocate_boxed_opaque_existential_N is the well-known function
21052070
// for deallocating buffers in existential containers of types with N witness
@@ -2176,11 +2141,9 @@ void irgen::emitDeallocateBoxedOpaqueExistentialBuffer(
21762141
OpaqueExistentialLayout existLayout = existentialTI.getLayout();
21772142

21782143
auto *deallocateFun = getDeallocateBoxedOpaqueExistentialBufferFunction(
2179-
IGF.IGM, existLayout);
2180-
auto *bufferAddr = IGF.Builder.CreateBitCast(
2181-
existentialContainer.getAddress(),
2182-
IGF.IGM.getExistentialPtrTy(existLayout.getNumTables()));
2183-
auto *call = IGF.Builder.CreateCall(deallocateFun, {bufferAddr});
2144+
IGF.IGM, existLayout, existentialContainer.getAddress()->getType());
2145+
auto *call = IGF.Builder.CreateCall(deallocateFun,
2146+
{existentialContainer.getAddress()});
21842147
call->setCallingConv(IGF.IGM.DefaultCC);
21852148
call->setDoesNotThrow();
21862149
return;
@@ -2192,7 +2155,7 @@ getProjectBoxedOpaqueExistentialFunction(IRGenFunction &IGF,
21922155
OpaqueExistentialLayout existLayout) {
21932156

21942157
auto &IGM = IGF.IGM;
2195-
auto *existentialBufferTy = IGM.getExistentialPtrTy(existLayout.getNumTables());
2158+
auto *existentialBufferTy = IGM.getFixedBufferTy()->getPointerTo();
21962159
llvm::Type *argTys[] = {existentialBufferTy, IGM.TypeMetadataPtrTy};
21972160

21982161
// __swift_project_boxed_opaque_existential_N is the well-known function for
@@ -2315,13 +2278,11 @@ Address irgen::emitOpaqueBoxedExistentialProjection(
23152278
wtables);
23162279
}
23172280

2281+
Address buffer = layout.projectExistentialBuffer(IGF, base);
23182282
auto *projectFunc =
23192283
getProjectBoxedOpaqueExistentialFunction(IGF, accessKind, layout);
2320-
auto *bufferAddr = IGF.Builder.CreateBitCast(
2321-
base.getAddress(),
2322-
IGF.IGM.getExistentialPtrTy(layout.getNumTables()));
23232284
auto *addrOfValue =
2324-
IGF.Builder.CreateCall(projectFunc, {bufferAddr, metadata});
2285+
IGF.Builder.CreateCall(projectFunc, {buffer.getAddress(), metadata});
23252286
addrOfValue->setCallingConv(IGF.IGM.DefaultCC);
23262287
addrOfValue->setDoesNotThrow();
23272288

@@ -2348,10 +2309,10 @@ static void initBufferWithCopyOfReference(IRGenFunction &IGF,
23482309
}
23492310

23502311
static llvm::Constant *getAssignBoxedOpaqueExistentialBufferFunction(
2351-
IRGenModule &IGM, OpaqueExistentialLayout existLayout) {
2312+
IRGenModule &IGM, OpaqueExistentialLayout existLayout,
2313+
llvm::Type *existContainerPointerTy) {
23522314

2353-
llvm::Type *argTys[] = {IGM.getExistentialPtrTy(existLayout.getNumTables()),
2354-
IGM.getExistentialPtrTy(existLayout.getNumTables())};
2315+
llvm::Type *argTys[] = {existContainerPointerTy, existContainerPointerTy};
23552316

23562317
// __swift_assign_box_in_existentials_N is the well-known function for
23572318
// assigning buffers in existential containers of types with N witness
@@ -2567,9 +2528,10 @@ static llvm::Constant *getAssignBoxedOpaqueExistentialBufferFunction(
25672528
}
25682529

25692530
static llvm::Constant *getDestroyBoxedOpaqueExistentialBufferFunction(
2570-
IRGenModule &IGM, OpaqueExistentialLayout existLayout) {
2531+
IRGenModule &IGM, OpaqueExistentialLayout existLayout,
2532+
llvm::Type *existContainerPointerTy) {
25712533

2572-
llvm::Type *argTys[] = {IGM.getExistentialPtrTy(existLayout.getNumTables())};
2534+
llvm::Type *argTys[] = {existContainerPointerTy};
25732535

25742536
llvm::SmallString<40> fnName;
25752537
llvm::raw_svector_ostream(fnName)

branches/master-rebranch/lib/IRGen/GenType.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ class TypeConverter {
117117
llvm::StringMap<YAMLTypeInfoNode> LegacyTypeInfos;
118118
llvm::DenseMap<NominalTypeDecl *, std::string> DeclMangledNames;
119119

120-
/// The key is the number of witness tables.
121-
llvm::DenseMap<unsigned, llvm::StructType *> OpaqueExistentialTypes;
122-
123120
const LoadableTypeInfo *createPrimitive(llvm::Type *T,
124121
Size size, Alignment align);
125122
const LoadableTypeInfo *createPrimitiveForAlignedPointer(llvm::PointerType *T,
@@ -185,8 +182,6 @@ class TypeConverter {
185182
bool isOptional);
186183
#include "swift/AST/ReferenceStorage.def"
187184

188-
llvm::Type *getExistentialType(unsigned numWitnessTables);
189-
190185
/// Enter a generic context for lowering the parameters of a generic function
191186
/// type.
192187
void pushGenericContext(CanGenericSignature signature);

branches/master-rebranch/lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ class IRGenModule {
725725
ReferenceCounting style) const;
726726

727727
llvm::Type *getFixedBufferTy();
728-
llvm::PointerType *getExistentialPtrTy(unsigned numTables);
729728
llvm::Type *getValueWitnessTy(ValueWitness index);
730729
Signature getValueWitnessSignature(ValueWitness index);
731730

0 commit comments

Comments
 (0)