Skip to content

Commit 3e923f5

Browse files
authored
Merge pull request #3936 from swiftwasm/main
2 parents 1af59ef + 1e0d5b8 commit 3e923f5

File tree

87 files changed

+2200
-434
lines changed

Some content is hidden

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

87 files changed

+2200
-434
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ option(SWIFT_BUILD_DYNAMIC_STDLIB
9393
option(SWIFT_BUILD_STATIC_STDLIB
9494
"Build static variants of the Swift standard library"
9595
FALSE)
96+
97+
option(SWIFT_STDLIB_STATIC_PRINT
98+
"Build compile-time evaluated vprintf()"
99+
FALSE)
96100

97101
option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
98102
"Build dynamic variants of the Swift SDK overlay"

include/swift/AST/ActorIsolation.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class ActorIsolation {
132132

133133
friend bool operator==(const ActorIsolation &lhs,
134134
const ActorIsolation &rhs) {
135+
if (lhs.isGlobalActor() && rhs.isGlobalActor())
136+
return areTypesEqual(lhs.globalActor, rhs.globalActor);
137+
135138
if (lhs.kind != rhs.kind)
136139
return false;
137140

@@ -146,7 +149,7 @@ class ActorIsolation {
146149

147150
case GlobalActor:
148151
case GlobalActorUnsafe:
149-
return areTypesEqual(lhs.globalActor, rhs.globalActor);
152+
llvm_unreachable("Global actors handled above");
150153
}
151154
}
152155

include/swift/AST/DiagnosticsSIL.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,8 @@ NOTE(sil_movekillscopyablevalue_use_here, none,
741741
NOTE(sil_movekillscopyablevalue_value_consumed_in_loop, none,
742742
"cyclic move here. move will occur multiple times in the loop", ())
743743
ERROR(sil_movekillscopyablevalue_move_applied_to_unsupported_move, none,
744-
"_move applied to value that the compiler does not know how to check. "
745-
"Please file a bug or an enhancement request!", ())
744+
"_move applied to value that the compiler does not supporting checking.",
745+
())
746746

747747
#define UNDEFINE_DIAGNOSTIC_MACROS
748748
#include "DefineDiagnosticMacros.h"

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,10 +4550,6 @@ ERROR(actor_isolated_witness,none,
45504550
ERROR(distributed_actor_isolated_witness,none,
45514551
"distributed actor-isolated %0 %1 cannot be used to satisfy a protocol requirement",
45524552
(DescriptiveDeclKind, DeclName))
4553-
ERROR(global_actor_isolated_requirement,none,
4554-
"%0 %1 must be isolated to the global actor %2 to satisfy corresponding "
4555-
"requirement from protocol %3",
4556-
(DescriptiveDeclKind, DeclName, Type, Identifier))
45574553
ERROR(global_actor_isolated_witness,none,
45584554
"%0 %1 isolated to global actor %2 can not satisfy corresponding "
45594555
"requirement from protocol %3",

include/swift/Runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(SWIFT_BNI_OS_BUILD FALSE)
33
set(SWIFT_BNI_XCODE_BUILD FALSE)
44
if(DEFINED ENV{RC_XBS})
5-
if(NOT DEFINED ENV{RC_XCODE} OR NOT "$ENV{RC_XCODE}")
5+
if((NOT DEFINED ENV{RC_XCODE} OR NOT "$ENV{RC_XCODE}") AND (NOT DEFINED ENV{RC_PLAYGROUNDS} OR NOT "$ENV{RC_PLAYGROUNDS}"))
66
set(SWIFT_BNI_OS_BUILD TRUE)
77
else()
88
set(SWIFT_BNI_XCODE_BUILD TRUE)

include/swift/SIL/SILInstruction.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,10 +1976,14 @@ class AllocStackInst final
19761976
/// Whether the alloc_stack instruction corresponds to a source-level VarDecl.
19771977
bool isLexical() const { return lexical; }
19781978

1979-
/// If this is a lexical borrow, eliminate the lexical bit. If this borrow
1980-
/// doesn't have a lexical bit, do not do anything.
1979+
/// If this is a lexical alloc_stack, eliminate the lexical bit. If this
1980+
/// alloc_stack doesn't have a lexical bit, do not do anything.
19811981
void removeIsLexical() { lexical = false; }
19821982

1983+
/// If this is not a lexical alloc_stack, set the lexical bit. If this
1984+
/// alloc_stack is already lexical, this does nothing.
1985+
void setIsLexical() { lexical = true; }
1986+
19831987
/// Return the debug variable information attached to this instruction.
19841988
Optional<SILDebugVariable> getVarInfo() const {
19851989
Optional<SILType> AuxVarType;

lib/ClangImporter/ClangImporter.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -899,10 +899,12 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
899899
std::make_shared<clang::CompilerInvocation>(*Impl.Invocation);
900900
invocation->getPreprocessorOpts().DisablePCHOrModuleValidation =
901901
clang::DisableValidationForModuleKind::None;
902-
invocation->getPreprocessorOpts().AllowPCHWithCompilerErrors = false;
903902
invocation->getHeaderSearchOpts().ModulesValidateSystemHeaders = true;
904903
invocation->getLangOpts()->NeededByPCHOrCompilationUsesPCH = true;
905904
invocation->getLangOpts()->CacheGeneratedPCH = true;
905+
// If the underlying invocation is allowing PCH errors, then it "can be read",
906+
// even if it has its error bit set. Thus, don't override
907+
// `AllowPCHWithCompilerErrors`.
906908

907909
// ClangImporter::create adds a remapped MemoryBuffer that we don't need
908910
// here. Moreover, it's a raw pointer owned by the preprocessor options; if
@@ -1408,7 +1410,8 @@ bool ClangImporter::Implementation::importHeader(
14081410
// Don't even try to load the bridging header if the Clang AST is in a bad
14091411
// state. It could cause a crash.
14101412
auto &clangDiags = getClangASTContext().getDiagnostics();
1411-
if (clangDiags.hasUnrecoverableErrorOccurred())
1413+
if (clangDiags.hasUnrecoverableErrorOccurred() &&
1414+
!getClangInstance()->getPreprocessorOpts().AllowPCHWithCompilerErrors)
14121415
return true;
14131416

14141417
assert(adapter);
@@ -1508,7 +1511,8 @@ bool ClangImporter::Implementation::importHeader(
15081511
getBufferImporterForDiagnostics());
15091512

15101513
// FIXME: What do we do if there was already an error?
1511-
if (!hadError && clangDiags.hasErrorOccurred()) {
1514+
if (!hadError && clangDiags.hasErrorOccurred() &&
1515+
!getClangInstance()->getPreprocessorOpts().AllowPCHWithCompilerErrors) {
15121516
diagnose(diagLoc, diag::bridging_header_error, headerName);
15131517
return true;
15141518
}
@@ -1711,7 +1715,8 @@ ClangImporter::emitBridgingPCH(StringRef headerPath,
17111715
FrontendOpts, std::make_unique<clang::GeneratePCHAction>());
17121716
emitInstance->ExecuteAction(*action);
17131717

1714-
if (emitInstance->getDiagnostics().hasErrorOccurred()) {
1718+
if (emitInstance->getDiagnostics().hasErrorOccurred() &&
1719+
!emitInstance->getPreprocessorOpts().AllowPCHWithCompilerErrors) {
17151720
Impl.diagnose({}, diag::bridging_header_pch_error,
17161721
outputPCHPath, headerPath);
17171722
return true;
@@ -1771,7 +1776,8 @@ bool ClangImporter::emitPrecompiledModule(StringRef moduleMapPath,
17711776
std::make_unique<clang::GenerateModuleFromModuleMapAction>());
17721777
emitInstance->ExecuteAction(*action);
17731778

1774-
if (emitInstance->getDiagnostics().hasErrorOccurred()) {
1779+
if (emitInstance->getDiagnostics().hasErrorOccurred() &&
1780+
!FrontendOpts.AllowPCMWithCompilerErrors) {
17751781
Impl.diagnose({}, diag::emit_pcm_error, outputPath, moduleMapPath);
17761782
return true;
17771783
}

lib/FrontendTool/FrontendTool.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,19 +1813,22 @@ createJSONFixItDiagnosticConsumerIfNeeded(
18131813

18141814
/// A PrettyStackTraceEntry to print frontend information useful for debugging.
18151815
class PrettyStackTraceFrontend : public llvm::PrettyStackTraceEntry {
1816-
const LangOptions &LangOpts;
1816+
const CompilerInvocation &Invocation;
18171817

18181818
public:
1819-
PrettyStackTraceFrontend(const LangOptions &langOpts)
1820-
: LangOpts(langOpts) {}
1819+
PrettyStackTraceFrontend(const CompilerInvocation &invocation)
1820+
: Invocation(invocation) {}
18211821

18221822
void print(llvm::raw_ostream &os) const override {
1823-
auto effective = LangOpts.EffectiveLanguageVersion;
1823+
auto effective = Invocation.getLangOptions().EffectiveLanguageVersion;
18241824
if (effective != version::Version::getCurrentLanguageVersion()) {
18251825
os << "Compiling with effective version " << effective;
18261826
} else {
18271827
os << "Compiling with the current language version";
18281828
}
1829+
if (Invocation.getFrontendOptions().AllowModuleWithCompilerErrors) {
1830+
os << " while allowing modules with compiler errors";
1831+
}
18291832
os << "\n";
18301833
};
18311834
};
@@ -1936,7 +1939,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
19361939
/// (leaks checking is not thread safe).
19371940
Invocation.getSILOptions().checkSILModuleLeaks = true;
19381941

1939-
PrettyStackTraceFrontend frontendTrace(Invocation.getLangOptions());
1942+
PrettyStackTraceFrontend frontendTrace(Invocation);
19401943

19411944
// Make an array of PrettyStackTrace objects to dump the configuration files
19421945
// we used to parse the arguments. These are RAII objects, so they and the

lib/IRGen/ClassTypeInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "ClassLayout.h"
2121
#include "HeapTypeInfo.h"
22+
#include "TypeLayout.h"
2223

2324
namespace swift {
2425
namespace irgen {
@@ -46,7 +47,7 @@ class ClassTypeInfo : public HeapTypeInfo<ClassTypeInfo> {
4647
ClassTypeInfo(llvm::PointerType *irType, Size size, SpareBitVector spareBits,
4748
Alignment align, ClassDecl *theClass,
4849
ReferenceCounting refcount)
49-
: HeapTypeInfo(irType, size, std::move(spareBits), align),
50+
: HeapTypeInfo(refcount, irType, size, std::move(spareBits), align),
5051
TheClass(theClass), Refcount(refcount) {}
5152

5253
ReferenceCounting getReferenceCounting() const { return Refcount; }

lib/IRGen/GenArchetype.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "GenArchetype.h"
1818

19+
#include "TypeLayout.h"
1920
#include "swift/AST/ASTContext.h"
2021
#include "swift/AST/Decl.h"
2122
#include "swift/AST/GenericEnvironment.h"
@@ -126,13 +127,11 @@ class ClassArchetypeTypeInfo
126127
{
127128
ReferenceCounting RefCount;
128129

129-
ClassArchetypeTypeInfo(llvm::PointerType *storageType,
130-
Size size, const SpareBitVector &spareBits,
131-
Alignment align,
130+
ClassArchetypeTypeInfo(llvm::PointerType *storageType, Size size,
131+
const SpareBitVector &spareBits, Alignment align,
132132
ReferenceCounting refCount)
133-
: HeapTypeInfo(storageType, size, spareBits, align),
134-
RefCount(refCount)
135-
{}
133+
: HeapTypeInfo(refCount, storageType, size, spareBits, align),
134+
RefCount(refCount) {}
136135

137136
public:
138137
static const ClassArchetypeTypeInfo *create(llvm::PointerType *storageType,

lib/IRGen/GenConcurrency.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class ExecutorTypeInfo :
5353

5454
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
5555
SILType T) const override {
56-
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
56+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T,
57+
ScalarKind::POD);
5758
}
5859

5960
static Size getSecondElementOffset(IRGenModule &IGM) {

lib/IRGen/GenDiffFunc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DifferentiableFuncTypeInfo final
120120
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
121121
SILType T) const override {
122122
if (!IGM.getOptions().ForceStructTypeLayouts || !areFieldsABIAccessible()) {
123-
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
123+
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(*this, T);
124124
}
125125

126126
if (getFields().empty()) {
@@ -292,7 +292,7 @@ class LinearFuncTypeInfo final
292292
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
293293
SILType T) const override {
294294
if (!IGM.getOptions().ForceStructTypeLayouts || !areFieldsABIAccessible()) {
295-
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
295+
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(*this, T);
296296
}
297297

298298
if (getFields().empty()) {

lib/IRGen/GenEnum.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
//
9999
//===----------------------------------------------------------------------===//
100100

101+
#include "TypeLayout.h"
101102
#define DEBUG_TYPE "enum-layout"
102103
#include "llvm/Support/Debug.h"
103104

@@ -385,9 +386,10 @@ namespace {
385386
return IGM.typeLayoutCache.getEmptyEntry();
386387
if (!ElementsAreABIAccessible)
387388
return IGM.typeLayoutCache.getOrCreateResilientEntry(T);
388-
if (TIK >= Loadable) {
389-
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
390-
}
389+
390+
if (TIK >= Loadable && !IGM.getOptions().ForceStructTypeLayouts)
391+
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(getTypeInfo(),
392+
T);
391393

392394
return getSingleton()->buildTypeLayoutEntry(IGM,
393395
getSingletonType(IGM, T));
@@ -1079,7 +1081,8 @@ namespace {
10791081

10801082
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
10811083
SILType T) const override {
1082-
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
1084+
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T,
1085+
ScalarKind::POD);
10831086
}
10841087

10851088

@@ -1231,7 +1234,8 @@ namespace {
12311234

12321235
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
12331236
SILType T) const override {
1234-
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
1237+
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T,
1238+
ScalarKind::POD);
12351239
}
12361240

12371241
/// \group Extra inhabitants for C-compatible enums.
@@ -3507,9 +3511,10 @@ namespace {
35073511
if (!ElementsAreABIAccessible)
35083512
return IGM.typeLayoutCache.getOrCreateResilientEntry(T);
35093513

3510-
if (AllowFixedLayoutOptimizations && TIK >= Loadable) {
3514+
if (!IGM.getOptions().ForceStructTypeLayouts && (AllowFixedLayoutOptimizations && TIK >= Loadable)) {
35113515
// The type layout entry code does not handle spare bits atm.
3512-
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
3516+
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(getTypeInfo(),
3517+
T);
35133518
}
35143519

35153520
unsigned emptyCases = ElementsWithNoPayload.size();

0 commit comments

Comments
 (0)