Skip to content

Commit aa6a588

Browse files
authored
Merge pull request #69163 from apple/rebranch
Merge `rebranch` into `main` to support `stable/20230725` llvm-project branch
2 parents e950a2f + 69c807a commit aa6a588

File tree

395 files changed

+19845
-2450
lines changed

Some content is hidden

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

395 files changed

+19845
-2450
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ How swift-C++ bridging code is compiled:
353353
DEFAULT: based on the build configuration
354354
]=] DEFAULT)
355355

356+
option(SWIFT_USE_SYMLINKS "Use symlinks instead of copying binaries" ${CMAKE_HOST_UNIX})
357+
set(SWIFT_COPY_OR_SYMLINK "copy")
358+
if(SWIFT_USE_SYMLINKS)
359+
set(SWIFT_COPY_OR_SYMLINK "create_symlink")
360+
endif()
361+
356362
# The following only works with the Ninja generator in CMake >= 3.0.
357363
set(SWIFT_PARALLEL_LINK_JOBS "" CACHE STRING
358364
"Define the maximum number of linker jobs for swift.")
@@ -1333,6 +1339,15 @@ endif()
13331339
add_subdirectory(include)
13341340

13351341
if(SWIFT_INCLUDE_TOOLS)
1342+
1343+
# TODO Remove this once release/5.9 is done and we can finish migrating Swift
1344+
# off of `llvm::None`/`llvm::Optional`, and `llvm::makeArrayRef`.
1345+
# This is to silence the avalanche of deprecation warnings from LLVM headers
1346+
# until we can actually do something about them. This is nasty, but it's
1347+
# better than losing context due to the sheer number in-actionable deprecation
1348+
# warnings or the massive number of merge-conflicts we would get otherwise.
1349+
add_definitions(-DSWIFT_TARGET)
1350+
13361351
# Include 'swift-syntax'.
13371352
# This is a function because we want to set some 'CMAKE_*' variables temporarily.'
13381353
# TODO: Replace this with 'block()' after CMake 3.25

cmake/modules/Libdispatch.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
88
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CMAKE_CXX_COMPILER})
99
elseif(CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
1010
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
11-
if(CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR AND
12-
TARGET clang)
11+
if(DEFINED SWIFT_CLANG_LOCATION)
12+
set(SWIFT_LIBDISPATCH_C_COMPILER ${SWIFT_CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
13+
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${SWIFT_CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
14+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR AND TARGET clang)
1315
set(SWIFT_LIBDISPATCH_C_COMPILER
1416
$<TARGET_FILE_DIR:clang>/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
1517
set(SWIFT_LIBDISPATCH_CXX_COMPILER
1618
$<TARGET_FILE_DIR:clang>/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
17-
elseif(DEFINED SWIFT_CLANG_LOCATION)
18-
set(SWIFT_LIBDISPATCH_C_COMPILER ${SWIFT_CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
19-
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${SWIFT_CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
2019
else()
2120
set(SWIFT_LIBDISPATCH_C_COMPILER clang-cl${CMAKE_EXECUTABLE_SUFFIX})
2221
set(SWIFT_LIBDISPATCH_CXX_COMPILER clang-cl${CMAKE_EXECUTABLE_SUFFIX})

cmake/modules/SwiftComponents.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ function(swift_install_symlink_component component)
203203
# otherwise.
204204
install(DIRECTORY DESTINATION "${ARG_DESTINATION}" COMPONENT ${component})
205205
install(SCRIPT ${INSTALL_SYMLINK}
206-
CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})"
206+
CODE "install_symlink(${ARG_LINK_NAME}
207+
${ARG_TARGET}
208+
${ARG_DESTINATION}
209+
${SWIFT_COPY_OR_SYMLINK})"
207210
COMPONENT ${component})
208211
endfunction()

include/swift/ABI/ObjectFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#ifndef SWIFT_ABI_OBJECTFILE_H
88
#define SWIFT_ABI_OBJECTFILE_H
99

10-
#include "llvm/Support/ErrorHandling.h"
10+
#include "llvm/ADT/Optional.h"
1111
#include "llvm/ADT/StringRef.h"
12+
#include "llvm/Support/ErrorHandling.h"
1213

1314
namespace swift {
1415

include/swift/AST/ASTContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ class ASTContext final {
506506
return StringRef(Result.data(), Result.size());
507507
}
508508

509-
template<typename T, typename Vector, typename Set>
509+
template<typename T, typename Vector, typename Set, unsigned N>
510510
MutableArrayRef<T>
511-
AllocateCopy(llvm::SetVector<T, Vector, Set> setVector,
511+
AllocateCopy(llvm::SetVector<T, Vector, Set, N> setVector,
512512
AllocationArena arena = AllocationArena::Permanent) const {
513513
return MutableArrayRef<T>(AllocateCopy<T>(setVector.begin(),
514514
setVector.end(),

include/swift/AST/ASTWalker.h

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

1616
#include "swift/Basic/LLVM.h"
1717
#include "llvm/ADT/Optional.h"
18+
#include "llvm/ADT/None.h"
1819
#include "llvm/ADT/PointerUnion.h"
1920
#include <utility>
2021

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5020,7 +5020,7 @@ class ProtocolDecl final : public NominalTypeDecl {
50205020
/// \c None if it hasn't yet been computed.
50215021
llvm::Optional<bool> getCachedHasSelfOrAssociatedTypeRequirements() {
50225022
if (Bits.ProtocolDecl.HasSelfOrAssociatedTypeRequirementsValid)
5023-
return Bits.ProtocolDecl.HasSelfOrAssociatedTypeRequirements;
5023+
return static_cast<bool>(Bits.ProtocolDecl.HasSelfOrAssociatedTypeRequirements);
50245024

50255025
return llvm::None;
50265026
}

include/swift/AST/FileUnit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
122122
/// collecting the identifiers in \p spiGroups.
123123
virtual void lookupImportedSPIGroups(
124124
const ModuleDecl *importedModule,
125-
SmallSetVector<Identifier, 4> &spiGroups) const {};
125+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {};
126126

127127
/// Checks whether this file imports \c module as \c @_weakLinked.
128128
virtual bool importsModuleAsWeakLinked(const ModuleDecl *module) const {

include/swift/AST/IRGenOptions.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,15 @@ class IRGenOptions {
502502
/// The calling convention used to perform non-swift calls.
503503
llvm::CallingConv::ID PlatformCCallingConvention;
504504

505+
/// Use CAS based object format as the output.
506+
bool UseCASBackend;
507+
508+
/// The output mode for the CAS Backend.
509+
llvm::CASBackendMode CASObjMode;
510+
511+
/// Emit a .casid file next to the object file if CAS Backend is used.
512+
bool EmitCASIDFile;
513+
505514
IRGenOptions()
506515
: DWARFVersion(2),
507516
OutputKind(IRGenOutputKind::LLVMAssemblyAfterOptimization),
@@ -513,9 +522,9 @@ class IRGenOptions {
513522
DebugInfoFormat(IRGenDebugInfoFormat::None),
514523
DisableClangModuleSkeletonCUs(false), UseJIT(false),
515524
DisableLLVMOptzns(false), DisableSwiftSpecificLLVMOptzns(false),
516-
Playground(false),
517-
EmitStackPromotionChecks(false), UseSingleModuleLLVMEmission(false),
518-
FunctionSections(false), PrintInlineTree(false), AlwaysCompile(false),
525+
Playground(false), EmitStackPromotionChecks(false),
526+
UseSingleModuleLLVMEmission(false), FunctionSections(false),
527+
PrintInlineTree(false), AlwaysCompile(false),
519528
EmbedMode(IRGenEmbedMode::None), LLVMLTOKind(IRGenLLVMLTOKind::None),
520529
SwiftAsyncFramePointer(SwiftAsyncFramePointerKind::Auto),
521530
HasValueNamesSetting(false), ValueNames(false),
@@ -538,13 +547,12 @@ class IRGenOptions {
538547
WitnessMethodElimination(false), ConditionalRuntimeRecords(false),
539548
InternalizeAtLink(false), InternalizeSymbols(false),
540549
EmitGenericRODatas(false), NoPreallocatedInstantiationCaches(false),
541-
DisableReadonlyStaticObjects(false),
542-
CollocatedMetadataFunctions(false),
543-
ColocateTypeDescriptors(true),
544-
UseRelativeProtocolWitnessTables(false), CmdArgs(),
545-
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
550+
DisableReadonlyStaticObjects(false), CollocatedMetadataFunctions(false),
551+
ColocateTypeDescriptors(true), UseRelativeProtocolWitnessTables(false),
552+
CmdArgs(), SanitizeCoverage(llvm::SanitizerCoverageOptions()),
546553
TypeInfoFilter(TypeInfoDumpFilter::All),
547-
PlatformCCallingConvention(llvm::CallingConv::C) {
554+
PlatformCCallingConvention(llvm::CallingConv::C), UseCASBackend(false),
555+
CASObjMode(llvm::CASBackendMode::Native) {
548556
#ifndef NDEBUG
549557
DisableRoundTripDebugTypes = false;
550558
#else

include/swift/AST/Import.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,15 @@ struct DenseMapInfo<swift::AttributedImport<ModuleInfo>> {
776776
SourceLocDMI::getEmptyKey(),
777777
ImportOptionsDMI::getEmptyKey(),
778778
StringRefDMI::getEmptyKey(),
779-
{}, {}, None,
779+
{}, {}, llvm::None,
780780
swift::AccessLevel::Public, {});
781781
}
782782
static inline AttributedImport getTombstoneKey() {
783783
return AttributedImport(ModuleInfoDMI::getTombstoneKey(),
784784
SourceLocDMI::getEmptyKey(),
785785
ImportOptionsDMI::getTombstoneKey(),
786786
StringRefDMI::getTombstoneKey(),
787-
{}, {}, None,
787+
{}, {}, llvm::None,
788788
swift::AccessLevel::Public, {});
789789
}
790790
static inline unsigned getHashValue(const AttributedImport &import) {

include/swift/AST/Module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/ADT/ArrayRef.h"
3434
#include "llvm/ADT/Optional.h"
3535
#include "llvm/ADT/STLExtras.h"
36+
#include "llvm/ADT/SetVector.h"
3637
#include "llvm/ADT/SmallVector.h"
3738
#include "llvm/ADT/StringMap.h"
3839
#include "llvm/Support/ErrorHandling.h"

include/swift/AST/ModuleLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/Basic/LLVM.h"
2525
#include "swift/Basic/Located.h"
2626
#include "swift/Basic/SourceLoc.h"
27+
#include "clang/Basic/FileManager.h"
2728
#include "llvm/ADT/Optional.h"
2829
#include "llvm/ADT/SetVector.h"
2930
#include "llvm/ADT/StringSet.h"

include/swift/AST/ResilienceExpansion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_AST_RESILIENCE_EXPANSION_H
1515

1616
#include "llvm/Support/raw_ostream.h"
17+
#include "llvm/Support/ErrorHandling.h"
1718

1819
namespace swift {
1920

include/swift/AST/SearchPathOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "llvm/ADT/Hashing.h"
2020
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2121
#include "llvm/ADT/StringMap.h"
22+
#include "llvm/ADT/Optional.h"
23+
#include "llvm/ADT/None.h"
2224
#include "llvm/Support/Error.h"
2325
#include "llvm/Support/VirtualFileSystem.h"
2426

include/swift/Basic/BlotMapVector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/ADT/DenseMap.h"
1717
#include "swift/Basic/LLVM.h"
1818
#include "swift/Basic/Range.h"
19+
#include "llvm/ADT/Optional.h"
1920
#include <vector>
2021

2122
namespace swift {

include/swift/Basic/Cache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
#include "llvm/ADT/DenseMapInfo.h"
1717
#include "llvm/ADT/IntrusiveRefCntPtr.h"
18-
#include "llvm/ADT/StringRef.h"
18+
#include "llvm/ADT/None.h"
1919
#include "llvm/ADT/Optional.h"
20+
#include "llvm/ADT/StringRef.h"
2021

2122
namespace swift {
2223
namespace sys {

include/swift/Basic/ClusteredBitVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class ClusteredBitVector {
216216

217217
/// Count the number of set bits in this vector.
218218
size_t count() const {
219-
return Bits ? Bits.value().countPopulation() : 0;
219+
return Bits ? Bits.value().popcount() : 0;
220220
}
221221

222222
/// Determine if there are any bits set in this vector.

include/swift/Basic/EncodedSequence.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "swift/Basic/LLVM.h"
2626
#include "swift/Basic/PrefixMap.h"
2727
#include "llvm/ADT/ArrayRef.h"
28-
#include "llvm/Support/Host.h"
28+
#include "llvm/TargetParser/Host.h"
2929
#include "llvm/Support/TrailingObjects.h"
3030
#include <climits>
3131

include/swift/Basic/Fingerprint.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/Optional.h"
1919
#include "llvm/ADT/SmallString.h"
2020
#include "llvm/ADT/StringRef.h"
21+
#include "llvm/Support/raw_ostream.h"
2122

2223
#include <string>
2324

include/swift/Basic/FixedBitSet.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,8 @@ class FixedBitSet {
218218

219219
ValueType operator*() const {
220220
assert(remainingChunk && "dereferencing a completed iterator");
221-
return ValueType(chunkIndex * chunkSize
222-
+ llvm::findFirstSet(remainingChunk,
223-
llvm::ZB_Undefined));
221+
return ValueType(chunkIndex * chunkSize +
222+
llvm::countr_zero(remainingChunk));
224223
}
225224

226225
bool operator==(const iterator &other) const {

include/swift/Basic/ImmutablePointerSet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@
4848
#ifndef SWIFT_BASIC_IMMUTABLEPOINTERSET_H
4949
#define SWIFT_BASIC_IMMUTABLEPOINTERSET_H
5050

51-
#include "swift/Basic/STLExtras.h"
5251
#include "swift/Basic/NullablePtr.h"
53-
#include "llvm/Support/Allocator.h"
52+
#include "swift/Basic/STLExtras.h"
53+
#include "llvm/ADT/ArrayRef.h"
5454
#include "llvm/ADT/FoldingSet.h"
55+
#include "llvm/Support/Allocator.h"
5556
#include <algorithm>
5657
#include <type_traits>
5758

include/swift/Basic/LLVM.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ namespace llvm {
5353
template <typename T, unsigned N> class SmallVector;
5454
#endif
5555
template <unsigned N> class SmallString;
56-
template <typename T, unsigned N> class SmallSetVector;
5756
#if SWIFT_LLVM_ODR_SAFE
5857
template<typename T> class ArrayRef;
5958
template<typename T> class MutableArrayRef;
@@ -93,7 +92,6 @@ namespace swift {
9392
using llvm::SmallBitVector;
9493
using llvm::SmallPtrSet;
9594
using llvm::SmallPtrSetImpl;
96-
using llvm::SmallSetVector;
9795
using llvm::SmallString;
9896
#if SWIFT_LLVM_ODR_SAFE
9997
using llvm::SmallVector;

include/swift/Basic/LLVMExtras.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===--- LLVMExtras.h -----------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file provides additional functionality on top of LLVM types
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_BASIC_LLVMEXTRAS_H
18+
#define SWIFT_BASIC_LLVMEXTRAS_H
19+
20+
#include "llvm/ADT/DenseSet.h"
21+
#include "llvm/ADT/SetVector.h"
22+
#include "llvm/ADT/SmallVector.h"
23+
24+
namespace swift {
25+
26+
/// A SetVector that does no allocations under the specified size
27+
///
28+
/// swift::SmallSetVector provides the old SmallSetVector semantics that allow
29+
/// storing types that don't have `operator==`.
30+
template <typename T, unsigned N>
31+
using SmallSetVector = llvm::SetVector<T, llvm::SmallVector<T, N>,
32+
llvm::SmallDenseSet<T, N, llvm::DenseMapInfo<T>>>;
33+
34+
} // namespace swift
35+
36+
#endif // SWIFT_BASIC_LLVMEXTRAS_H

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "llvm/ADT/SmallString.h"
3333
#include "llvm/ADT/SmallVector.h"
3434
#include "llvm/ADT/StringRef.h"
35-
#include "llvm/ADT/Triple.h"
35+
#include "llvm/TargetParser/Triple.h"
3636
#include "llvm/Support/Regex.h"
3737
#include "llvm/Support/VersionTuple.h"
3838
#include "llvm/Support/raw_ostream.h"

include/swift/Basic/MultiMapCache.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "swift/Basic/LLVM.h"
1717
#include "llvm/ADT/ArrayRef.h"
1818
#include "llvm/ADT/DenseMap.h"
19+
#include "llvm/ADT/Optional.h"
20+
#include "llvm/ADT/None.h"
21+
#include "swift/Basic/STLExtras.h"
1922

2023
namespace swift {
2124

@@ -61,7 +64,8 @@ class MultiMapCache {
6164

6265
// If we already have a cached value, just return the cached value.
6366
if (!iter.second) {
64-
return iter.first->second.transform(
67+
68+
return swift::transform(iter.first->second,
6569
[&](std::tuple<unsigned, unsigned> startLengthRange) {
6670
return llvm::makeArrayRef(data).slice(
6771
std::get<ArrayStartOffset>(startLengthRange),

include/swift/Basic/Program.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_BASIC_PROGRAM_H
1515

1616
#include "llvm/ADT/ArrayRef.h"
17+
#include "llvm/ADT/None.h"
1718
#include "llvm/ADT/Optional.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Support/ErrorOr.h"

include/swift/Basic/STLExtras.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <numeric>
2929
#include <type_traits>
3030
#include <unordered_set>
31+
#include <optional>
3132

3233
namespace swift {
3334

@@ -783,6 +784,17 @@ void emplace_back_all(VectorType &vector, ValueType &&value,
783784
template <class VectorType>
784785
void emplace_back_all(VectorType &vector) {}
785786

787+
/// Apply a function to the value if present; otherwise return None.
788+
template <typename OptionalElement, typename Function>
789+
auto transform(const llvm::Optional<OptionalElement> &value,
790+
const Function &operation)
791+
-> llvm::Optional<decltype(operation(*value))> {
792+
793+
if (value) {
794+
return operation(*value);
795+
}
796+
return llvm::None;
797+
}
786798
} // end namespace swift
787799

788800
#endif // SWIFT_BASIC_STLEXTRAS_H

0 commit comments

Comments
 (0)