mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge swiftlang#38335
This commit is contained in:
committed by
Michael Chiu
parent
0c47c45303
commit
7f0f2ac4dd
@@ -1056,6 +1056,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(SWIFT_USE_LINKER_default "")
|
||||
elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023")
|
||||
set(SWIFT_USE_LINKER_default "lld")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
set(SWIFT_USE_LINKER_default "lld")
|
||||
else()
|
||||
get_gold_version(gold_version)
|
||||
if(NOT gold_version)
|
||||
|
||||
@@ -422,7 +422,14 @@ public:
|
||||
Kind kind;
|
||||
|
||||
/// The type and index of a differentiability parameter or result.
|
||||
using TypeAndIndex = std::pair<Type, unsigned>;
|
||||
/// std::pair does not have a trivial copy constructor on FreeBSD <= 14 for
|
||||
/// ABI reasons, so we have to define our own type here instead
|
||||
struct TypeAndIndex {
|
||||
Type first;
|
||||
unsigned second;
|
||||
|
||||
TypeAndIndex(Type type, unsigned index) : first(type), second(index) {}
|
||||
};
|
||||
|
||||
private:
|
||||
union Value {
|
||||
|
||||
@@ -34,6 +34,7 @@ AVAILABILITY_PLATFORM(visionOSApplicationExtension, "application extensions for
|
||||
AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS")
|
||||
AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst")
|
||||
AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst")
|
||||
AVAILABILITY_PLATFORM(FreeBSD, "FreeBSD")
|
||||
AVAILABILITY_PLATFORM(OpenBSD, "OpenBSD")
|
||||
AVAILABILITY_PLATFORM(Windows, "Windows")
|
||||
|
||||
|
||||
@@ -71,8 +71,15 @@ private:
|
||||
|
||||
/// The parent `apply` instruction and the witness associated with the
|
||||
/// `IndirectDifferentiation` case.
|
||||
std::pair<ApplyInst *, SILDifferentiabilityWitness *>
|
||||
indirectDifferentiation;
|
||||
/// Note: This used to be a std::pair, but on FreeBSD <= 14, libc++ is
|
||||
/// configured with _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
|
||||
/// and hence does not have a trivial copy constructor
|
||||
struct IndirectDifferentiation {
|
||||
ApplyInst *applyInst;
|
||||
SILDifferentiabilityWitness *witness;
|
||||
};
|
||||
IndirectDifferentiation indirectDifferentiation;
|
||||
|
||||
Value(ApplyInst *applyInst, SILDifferentiabilityWitness *witness)
|
||||
: indirectDifferentiation({applyInst, witness}) {}
|
||||
|
||||
@@ -111,7 +118,8 @@ public:
|
||||
std::pair<ApplyInst *, SILDifferentiabilityWitness *>
|
||||
getIndirectDifferentiation() const {
|
||||
assert(kind == Kind::IndirectDifferentiation);
|
||||
return value.indirectDifferentiation;
|
||||
return std::make_pair(value.indirectDifferentiation.applyInst,
|
||||
value.indirectDifferentiation.witness);
|
||||
}
|
||||
|
||||
SILDifferentiabilityWitness *getSILDifferentiabilityWitnessInvoker() const {
|
||||
|
||||
@@ -116,6 +116,7 @@ swift::basePlatformForExtensionPlatform(PlatformKind Platform) {
|
||||
case PlatformKind::tvOS:
|
||||
case PlatformKind::watchOS:
|
||||
case PlatformKind::visionOS:
|
||||
case PlatformKind::FreeBSD:
|
||||
case PlatformKind::OpenBSD:
|
||||
case PlatformKind::Windows:
|
||||
case PlatformKind::none:
|
||||
@@ -160,6 +161,8 @@ static bool isPlatformActiveForTarget(PlatformKind Platform,
|
||||
return Target.isXROS();
|
||||
case PlatformKind::OpenBSD:
|
||||
return Target.isOSOpenBSD();
|
||||
case PlatformKind::FreeBSD:
|
||||
return Target.isOSFreeBSD();
|
||||
case PlatformKind::Windows:
|
||||
return Target.isOSWindows();
|
||||
case PlatformKind::none:
|
||||
@@ -292,6 +295,7 @@ bool swift::isPlatformSPI(PlatformKind Platform) {
|
||||
case PlatformKind::visionOS:
|
||||
case PlatformKind::visionOSApplicationExtension:
|
||||
case PlatformKind::OpenBSD:
|
||||
case PlatformKind::FreeBSD:
|
||||
case PlatformKind::Windows:
|
||||
case PlatformKind::none:
|
||||
return false;
|
||||
|
||||
@@ -4721,7 +4721,8 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType(
|
||||
if (!resultTan)
|
||||
return llvm::make_error<DerivativeFunctionTypeError>(
|
||||
this, DerivativeFunctionTypeError::Kind::NonDifferentiableResult,
|
||||
std::make_pair(originalResultType, unsigned(originalResult.index)));
|
||||
DerivativeFunctionTypeError::TypeAndIndex(
|
||||
originalResultType, unsigned(originalResult.index)));
|
||||
|
||||
if (!originalResult.isSemanticResultParameter)
|
||||
resultTanTypes.push_back(resultTan->getType());
|
||||
@@ -4751,7 +4752,7 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType(
|
||||
this,
|
||||
DerivativeFunctionTypeError::Kind::
|
||||
NonDifferentiableDifferentiabilityParameter,
|
||||
std::make_pair(paramType, i));
|
||||
DerivativeFunctionTypeError::TypeAndIndex(paramType, i));
|
||||
|
||||
differentialParams.push_back(AnyFunctionType::Param(
|
||||
paramTan->getType(), Identifier(), diffParam.getParameterFlags()));
|
||||
@@ -4799,7 +4800,7 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType(
|
||||
this,
|
||||
DerivativeFunctionTypeError::Kind::
|
||||
NonDifferentiableDifferentiabilityParameter,
|
||||
std::make_pair(paramType, i));
|
||||
DerivativeFunctionTypeError::TypeAndIndex(paramType, i));
|
||||
|
||||
if (diffParam.isAutoDiffSemanticResult()) {
|
||||
if (paramType->isVoid())
|
||||
|
||||
@@ -2590,6 +2590,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts)
|
||||
case PlatformKind::visionOSApplicationExtension:
|
||||
break;
|
||||
|
||||
case PlatformKind::FreeBSD:
|
||||
deprecatedAsUnavailableMessage = "";
|
||||
break;
|
||||
|
||||
case PlatformKind::OpenBSD:
|
||||
deprecatedAsUnavailableMessage = "";
|
||||
break;
|
||||
@@ -2637,6 +2641,9 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const {
|
||||
return name == "xros" || name == "xros_app_extension" ||
|
||||
name == "visionos" || name == "visionos_app_extension";
|
||||
|
||||
case PlatformKind::FreeBSD:
|
||||
return name == "freebsd";
|
||||
|
||||
case PlatformKind::OpenBSD:
|
||||
return name == "openbsd";
|
||||
|
||||
@@ -2708,6 +2715,10 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable(
|
||||
// No deprecation filter on xrOS
|
||||
return false;
|
||||
|
||||
case PlatformKind::FreeBSD:
|
||||
// No deprecation filter on FreeBSD
|
||||
return false;
|
||||
|
||||
case PlatformKind::OpenBSD:
|
||||
// No deprecation filter on OpenBSD
|
||||
return false;
|
||||
|
||||
@@ -244,6 +244,8 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver,
|
||||
llvm_unreachable("cannot find platform kind");
|
||||
case swift::PlatformKind::OpenBSD:
|
||||
llvm_unreachable("not used for this platform");
|
||||
case swift::PlatformKind::FreeBSD:
|
||||
llvm_unreachable("not used for this platform");
|
||||
case swift::PlatformKind::Windows:
|
||||
llvm_unreachable("not used for this platform");
|
||||
case swift::PlatformKind::iOS:
|
||||
|
||||
@@ -168,7 +168,8 @@ OptionSet<SanitizerKind> swift::parseSanitizerArgValues(
|
||||
}
|
||||
|
||||
// Check that we're one of the known supported targets for sanitizers.
|
||||
if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows())) {
|
||||
if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows()
|
||||
|| Triple.isOSFreeBSD())) {
|
||||
SmallString<128> b;
|
||||
Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target,
|
||||
(A->getOption().getPrefixedName() +
|
||||
|
||||
@@ -1779,6 +1779,9 @@ public:
|
||||
case PlatformKind::visionOSApplicationExtension:
|
||||
plat = "visionos_app_extension";
|
||||
break;
|
||||
case PlatformKind::FreeBSD:
|
||||
plat = "freebsd";
|
||||
break;
|
||||
case PlatformKind::OpenBSD:
|
||||
plat = "openbsd";
|
||||
break;
|
||||
|
||||
@@ -54,6 +54,8 @@ StringRef getDomain(const SemanticAvailableAttr &AvAttr) {
|
||||
return { "watchOSAppExtension" };
|
||||
case swift::PlatformKind::visionOSApplicationExtension:
|
||||
return { "visionOSAppExtension" };
|
||||
case swift::PlatformKind::FreeBSD:
|
||||
return { "FreeBSD" };
|
||||
case swift::PlatformKind::OpenBSD:
|
||||
return { "OpenBSD" };
|
||||
case swift::PlatformKind::Windows:
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
// Clang has been defining __INTxx_TYPE__ macros for a long time.
|
||||
// __UINTxx_TYPE__ are defined only since Clang 3.5.
|
||||
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__wasi__)
|
||||
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__wasi__)
|
||||
#include <stdint.h>
|
||||
typedef int64_t __swift_int64_t;
|
||||
typedef uint64_t __swift_uint64_t;
|
||||
|
||||
@@ -688,6 +688,7 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D,
|
||||
static UIdent PlatformOSXAppExt("source.availability.platform.osx_app_extension");
|
||||
static UIdent PlatformtvOSAppExt("source.availability.platform.tvos_app_extension");
|
||||
static UIdent PlatformWatchOSAppExt("source.availability.platform.watchos_app_extension");
|
||||
static UIdent PlatformFreeBSD("source.availability.platform.freebsd");
|
||||
static UIdent PlatformOpenBSD("source.availability.platform.openbsd");
|
||||
static UIdent PlatformWindows("source.availability.platform.windows");
|
||||
std::vector<SemanticAvailableAttr> Scratch;
|
||||
@@ -739,6 +740,9 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D,
|
||||
case PlatformKind::OpenBSD:
|
||||
PlatformUID = PlatformOpenBSD;
|
||||
break;
|
||||
case PlatformKind::FreeBSD:
|
||||
PlatformUID = PlatformFreeBSD;
|
||||
break;
|
||||
case PlatformKind::Windows:
|
||||
PlatformUID = PlatformWindows;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user