Skip to content

Commit f2b83a3

Browse files
authored
Merge pull request #1244 from swiftwasm/maxd/master-merge
Resolve conflict with master
2 parents 41f5c8e + 8e3501e commit f2b83a3

Some content is hidden

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

41 files changed

+381
-579
lines changed

include/swift/AST/Requirement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Requirement {
142142
case RequirementKind::Conformance:
143143
case RequirementKind::Superclass:
144144
case RequirementKind::SameType:
145-
second = hash_value(requirement.getSecondType());
145+
second = hash_value(requirement.getSecondType().getPointer());
146146
break;
147147

148148
case RequirementKind::Layout:

include/swift/AST/Type.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,6 @@ class Type {
325325
/// Return the name of the type as a string, for use in diagnostics only.
326326
std::string getString(const PrintOptions &PO = PrintOptions()) const;
327327

328-
friend llvm::hash_code hash_value(Type type) {
329-
using llvm::hash_value;
330-
return hash_value(type.getPointer());
331-
}
332-
333328
/// Return the name of the type, adding parens in cases where
334329
/// appending or prepending text to the result would cause that text
335330
/// to be appended to only a portion of the returned type. For
@@ -502,6 +497,10 @@ class CanType : public Type {
502497
bool operator==(CanType T) const { return getPointer() == T.getPointer(); }
503498
bool operator!=(CanType T) const { return !operator==(T); }
504499

500+
friend llvm::hash_code hash_value(CanType T) {
501+
return llvm::hash_value(T.getPointer());
502+
}
503+
505504
bool operator<(CanType T) const { return getPointer() < T.getPointer(); }
506505
};
507506

include/swift/AST/Witness.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ struct TypeWitnessAndDecl {
206206
}
207207

208208
friend llvm::hash_code hash_value(const TypeWitnessAndDecl &owner) {
209-
return llvm::hash_combine(owner.witnessType,
209+
return llvm::hash_combine(owner.witnessType.getPointer(),
210210
owner.witnessDecl);
211211
}
212212

213213
friend bool operator==(const TypeWitnessAndDecl &lhs,
214214
const TypeWitnessAndDecl &rhs) {
215-
return lhs.witnessType->isEqual(rhs.witnessType) &&
215+
return lhs.witnessType.getPointer() == rhs.witnessType.getPointer() &&
216216
lhs.witnessDecl == rhs.witnessDecl;
217217
}
218218

include/swift/Reflection/ReflectionContext.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "swift/Runtime/Unreachable.h"
3535

3636
#include <set>
37-
#include <sstream>
3837
#include <unordered_map>
3938
#include <utility>
4039
#include <vector>
@@ -946,10 +945,12 @@ class ReflectionContext
946945
reinterpret_cast<const MetadataAllocationBacktraceHeader<Runtime> *>(
947946
HeaderBytes.get());
948947
if (HeaderPtr == nullptr) {
949-
std::stringstream stream;
950-
stream << "unable to read Next pointer 0x" << std::hex
951-
<< BacktraceListNext.getAddressData();
952-
return stream.str();
948+
// FIXME: std::stringstream would be better, but LLVM's standard library
949+
// introduces a vtable and we don't want that.
950+
char result[128];
951+
std::snprintf(result, sizeof(result), "unable to read Next pointer %p",
952+
BacktraceListNext.getAddressData());
953+
return std::string(result);
953954
}
954955
auto BacktraceAddrPtr =
955956
BacktraceListNext +

include/swift/SIL/OwnershipUtils.h

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,20 @@ bool isOwnedForwardingInstruction(SILInstruction *inst);
6666
/// previous terminator.
6767
bool isOwnedForwardingValue(SILValue value);
6868

69-
struct BorrowingOperandKind {
70-
enum Kind {
69+
class BorrowingOperandKind {
70+
public:
71+
enum Kind : uint8_t {
7172
BeginBorrow,
7273
BeginApply,
7374
Branch,
7475
};
7576

77+
private:
7678
Kind value;
7779

80+
public:
7881
BorrowingOperandKind(Kind newValue) : value(newValue) {}
79-
BorrowingOperandKind(const BorrowingOperandKind &other)
80-
: value(other.value) {}
82+
8183
operator Kind() const { return value; }
8284

8385
static Optional<BorrowingOperandKind> get(SILInstructionKind kind) {
@@ -207,15 +209,20 @@ struct BorrowingOperand {
207209
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
208210
const BorrowingOperand &operand);
209211

210-
struct BorrowedValueKind {
212+
class BorrowedValueKind {
213+
public:
211214
/// Enum we use for exhaustive pattern matching over borrow scope introducers.
212-
enum Kind {
215+
enum Kind : uint8_t {
213216
LoadBorrow,
214217
BeginBorrow,
215218
SILFunctionArgument,
216219
Phi,
217220
};
218221

222+
private:
223+
Kind value;
224+
225+
public:
219226
static Optional<BorrowedValueKind> get(SILValue value) {
220227
if (value.getOwnershipKind() != ValueOwnershipKind::Guaranteed)
221228
return None;
@@ -240,10 +247,8 @@ struct BorrowedValueKind {
240247
}
241248
}
242249

243-
Kind value;
244-
245250
BorrowedValueKind(Kind newValue) : value(newValue) {}
246-
BorrowedValueKind(const BorrowedValueKind &other) : value(other.value) {}
251+
247252
operator Kind() const { return value; }
248253

249254
/// Is this a borrow scope that begins and ends within the same function and
@@ -383,18 +388,20 @@ bool getAllBorrowIntroducingValues(SILValue value,
383388
/// introducer, then we return a .some(BorrowScopeIntroducingValue).
384389
Optional<BorrowedValue> getSingleBorrowIntroducingValue(SILValue inputValue);
385390

386-
struct InteriorPointerOperandKind {
391+
class InteriorPointerOperandKind {
392+
public:
387393
enum Kind : uint8_t {
388394
RefElementAddr,
389395
RefTailAddr,
390396
OpenExistentialBox,
391397
};
392398

399+
private:
393400
Kind value;
394401

402+
public:
395403
InteriorPointerOperandKind(Kind newValue) : value(newValue) {}
396-
InteriorPointerOperandKind(const InteriorPointerOperandKind &other)
397-
: value(other.value) {}
404+
398405
operator Kind() const { return value; }
399406

400407
static Optional<InteriorPointerOperandKind> get(Operand *use) {
@@ -467,8 +474,9 @@ struct InteriorPointerOperand {
467474
: operand(op), kind(kind) {}
468475
};
469476

470-
struct OwnedValueIntroducerKind {
471-
enum Kind {
477+
class OwnedValueIntroducerKind {
478+
public:
479+
enum Kind : uint8_t {
472480
/// An owned value that is a result of an Apply.
473481
Apply,
474482

@@ -519,6 +527,10 @@ struct OwnedValueIntroducerKind {
519527
AllocRefInit,
520528
};
521529

530+
private:
531+
Kind value;
532+
533+
public:
522534
static Optional<OwnedValueIntroducerKind> get(SILValue value) {
523535
if (value.getOwnershipKind() != ValueOwnershipKind::Owned)
524536
return None;
@@ -569,11 +581,8 @@ struct OwnedValueIntroducerKind {
569581
llvm_unreachable("Default should have caught this");
570582
}
571583

572-
Kind value;
573-
574584
OwnedValueIntroducerKind(Kind newValue) : value(newValue) {}
575-
OwnedValueIntroducerKind(const OwnedValueIntroducerKind &other)
576-
: value(other.value) {}
585+
577586
operator Kind() const { return value; }
578587

579588
void print(llvm::raw_ostream &os) const;

include/swift/SIL/SILDeclRef.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,16 @@ struct SILDeclRef {
397397

398398
bool canBeDynamicReplacement() const;
399399

400+
bool isAutoDiffDerivativeFunction() const {
401+
return derivativeFunctionIdentifier != nullptr;
402+
}
403+
404+
AutoDiffDerivativeFunctionIdentifier *
405+
getAutoDiffDerivativeFunctionIdentifier() const {
406+
assert(isAutoDiffDerivativeFunction());
407+
return derivativeFunctionIdentifier;
408+
}
409+
400410
private:
401411
friend struct llvm::DenseMapInfo<swift::SILDeclRef>;
402412
/// Produces a SILDeclRef from an opaque value.

lib/Basic/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function(generate_revision_inc revision_inc_var name dir)
3434
endfunction()
3535

3636
generate_revision_inc(llvm_revision_inc LLVM "${LLVM_MAIN_SRC_DIR}")
37-
generate_revision_inc(clang_revision_inc Clang "${CLANG_MAIN_SRC_DIR}")
3837
generate_revision_inc(swift_revision_inc Swift "${SWIFT_SOURCE_DIR}")
3938

4039
add_swift_host_library(swiftBasic STATIC

lib/Basic/Version.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,25 @@
4545
#endif
4646

4747
#include "LLVMRevision.inc"
48-
#include "ClangRevision.inc"
4948
#include "SwiftRevision.inc"
5049

5150
namespace swift {
5251
namespace version {
5352

54-
/// Print a string of the form "LLVM xxxxx, Clang yyyyy, Swift zzzzz",
55-
/// where each placeholder is the revision for the associated repository.
53+
/// Print a string of the form "LLVM xxxxx, Swift zzzzz", where each placeholder
54+
/// is the revision for the associated repository.
5655
static void printFullRevisionString(raw_ostream &out) {
57-
// Arbitrarily truncate to 10 characters. This should be enough to unique
58-
// Git hashes for the time being, and certainly enough for SVN revisions,
59-
// while keeping the version string from being ridiculously long.
56+
// Arbitrarily truncate to 15 characters. This should be enough to unique Git
57+
// hashes while keeping the REPL version string from overflowing 80 columns.
6058
#if defined(LLVM_REVISION)
61-
out << "LLVM " << StringRef(LLVM_REVISION).slice(0, 10);
62-
# if defined(CLANG_REVISION) || defined(SWIFT_REVISION)
63-
out << ", ";
64-
# endif
65-
#endif
66-
67-
#if defined(CLANG_REVISION)
68-
out << "Clang " << StringRef(CLANG_REVISION).slice(0, 10);
59+
out << "LLVM " << StringRef(LLVM_REVISION).slice(0, 15);
6960
# if defined(SWIFT_REVISION)
7061
out << ", ";
7162
# endif
7263
#endif
7364

7465
#if defined(SWIFT_REVISION)
75-
out << "Swift " << StringRef(SWIFT_REVISION).slice(0, 10);
66+
out << "Swift " << StringRef(SWIFT_REVISION).slice(0, 15);
7667
#endif
7768
}
7869

@@ -424,8 +415,7 @@ std::string getSwiftFullVersion(Version effectiveVersion) {
424415
OS << " clang-" CLANG_COMPILER_VERSION;
425416
#endif
426417
OS << ")";
427-
#elif defined(LLVM_REVISION) || defined(CLANG_REVISION) || \
428-
defined(SWIFT_REVISION)
418+
#elif defined(LLVM_REVISION) || defined(SWIFT_REVISION)
429419
OS << " (";
430420
printFullRevisionString(OS);
431421
OS << ")";

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7401,7 +7401,9 @@ void SwiftDeclConverter::importInheritedConstructors(
74017401

74027402
Impl.importAttributes(objcMethod, newCtor, curObjCClass);
74037403
newMembers.push_back(newCtor);
7404-
} else if (existing && existing->getClangDecl()) {
7404+
} else if (existing && existing->getInitKind() ==
7405+
CtorInitializerKind::ConvenienceFactory &&
7406+
existing->getClangDecl()) {
74057407
// Check that the existing constructor the prevented new creation is
74067408
// really an inherited factory initializer and not a class member.
74077409
auto existingMD = cast<clang::ObjCMethodDecl>(existing->getClangDecl());

lib/IRGen/GenMeta.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ namespace {
739739
isa<ConstructorDecl>(func.getDecl())
740740
? SILDeclRef::Kind::Allocator
741741
: SILDeclRef::Kind::Func);
742+
if (entry.getFunction().isAutoDiffDerivativeFunction())
743+
declRef = declRef.asAutoDiffDerivativeFunction(
744+
entry.getFunction().getAutoDiffDerivativeFunctionIdentifier());
742745
addDiscriminator(flags, schema, declRef);
743746
}
744747

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ target_sources(swiftSILOptimizer PRIVATE
1212
DiagnoseStaticExclusivity.cpp
1313
DiagnoseUnreachable.cpp
1414
Differentiation.cpp
15-
GuaranteedARCOpts.cpp
1615
IRGenPrepare.cpp
1716
MandatoryInlining.cpp
1817
PredictableMemOpt.cpp

0 commit comments

Comments
 (0)