Skip to content

Commit f9f114f

Browse files
authored
---
yaml --- r: 286651 b: refs/heads/master-next c: 99753a7 h: refs/heads/master i: 286649: 5a50b00 286647: 6109041
1 parent 3420702 commit f9f114f

File tree

17 files changed

+263
-206
lines changed

17 files changed

+263
-206
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: a67ffadd758dfc7a0f10a8afde063b8864663208
3-
refs/heads/master-next: ec3a8f59d1373f0565759b33908715d53cc12e58
3+
refs/heads/master-next: 99753a762011cdac18890d7bd53e9adf4a5b9ee4
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/SIL/AccessedStorage.def

Lines changed: 0 additions & 39 deletions
This file was deleted.

branches/master-next/include/swift/SIL/MemAccessUtils.h

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,15 @@ class AccessedStorage {
106106
/// Enumerate over all valid begin_access bases. Clients can use a covered
107107
/// switch to warn if findAccessedAddressBase ever adds a case.
108108
enum Kind : uint8_t {
109-
#define ACCESSED_STORAGE(Name) Name,
110-
#define ACCESSED_STORAGE_RANGE(Name, Start, End) \
111-
First_##Name = Start, Last_##Name = End,
112-
#include "swift/SIL/AccessedStorage.def"
113-
NumKindBits = countBitsUsed(unsigned(Last_AccessedStorageKind))
109+
Box,
110+
Stack,
111+
Global,
112+
Class,
113+
Argument,
114+
Yield,
115+
Nested,
116+
Unidentified,
117+
NumKindBits = countBitsUsed(static_cast<unsigned>(Unidentified))
114118
};
115119

116120
static const char *getKindName(Kind k);
@@ -322,26 +326,6 @@ class AccessedStorage {
322326
bool operator==(const AccessedStorage &) const = delete;
323327
bool operator!=(const AccessedStorage &) const = delete;
324328
};
325-
326-
template <class ImplTy, class ResultTy = void, typename... ArgTys>
327-
class AccessedStorageVisitor {
328-
ImplTy &asImpl() { return static_cast<ImplTy &>(*this); }
329-
330-
public:
331-
#define ACCESSED_STORAGE(Name) \
332-
ResultTy visit##Name(const AccessedStorage &storage, ArgTys &&... args);
333-
#include "swift/SIL/AccessedStorage.def"
334-
335-
ResultTy visit(const AccessedStorage &storage, ArgTys &&... args) {
336-
switch (storage.getKind()) {
337-
#define ACCESSED_STORAGE(Name) \
338-
case AccessedStorage::Name: \
339-
return asImpl().visit##Name(storage, std::forward<ArgTys>(args)...);
340-
#include "swift/SIL/AccessedStorage.def"
341-
}
342-
}
343-
};
344-
345329
} // end namespace swift
346330

347331
namespace llvm {

branches/master-next/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,23 @@
2424
extern "C" {
2525
#endif
2626

27-
typedef uint64_t swift_typeref_t;
27+
// Pointers used here need to be pointer-sized on watchOS for binary
28+
// compatibility. Everywhere else, they are 64-bit so 32-bit processes can
29+
// potentially read from 64-bit processes.
30+
#if defined(__APPLE__) && defined(__MACH__)
31+
#include <TargetConditionals.h>
32+
#if TARGET_OS_WATCH
33+
#define SWIFT_REFLECTION_NATIVE_POINTERS 1
34+
#endif
35+
#endif
36+
37+
#if SWIFT_REFLECTION_NATIVE_POINTERS
38+
typedef uintptr_t swift_reflection_ptr_t;
39+
#else
40+
typedef uint64_t swift_reflection_ptr_t;
41+
#endif
42+
43+
typedef swift_reflection_ptr_t swift_typeref_t;
2844

2945
/// Represents one of the Swift reflection sections of an image.
3046
typedef struct swift_reflection_section {
@@ -37,37 +53,37 @@ typedef struct swift_reflection_section {
3753
typedef struct swift_reflection_info {
3854
struct {
3955
swift_reflection_section_t section;
40-
uint64_t offset;
56+
swift_reflection_ptr_t offset;
4157
} field;
4258

4359
struct {
4460
swift_reflection_section_t section;
45-
uint64_t offset;
61+
swift_reflection_ptr_t offset;
4662
} associated_types;
4763

4864
struct {
4965
swift_reflection_section_t section;
50-
uint64_t offset;
66+
swift_reflection_ptr_t offset;
5167
} builtin_types;
5268

5369
struct {
5470
swift_reflection_section_t section;
55-
uint64_t offset;
71+
swift_reflection_ptr_t offset;
5672
} capture;
5773

5874
struct {
5975
swift_reflection_section_t section;
60-
uint64_t offset;
76+
swift_reflection_ptr_t offset;
6177
} type_references;
6278

6379
struct {
6480
swift_reflection_section_t section;
65-
uint64_t offset;
81+
swift_reflection_ptr_t offset;
6682
} reflection_strings;
6783

6884
// Start address in local and remote address spaces.
69-
uint64_t LocalStartAddress;
70-
uint64_t RemoteStartAddress;
85+
swift_reflection_ptr_t LocalStartAddress;
86+
swift_reflection_ptr_t RemoteStartAddress;
7187
} swift_reflection_info_t;
7288

7389
/// The layout kind of a Swift type.

branches/master-next/lib/SIL/MemAccessUtils.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,22 @@ const ValueDecl *AccessedStorage::getDecl(SILFunction *F) const {
140140

141141
const char *AccessedStorage::getKindName(AccessedStorage::Kind k) {
142142
switch (k) {
143-
#define ACCESSED_STORAGE(NAME) \
144-
case AccessedStorage::NAME: \
145-
return #NAME;
146-
#include "swift/SIL/AccessedStorage.def"
143+
case Box:
144+
return "Box";
145+
case Stack:
146+
return "Stack";
147+
case Nested:
148+
return "Nested";
149+
case Unidentified:
150+
return "Unidentified";
151+
case Argument:
152+
return "Argument";
153+
case Yield:
154+
return "Yield";
155+
case Global:
156+
return "Global";
157+
case Class:
158+
return "Class";
147159
}
148160
llvm_unreachable("unhandled kind");
149161
}

branches/master-next/lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -339,56 +339,29 @@ bool SemanticARCOptVisitor::visitCopyValueInst(CopyValueInst *cvi) {
339339
// load [copy] Optimizations
340340
//===----------------------------------------------------------------------===//
341341

342-
/// A flow insensitive analysis that tells the load [copy] analysis if the
343-
/// storage has 0, 1, >1 writes to it.
344-
///
345-
/// In the case of 0 writes, we return CanOptimizeLoadCopyResult::Always.
346-
///
347-
/// In the case of 1 write, we return OnlyIfStorageIsLocal. We are taking
348-
/// advantage of definite initialization implying that an alloc_stack must be
349-
/// written to once before any loads from the memory location. Thus if we are
350-
/// local and see 1 write, we can still change to load_borrow if all other uses
351-
/// check out.
352-
///
353-
/// If there is 2+ writes, we can not optimize = (.
354-
namespace {
355-
356-
struct CanOptimizeLoadCopyFromAccessVisitor
357-
: AccessedStorageVisitor<CanOptimizeLoadCopyFromAccessVisitor, bool> {
358-
SILFunction &f;
359-
360-
CanOptimizeLoadCopyFromAccessVisitor(SILFunction &f) : f(f) {}
361-
362-
// Stubs
363-
bool visitBox(const AccessedStorage &boxStorage) { return false; }
364-
bool visitStack(const AccessedStorage &stackStorage) { return false; }
365-
bool visitGlobal(const AccessedStorage &globalStorage) { return false; }
366-
bool visitClass(const AccessedStorage &classStorage) { return false; }
367-
bool visitYield(const AccessedStorage &yieldStorage) { return false; }
368-
bool visitUnidentified(const AccessedStorage &unidentifiedStorage) {
369-
return false;
370-
}
371-
bool visitNested(const AccessedStorage &nested) {
372-
llvm_unreachable("Visitor should never see nested since we lookup our "
373-
"address storage using lookup non nested");
374-
}
375-
376-
bool visitArgument(const AccessedStorage &argumentStorage);
377-
};
378-
379-
} // namespace
342+
// A flow insensitive analysis that tells the load [copy] analysis if the
343+
// storage has 0, 1, >1 writes to it.
344+
//
345+
// In the case of 0 writes, we return CanOptimizeLoadCopyResult::Always.
346+
//
347+
// In the case of 1 write, we return OnlyIfStorageIsLocal. We are taking
348+
// advantage of definite initialization implying that an alloc_stack must be
349+
// written to once before any loads from the memory location. Thus if we are
350+
// local and see 1 write, we can still change to load_borrow if all other uses
351+
// check out.
352+
//
353+
// If there is 2+ writes, we can not optimize = (.
380354

381-
bool CanOptimizeLoadCopyFromAccessVisitor::visitArgument(
382-
const AccessedStorage &storage) {
355+
bool mayFunctionMutateArgument(const AccessedStorage &storage, SILFunction &f) {
383356
auto *arg = cast<SILFunctionArgument>(storage.getArgument(&f));
384357

385358
// Then check if we have an in_guaranteed argument. In this case, we can
386359
// always optimize load [copy] from this.
387360
if (arg->hasConvention(SILArgumentConvention::Indirect_In_Guaranteed))
388-
return true;
361+
return false;
389362

390363
// For now just return false.
391-
return false;
364+
return true;
392365
}
393366

394367
static bool isWrittenTo(SILFunction &f, SILValue value) {
@@ -402,7 +375,19 @@ static bool isWrittenTo(SILFunction &f, SILValue value) {
402375
// way (ignoring stores that are obviously the only initializer to
403376
// memory). We have to do this since load_borrow assumes that the
404377
// underlying memory is never written to.
405-
return !CanOptimizeLoadCopyFromAccessVisitor(f).visit(storage);
378+
switch (storage.getKind()) {
379+
case AccessedStorage::Box:
380+
case AccessedStorage::Stack:
381+
case AccessedStorage::Global:
382+
case AccessedStorage::Class:
383+
case AccessedStorage::Yield:
384+
case AccessedStorage::Nested:
385+
case AccessedStorage::Unidentified:
386+
return true;
387+
388+
case AccessedStorage::Argument:
389+
return mayFunctionMutateArgument(storage, f);
390+
}
406391
}
407392

408393
// Convert a load [copy] from unique storage [read] that has all uses that can

branches/master-next/lib/Sema/CSApply.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5678,20 +5678,27 @@ Expr *ExprRewriter::coerceCallArguments(
56785678
continue;
56795679
}
56805680

5681-
auto isAutoClosureArg = [](Expr *arg) -> bool {
5682-
if (auto *DRE = dyn_cast<DeclRefExpr>(arg)) {
5683-
if (auto *PD = dyn_cast<ParamDecl>(DRE->getDecl()))
5684-
return PD->isAutoClosure();
5681+
Expr *convertedArg = nullptr;
5682+
auto argRequiresAutoClosureExpr = [&](const AnyFunctionType::Param &param,
5683+
Type argType) {
5684+
if (!param.isAutoClosure())
5685+
return false;
5686+
5687+
// Since it was allowed to pass function types to @autoclosure
5688+
// parameters in Swift versions < 5, it has to be handled as
5689+
// a regular function coversion by `coerceToType`.
5690+
if (isAutoClosureArgument(arg)) {
5691+
// In Swift >= 5 mode we only allow `@autoclosure` arguments
5692+
// to be used by value if parameter would return a function
5693+
// type (it just needs to get wrapped into autoclosure expr),
5694+
// otherwise argument must always form a call.
5695+
return cs.getASTContext().isSwiftVersionAtLeast(5);
56855696
}
5686-
return false;
5697+
5698+
return true;
56875699
};
56885700

5689-
Expr *convertedArg = nullptr;
5690-
// Since it was allowed to pass function types to @autoclosure
5691-
// parameters in Swift versions < 5, it has to be handled as
5692-
// a regular function coversion by `coerceToType`.
5693-
if (param.isAutoClosure() && (!argType->is<FunctionType>() ||
5694-
!isAutoClosureArg(arg))) {
5701+
if (argRequiresAutoClosureExpr(param, argType)) {
56955702
assert(!param.isInOut());
56965703

56975704
// If parameter is an autoclosure, we need to make sure that:

branches/master-next/lib/Sema/CSDiagnostics.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,14 @@ bool MissingCallFailure::diagnoseAsError() {
17601760
return true;
17611761
}
17621762

1763+
case ConstraintLocator::FunctionResult: {
1764+
path = path.drop_back();
1765+
if (path.back().getKind() != ConstraintLocator::AutoclosureResult)
1766+
break;
1767+
1768+
LLVM_FALLTHROUGH;
1769+
}
1770+
17631771
case ConstraintLocator::AutoclosureResult: {
17641772
auto &cs = getConstraintSystem();
17651773
auto loc = cs.getConstraintLocator(getRawAnchor(), path.drop_back(),

0 commit comments

Comments
 (0)