Skip to content

Commit 90ed765

Browse files
committed
Merge branch 'main' of github.com:apple/swift into maxd/main-merge
# Conflicts: # stdlib/private/StdlibUnittest/StdlibUnittest.swift
2 parents edfc2ad + a382f58 commit 90ed765

32 files changed

+629
-271
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ option(SWIFT_ENABLE_DISPATCH
449449
TRUE)
450450

451451
option(SWIFT_ENABLE_GLOBAL_ISEL_ARM64
452-
"Enable global isel on arm64, arm64e, arm64_32"
452+
"Enable global isel on arm64"
453453
FALSE)
454454

455455
cmake_dependent_option(SWIFT_BUILD_SYNTAXPARSERLIB

include/swift/AST/DiagnosticsCommon.def

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,6 @@ REMARK(remark_save_cache, none,
209209
// MARK: custom attribute diagnostics
210210
//------------------------------------------------------------------------------
211211

212-
ERROR(ambiguous_custom_attribute_ref,none,
213-
"ambiguous use of attribute %0", (Identifier))
214-
NOTE(ambiguous_custom_attribute_ref_fix,none,
215-
"use '%0.' to reference the attribute %1 in module %2",
216-
(StringRef, Identifier, Identifier))
217-
NOTE(found_attribute_candidate,none,
218-
"found this attribute", ())
219212
ERROR(unknown_attribute,none,
220213
"unknown attribute '%0'", (StringRef))
221214

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ struct SupplementaryOutputPaths {
146146
/// The output path to generate ABI baseline.
147147
std::string ABIDescriptorOutputPath;
148148

149+
/// The output path for YAML optimization record file.
150+
std::string YAMLOptRecordPath;
151+
152+
/// The output path for bitstream optimization record file.
153+
std::string BitstreamOptRecordPath;
154+
149155
SupplementaryOutputPaths() = default;
150156
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;
151157

@@ -179,6 +185,10 @@ struct SupplementaryOutputPaths {
179185
fn(ModuleSummaryOutputPath);
180186
if (!ABIDescriptorOutputPath.empty())
181187
fn(ABIDescriptorOutputPath);
188+
if (!YAMLOptRecordPath.empty())
189+
fn(YAMLOptRecordPath);
190+
if (!BitstreamOptRecordPath.empty())
191+
fn(BitstreamOptRecordPath);
182192
}
183193

184194
bool empty() const {
@@ -187,7 +197,8 @@ struct SupplementaryOutputPaths {
187197
ReferenceDependenciesFilePath.empty() &&
188198
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
189199
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
190-
ModuleSourceInfoOutputPath.empty() && ABIDescriptorOutputPath.empty();
200+
ModuleSourceInfoOutputPath.empty() && ABIDescriptorOutputPath.empty() &&
201+
YAMLOptRecordPath.empty() && BitstreamOptRecordPath.empty();
191202
}
192203
};
193204
} // namespace swift

include/swift/Frontend/FrontendInputsAndOutputs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ class FrontendInputsAndOutputs {
259259
bool hasABIDescriptorOutputPath() const;
260260
bool hasModuleSummaryOutputPath() const;
261261
bool hasTBDPath() const;
262+
bool hasYAMLOptRecordPath() const;
263+
bool hasBitstreamOptRecordPath() const;
262264

263265
bool hasDependencyTrackerPath() const;
264266
};

include/swift/Runtime/VoucherShims.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@
4141

4242
#if SWIFT_HAS_VOUCHER_HEADER
4343

44-
static inline bool swift_voucher_needs_adopt(voucher_t _Nullable voucher) {
45-
if (__builtin_available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)) {
46-
return voucher_needs_adopt(voucher);
47-
}
48-
return true;
49-
}
50-
5144
#else
5245

5346
// If the header isn't available, declare the necessary calls here.
@@ -64,10 +57,6 @@ extern "C" voucher_t _Nullable voucher_copy(void);
6457
// Consumes argument, returns retained value.
6558
extern "C" voucher_t _Nullable voucher_adopt(voucher_t _Nullable voucher);
6659

67-
static inline bool swift_voucher_needs_adopt(voucher_t _Nullable voucher) {
68-
return true;
69-
}
70-
7160
#endif // __has_include(<os/voucher_private.h>)
7261

7362
static inline void swift_voucher_release(voucher_t _Nullable voucher) {
@@ -88,10 +77,26 @@ static inline voucher_t _Nullable voucher_copy(void) { return nullptr; }
8877
static inline voucher_t _Nullable voucher_adopt(voucher_t _Nullable voucher) {
8978
return nullptr;
9079
}
91-
static inline bool swift_voucher_needs_adopt(voucher_t _Nullable voucher) {
92-
return true;
93-
}
9480
static inline void swift_voucher_release(voucher_t _Nullable voucher) {}
9581
#endif // __APPLE__
9682

83+
// Declare our own voucher_needs_adopt for when we don't get it from the SDK.
84+
// This declaration deliberately takes `void *` instead of `voucher_t`. When the
85+
// SDK provides one that takes `voucher_t`, then C++ overload resolution will
86+
// favor that one. When the SDK does not provide a declaration, then the call
87+
// site will invoke this stub instead.
88+
static inline bool voucher_needs_adopt(void * _Nullable voucher) {
89+
return true;
90+
}
91+
92+
static inline bool swift_voucher_needs_adopt(voucher_t _Nullable voucher) {
93+
#if __APPLE__
94+
if (__builtin_available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *))
95+
return voucher_needs_adopt(voucher);
96+
return true;
97+
#else
98+
return voucher_needs_adopt(voucher);
9799
#endif
100+
}
101+
102+
#endif // SWIFT_CONCURRENCY_VOUCHERSHIMS_H

lib/AST/GenericSignature.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/AST/Module.h"
2424
#include "swift/AST/PrettyStackTrace.h"
2525
#include "swift/AST/Types.h"
26+
#include "swift/Basic/SourceManager.h"
2627
#include "swift/Basic/STLExtras.h"
2728
#include "RequirementMachine/RequirementMachine.h"
2829
#include <functional>
@@ -1492,9 +1493,12 @@ int swift::compareAssociatedTypes(AssociatedTypeDecl *assocType1,
14921493
return compareProtocols;
14931494

14941495
// Error case: if we have two associated types with the same name in the
1495-
// same protocol, just tie-break based on address.
1496-
if (assocType1 != assocType2)
1497-
return assocType1 < assocType2 ? -1 : +1;
1496+
// same protocol, just tie-break based on source location.
1497+
if (assocType1 != assocType2) {
1498+
auto &ctx = assocType1->getASTContext();
1499+
return ctx.SourceMgr.isBeforeInBuffer(assocType1->getLoc(),
1500+
assocType2->getLoc()) ? -1 : +1;
1501+
}
14981502

14991503
return 0;
15001504
}

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4012,7 +4012,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
40124012
// Add all of the inherited protocol requirements, recursively.
40134013
auto inheritedReqResult =
40144014
addInheritedRequirements(proto, selfType.getUnresolvedType(), source,
4015-
proto->getModuleContext());
4015+
nullptr);
40164016
if (isErrorResult(inheritedReqResult))
40174017
return inheritedReqResult;
40184018
}

lib/AST/NameLookup.cpp

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,11 +2105,22 @@ directReferencesForUnqualifiedTypeLookup(DeclNameRef name,
21052105
auto descriptor = UnqualifiedLookupDescriptor(name, dc, loc, options);
21062106
auto lookup = evaluateOrDefault(ctx.evaluator,
21072107
UnqualifiedLookupRequest{descriptor}, {});
2108+
2109+
unsigned nominalTypeDeclCount = 0;
21082110
for (const auto &result : lookup.allResults()) {
21092111
auto typeDecl = cast<TypeDecl>(result.getValueDecl());
2112+
2113+
if (isa<NominalTypeDecl>(typeDecl))
2114+
nominalTypeDeclCount++;
2115+
21102116
results.push_back(typeDecl);
21112117
}
21122118

2119+
// If we saw multiple nominal type declarations with the same name,
2120+
// the result of the lookup is definitely ambiguous.
2121+
if (nominalTypeDeclCount > 1)
2122+
results.clear();
2123+
21132124
return results;
21142125
}
21152126

@@ -2607,54 +2618,6 @@ CustomAttrNominalRequest::evaluate(Evaluator &evaluator,
26072618
}
26082619
}
26092620

2610-
// If we have more than one attribute declaration, we have an ambiguity.
2611-
// So, emit an ambiguity diagnostic.
2612-
if (auto typeRepr = attr->getTypeRepr()) {
2613-
if (nominals.size() > 1) {
2614-
SmallVector<NominalTypeDecl *, 4> ambiguousCandidates;
2615-
// Filter out declarations that cannot be attributes.
2616-
for (auto decl : nominals) {
2617-
if (isa<ProtocolDecl>(decl)) {
2618-
continue;
2619-
}
2620-
ambiguousCandidates.push_back(decl);
2621-
}
2622-
if (ambiguousCandidates.size() > 1) {
2623-
auto attrName = nominals.front()->getName();
2624-
ctx.Diags.diagnose(typeRepr->getLoc(),
2625-
diag::ambiguous_custom_attribute_ref, attrName);
2626-
for (auto candidate : ambiguousCandidates) {
2627-
ctx.Diags.diagnose(candidate->getLoc(),
2628-
diag::found_attribute_candidate);
2629-
// If the candidate is a top-level attribute, let's suggest
2630-
// adding module name to resolve the ambiguity.
2631-
if (candidate->getDeclContext()->isModuleScopeContext()) {
2632-
auto moduleName = candidate->getParentModule()->getName();
2633-
ctx.Diags
2634-
.diagnose(typeRepr->getLoc(),
2635-
diag::ambiguous_custom_attribute_ref_fix,
2636-
moduleName.str(), attrName, moduleName)
2637-
.fixItInsert(typeRepr->getLoc(), moduleName.str().str() + ".");
2638-
}
2639-
}
2640-
return nullptr;
2641-
}
2642-
}
2643-
}
2644-
2645-
// There is no nominal type with this name, so complain about this being
2646-
// an unknown attribute.
2647-
std::string typeName;
2648-
if (auto typeRepr = attr->getTypeRepr()) {
2649-
llvm::raw_string_ostream out(typeName);
2650-
typeRepr->print(out);
2651-
} else {
2652-
typeName = attr->getType().getString();
2653-
}
2654-
2655-
ctx.Diags.diagnose(attr->getLocation(), diag::unknown_attribute, typeName);
2656-
attr->setInvalid();
2657-
26582621
return nullptr;
26592622
}
26602623

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,14 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
341341
options::OPT_emit_module_summary_path);
342342
auto abiDescriptorOutput = getSupplementaryFilenamesFromArguments(
343343
options::OPT_emit_abi_descriptor_path);
344+
auto optRecordOutput = getSupplementaryFilenamesFromArguments(
345+
options::OPT_save_optimization_record_path);
344346
if (!objCHeaderOutput || !moduleOutput || !moduleDocOutput ||
345347
!dependenciesFile || !referenceDependenciesFile ||
346348
!serializedDiagnostics || !fixItsOutput || !loadedModuleTrace || !TBD ||
347349
!moduleInterfaceOutput || !privateModuleInterfaceOutput ||
348-
!moduleSourceInfoOutput || !moduleSummaryOutput || !abiDescriptorOutput) {
350+
!moduleSourceInfoOutput || !moduleSummaryOutput || !abiDescriptorOutput ||
351+
!optRecordOutput) {
349352
return None;
350353
}
351354
std::vector<SupplementaryOutputPaths> result;
@@ -368,6 +371,8 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
368371
sop.ModuleSourceInfoOutputPath = (*moduleSourceInfoOutput)[i];
369372
sop.ModuleSummaryOutputPath = (*moduleSummaryOutput)[i];
370373
sop.ABIDescriptorOutputPath = (*abiDescriptorOutput)[i];
374+
sop.YAMLOptRecordPath = (*optRecordOutput)[i];
375+
sop.BitstreamOptRecordPath = (*optRecordOutput)[i];
371376
result.push_back(sop);
372377
}
373378
return result;
@@ -479,6 +484,15 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
479484
file_types::TY_SwiftModuleFile, mainOutputIfUsableForModule,
480485
defaultSupplementaryOutputPathExcludingExtension);
481486

487+
auto YAMLOptRecordPath = determineSupplementaryOutputFilename(
488+
OPT_save_optimization_record_path, pathsFromArguments.YAMLOptRecordPath,
489+
file_types::TY_YAMLOptRecord, "",
490+
defaultSupplementaryOutputPathExcludingExtension);
491+
auto bitstreamOptRecordPath = determineSupplementaryOutputFilename(
492+
OPT_save_optimization_record_path, pathsFromArguments.BitstreamOptRecordPath,
493+
file_types::TY_BitstreamOptRecord, "",
494+
defaultSupplementaryOutputPathExcludingExtension);
495+
482496
SupplementaryOutputPaths sop;
483497
sop.ObjCHeaderOutputPath = objcHeaderOutputPath;
484498
sop.ModuleOutputPath = moduleOutputPath;
@@ -494,6 +508,8 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
494508
sop.ModuleSourceInfoOutputPath = moduleSourceInfoOutputPath;
495509
sop.ModuleSummaryOutputPath = moduleSummaryOutputPath;
496510
sop.ABIDescriptorOutputPath = ABIDescriptorOutputPath;
511+
sop.YAMLOptRecordPath = YAMLOptRecordPath;
512+
sop.BitstreamOptRecordPath = bitstreamOptRecordPath;
497513
return sop;
498514
}
499515

@@ -576,6 +592,8 @@ createFromTypeToPathMap(const TypeToPathMap *map) {
576592
{file_types::TY_SwiftModuleSummaryFile, paths.ModuleSummaryOutputPath},
577593
{file_types::TY_PrivateSwiftModuleInterfaceFile,
578594
paths.PrivateModuleInterfaceOutputPath},
595+
{file_types::TY_YAMLOptRecord, paths.YAMLOptRecordPath},
596+
{file_types::TY_BitstreamOptRecord, paths.BitstreamOptRecordPath},
579597
};
580598
for (const std::pair<file_types::ID, std::string &> &typeAndString :
581599
typesAndStrings) {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,8 +1891,7 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
18911891
}
18921892

18931893
if (SWIFT_ENABLE_GLOBAL_ISEL_ARM64 &&
1894-
(Triple.getArch() == llvm::Triple::aarch64 ||
1895-
Triple.getArch() == llvm::Triple::aarch64_32) &&
1894+
Triple.getArch() == llvm::Triple::aarch64 &&
18961895
Triple.getArchName() != "arm64e") {
18971896
Opts.EnableGlobalISel = true;
18981897
}

0 commit comments

Comments
 (0)