Skip to content

Commit 91b2abe

Browse files
authored
Merge pull request #60531 from apple/pull-request-rebranch
Merge `rebranch` into `main` to support llvm-project `stable/20220421`
2 parents 822174e + 59db203 commit 91b2abe

File tree

122 files changed

+591
-497
lines changed

Some content is hidden

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

122 files changed

+591
-497
lines changed

include/swift/ABI/Metadata.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,7 @@ struct TargetMetadata {
429429
#endif
430430

431431
#ifndef NDEBUG
432-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
433-
"Only meant for use in the debugger");
432+
[[deprecated("Only meant for use in the debugger")]] void dump() const;
434433
#endif
435434

436435
protected:
@@ -2710,8 +2709,7 @@ struct TargetContextDescriptor {
27102709
}
27112710

27122711
#ifndef NDEBUG
2713-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
2714-
"only for use in the debugger");
2712+
[[deprecated("Only meant for use in the debugger")]] void dump() const;
27152713
#endif
27162714

27172715
private:
@@ -2976,8 +2974,7 @@ struct TargetProtocolDescriptor final
29762974
}
29772975

29782976
#ifndef NDEBUG
2979-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
2980-
"only for use in the debugger");
2977+
[[deprecated("Only meant for use in the debugger")]] void dump() const;
29812978
#endif
29822979

29832980
static bool classof(const TargetContextDescriptor<Runtime> *cd) {
@@ -4449,8 +4446,7 @@ class TargetEnumDescriptor final
44494446
}
44504447

44514448
#ifndef NDEBUG
4452-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
4453-
"Only meant for use in the debugger");
4449+
[[deprecated("Only meant for use in the debugger")]] void dump() const;
44544450
#endif
44554451
};
44564452

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/ABI/KeyPath.h"
2323
#include "swift/ABI/ProtocolDispatchStrategy.h"
2424
#include "swift/AST/Ownership.h"
25+
#include "swift/Basic/Debug.h"
2526
#include "swift/Basic/LLVM.h"
2627
#include "swift/Basic/FlagSet.h"
2728
#include "llvm/ADT/ArrayRef.h"
@@ -531,8 +532,7 @@ class ProtocolDescriptorFlags {
531532
}
532533

533534
#ifndef NDEBUG
534-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
535-
"Only for use in the debugger");
535+
SWIFT_DEBUG_DUMP;
536536
#endif
537537
};
538538

include/swift/AST/AutoDiff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ using swift::SILFunctionType;
705705
using swift::DifferentiabilityKind;
706706
using swift::SILDifferentiabilityWitnessKey;
707707

708-
template <typename T> struct DenseMapInfo;
708+
template <typename T, typename Enable> struct DenseMapInfo;
709709

710710
template <> struct DenseMapInfo<AutoDiffConfig> {
711711
static AutoDiffConfig getEmptyKey() {

include/swift/AST/Identifier.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,7 @@ class DeclNameRef {
778778
llvm::raw_ostream &printPretty(llvm::raw_ostream &os) const;
779779

780780
/// Dump this name to standard error.
781-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
782-
"only for use within the debugger");
781+
SWIFT_DEBUG_DUMP;
783782
};
784783

785784
inline DeclNameRef DeclNameRef::getFromOpaqueValue(void *p) {

include/swift/Basic/Debug.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
/// This deprecates the method so it won't be called directly and marks it as
2121
/// used so it won't be eliminated as dead code.
2222
#define SWIFT_DEBUG_HELPER(method) \
23-
LLVM_ATTRIBUTE_DEPRECATED(method LLVM_ATTRIBUTE_USED, \
24-
"only for use in the debugger")
23+
[[deprecated("only for use in the debugger")]] method LLVM_ATTRIBUTE_USED
2524

2625
/// Declares a const void instance method with the name and parameters provided.
2726
/// Methods declared with this macro should never be called except in the

include/swift/Basic/LangOptions.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,16 @@ namespace swift {
535535
/// This is only implemented on certain OSs. If no target has been
536536
/// configured, returns v0.0.0.
537537
llvm::VersionTuple getMinPlatformVersion() const {
538-
unsigned major = 0, minor = 0, revision = 0;
539538
if (Target.isMacOSX()) {
540-
Target.getMacOSXVersion(major, minor, revision);
539+
llvm::VersionTuple OSVersion;
540+
Target.getMacOSXVersion(OSVersion);
541+
return OSVersion;
541542
} else if (Target.isiOS()) {
542-
Target.getiOSVersion(major, minor, revision);
543+
return Target.getiOSVersion();
543544
} else if (Target.isWatchOS()) {
544-
Target.getOSVersion(major, minor, revision);
545+
return Target.getOSVersion();
545546
}
546-
return llvm::VersionTuple(major, minor, revision);
547+
return llvm::VersionTuple(/*Major=*/0, /*Minor=*/0, /*Subminor=*/0);
547548
}
548549

549550
/// Sets an implicit platform condition.

include/swift/Basic/Located.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool operator ==(const Located<T> &lhs, const Located<T> &rhs) {
5555

5656
namespace llvm {
5757

58-
template <typename T> struct DenseMapInfo;
58+
template <typename T, typename Enable> struct DenseMapInfo;
5959

6060
template<typename T>
6161
struct DenseMapInfo<swift::Located<T>> {

include/swift/Basic/SourceLoc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class CharSourceRange {
248248
} // end namespace swift
249249

250250
namespace llvm {
251-
template <typename T> struct DenseMapInfo;
251+
template <typename T, typename Enable> struct DenseMapInfo;
252252

253253
template <> struct DenseMapInfo<swift::SourceLoc> {
254254
static swift::SourceLoc getEmptyKey() {

include/swift/ClangImporter/SwiftAbstractBasicReader.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class DataStreamBasicReader
8989
clang::QualType type = asImpl().readTypeRef();
9090
return getASTContext().getQualifiedType(type, quals);
9191
}
92+
93+
const clang::BTFTypeTagAttr *readBTFTypeTagAttr() {
94+
llvm::report_fatal_error("Read BTFTypeTagAttr that should never have been"
95+
" serialized");
96+
}
9297
};
9398

9499
}

include/swift/ClangImporter/SwiftAbstractBasicWriter.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define SWIFT_CLANGIMPORTER_SWIFTABSTRACTBASICWRITER_H
2222

2323
#include "clang/AST/AbstractTypeWriter.h"
24+
#include "clang/AST/Type.h"
2425

2526
namespace swift {
2627

@@ -80,11 +81,24 @@ class DataStreamBasicWriter
8081
assert(!type.isNull());
8182

8283
auto split = type.split();
83-
asImpl().writeQualifiers(split.Quals);
84+
auto qualifiers = split.Quals;
8485

86+
// Unwrap BTFTagAttributeType and merge any of its qualifiers.
87+
while (auto btfType = dyn_cast<clang::BTFTagAttributedType>(split.Ty)) {
88+
split = btfType->getWrappedType().split();
89+
qualifiers.addQualifiers(split.Quals);
90+
}
91+
92+
asImpl().writeQualifiers(qualifiers);
8593
// Just recursively visit the given type.
8694
asImpl().writeTypeRef(split.Ty);
8795
}
96+
97+
void writeBTFTypeTagAttr(const clang::BTFTypeTagAttr *attr) {
98+
// BTFTagAttributeType is explicitly unwrapped above, so we should never
99+
// hit any of its attributes.
100+
llvm::report_fatal_error("Should never hit BTFTypeTagAttr serialization");
101+
}
88102
};
89103

90104
}

include/swift/Demangling/Demangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
#include "swift/Demangling/NamespaceMacros.h"
2424
#include "llvm/ADT/StringRef.h"
2525
#include "llvm/Support/Compiler.h"
26+
2627
#include <cassert>
2728
#include <cstdint>
29+
#include <functional>
2830
#include <memory>
2931
#include <string>
3032

include/swift/Runtime/ExistentialContainer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ struct TargetOpaqueExistentialContainer {
6868

6969
/// Dump information about this specific box and its contents. Only intended
7070
/// for use in the debugger.
71-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
72-
"Only meant for use in the debugger");
71+
[[deprecated("Only meant for use in the debugger")]] void dump() const;
7372
#endif
7473
};
7574
using OpaqueExistentialContainer = TargetOpaqueExistentialContainer<InProcess>;

include/swift/SIL/SILRemarkStreamer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "swift/Basic/SourceManager.h"
2323
#include "swift/SIL/OptimizationRemark.h"
24+
#include "llvm/Remarks/Remark.h"
2425
#include "llvm/Remarks/RemarkStreamer.h"
2526

2627
namespace swift {

include/swift/SIL/SILType.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ class SILType {
200200

201201
public:
202202
// FIXME -- Temporary until LLDB adopts getASTType()
203-
LLVM_ATTRIBUTE_DEPRECATED(CanType getSwiftRValueType() const,
204-
"Please use getASTType()") {
203+
[[deprecated("Please use getASTType()")]] CanType getSwiftRValueType() const {
205204
return getASTType();
206205
}
207206

include/swift/SIL/SILValue.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef SWIFT_SIL_SILVALUE_H
1818
#define SWIFT_SIL_SILVALUE_H
1919

20+
#include "swift/Basic/Debug.h"
2021
#include "swift/Basic/Range.h"
2122
#include "swift/Basic/ArrayRefView.h"
2223
#include "swift/Basic/STLExtras.h"
@@ -668,16 +669,15 @@ class SILValue {
668669
/// NOTE: This is implemented in ValueOwnership.cpp not SILValue.cpp.
669670
///
670671
/// FIXME: remove this redundant API from SILValue.
671-
LLVM_ATTRIBUTE_DEPRECATED(
672-
ValueOwnershipKind getOwnershipKind()
673-
const { return Value->getOwnershipKind(); },
674-
"Please use ValueBase::getOwnershipKind()");
672+
[[deprecated("Please use ValueBase::getOwnershipKind()")]] ValueOwnershipKind
673+
getOwnershipKind() const {
674+
return Value->getOwnershipKind();
675+
};
675676

676677
/// Verify that this SILValue and its uses respects ownership invariants.
677678
void verifyOwnership(DeadEndBlocks *DEBlocks) const;
678679

679-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
680-
"Only for use in the debugger");
680+
SWIFT_DEBUG_DUMP;
681681
};
682682

683683
inline SILNodePointer::SILNodePointer(SILValue value) : node(value) { }
@@ -1107,10 +1107,8 @@ class Operand {
11071107
SILBasicBlock *getParentBlock() const;
11081108
SILFunction *getParentFunction() const;
11091109

1110-
LLVM_ATTRIBUTE_DEPRECATED(
1111-
void dump() const LLVM_ATTRIBUTE_USED,
1112-
"Dump the operand's state. Only for use in the debugger!");
11131110
void print(llvm::raw_ostream &os) const;
1111+
SWIFT_DEBUG_DUMP;
11141112

11151113
private:
11161114
void removeFromCurrent() {

include/swift/Serialization/SerializationOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ namespace swift {
2929
SerializationOptions &operator=(SerializationOptions &&) = default;
3030
~SerializationOptions() = default;
3131

32-
const char *OutputPath = nullptr;
33-
const char *DocOutputPath = nullptr;
34-
const char *SourceInfoOutputPath = nullptr;
32+
StringRef OutputPath;
33+
StringRef DocOutputPath;
34+
StringRef SourceInfoOutputPath;
3535
std::string ABIDescriptorPath;
3636
bool emptyABIDescriptor = false;
3737
llvm::VersionTuple UserModuleVersion;

lib/AST/Builtins.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,8 @@ Type IntrinsicTypeDecoder::decodeImmediate() {
21032103
case IITDescriptor::VecOfBitcastsToInt:
21042104
case IITDescriptor::Subdivide2Argument:
21052105
case IITDescriptor::Subdivide4Argument:
2106+
case IITDescriptor::PPCQuad:
2107+
case IITDescriptor::AnyPtrToElt:
21062108
// These types cannot be expressed in swift yet.
21072109
return Type();
21082110

lib/Basic/LangOptions.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,12 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
260260
llvm::raw_svector_ostream osx(osxBuf);
261261
osx << llvm::Triple::getOSTypeName(llvm::Triple::MacOSX);
262262

263-
unsigned major, minor, micro;
264-
triple.getMacOSXVersion(major, minor, micro);
265-
osx << major << "." << minor;
266-
if (micro != 0)
267-
osx << "." << micro;
263+
llvm::VersionTuple OSVersion;
264+
triple.getMacOSXVersion(OSVersion);
265+
266+
osx << OSVersion.getMajor() << "." << OSVersion.getMinor().getValueOr(0);
267+
if (auto Subminor = OSVersion.getSubminor())
268+
osx << "." << *Subminor;
268269

269270
triple.setOSName(osx.str());
270271
}

lib/Basic/Platform.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,14 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
181181
case llvm::Triple::Ananas:
182182
case llvm::Triple::CloudABI:
183183
case llvm::Triple::DragonFly:
184+
case llvm::Triple::DriverKit:
184185
case llvm::Triple::Emscripten:
185186
case llvm::Triple::Fuchsia:
186187
case llvm::Triple::KFreeBSD:
187188
case llvm::Triple::Lv2:
188189
case llvm::Triple::NetBSD:
190+
case llvm::Triple::PS5:
191+
case llvm::Triple::ShaderModel:
189192
case llvm::Triple::Solaris:
190193
case llvm::Triple::Minix:
191194
case llvm::Triple::RTEMS:
@@ -395,11 +398,13 @@ llvm::Triple swift::getUnversionedTriple(const llvm::Triple &triple) {
395398
Optional<llvm::VersionTuple>
396399
swift::getSwiftRuntimeCompatibilityVersionForTarget(
397400
const llvm::Triple &Triple) {
398-
unsigned Major, Minor, Micro;
399401
#define MAX(a, b) ((a) > (b) ? (a) : (b))
400402

401403
if (Triple.isMacOSX()) {
402-
Triple.getMacOSXVersion(Major, Minor, Micro);
404+
llvm::VersionTuple OSVersion;
405+
Triple.getMacOSXVersion(OSVersion);
406+
unsigned Major = OSVersion.getMajor();
407+
unsigned Minor = OSVersion.getMinor().getValueOr(0);
403408

404409
auto floorFor64 = [&Triple](llvm::VersionTuple v) {
405410
if (!Triple.isAArch64()) return v;
@@ -414,7 +419,7 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
414419
if (Minor <= 14) {
415420
return floorFor64(llvm::VersionTuple(5, 0));
416421
} else if (Minor <= 15) {
417-
if (Micro <= 3) {
422+
if (OSVersion.getSubminor().getValueOr(0) <= 3) {
418423
return floorFor64(llvm::VersionTuple(5, 1));
419424
} else {
420425
return floorFor64(llvm::VersionTuple(5, 2));
@@ -429,7 +434,9 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
429434
return floorFor64(llvm::VersionTuple(5, 5));
430435
}
431436
} else if (Triple.isiOS()) { // includes tvOS
432-
Triple.getiOSVersion(Major, Minor, Micro);
437+
llvm::VersionTuple OSVersion = Triple.getiOSVersion();
438+
unsigned Major = OSVersion.getMajor();
439+
unsigned Minor = OSVersion.getMinor().getValueOr(0);
433440

434441
auto floorForArchitecture = [&Triple, Major](llvm::VersionTuple v) {
435442
// arm64 simulators and macCatalyst are introduced in iOS 14.0/tvOS 14.0
@@ -463,13 +470,16 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
463470
return floorForArchitecture(llvm::VersionTuple(5, 5));
464471
}
465472
} else if (Triple.isWatchOS()) {
473+
llvm::VersionTuple OSVersion = Triple.getWatchOSVersion();
474+
unsigned Major = OSVersion.getMajor();
475+
unsigned Minor = OSVersion.getMinor().getValueOr(0);
476+
466477
auto floorFor64bits = [&Triple](llvm::VersionTuple v) {
467478
if (!Triple.isArch64Bit()) return v;
468479
// 64-bit watchOS was introduced with Swift 5.3
469480
return MAX(v, llvm::VersionTuple(5, 3));
470481
};
471482

472-
Triple.getWatchOSVersion(Major, Minor, Micro);
473483
if (Major <= 5) {
474484
return floorFor64bits(llvm::VersionTuple(5, 0));
475485
} else if (Major <= 6) {

0 commit comments

Comments
 (0)