Skip to content

Commit 7ba2f72

Browse files
authored
Merge pull request #1407 from swiftwasm/master
[pull] swiftwasm from master
2 parents dbd1ec6 + 063d420 commit 7ba2f72

Some content is hidden

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

43 files changed

+726
-299
lines changed

cmake/modules/AddSwift.cmake

-18
Original file line numberDiff line numberDiff line change
@@ -507,24 +507,6 @@ function(add_swift_host_library name)
507507
endif()
508508

509509
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
510-
# Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
511-
if(SWIFT_EMBED_BITCODE_SECTION)
512-
target_compile_options(${name} PRIVATE
513-
-fembed-bitcode)
514-
target_link_options(${name} PRIVATE
515-
"LINKER:-bitcode_bundle"
516-
"LINKER:-lto_library,${LLVM_LIBRARY_DIR}/libLTO.dylib")
517-
518-
# Please note that using a generator expression to fit this in a single
519-
# target_link_options does not work (at least in CMake 3.15 and 3.16),
520-
# since that seems not to allow the LINKER: prefix to be evaluated (i.e.
521-
# it will be added as-is to the linker parameters)
522-
if(SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS)
523-
target_link_options(${name} PRIVATE
524-
"LINKER:-bitcode_hide_symbols")
525-
endif()
526-
endif()
527-
528510
target_link_options(${name} PRIVATE
529511
"LINKER:-compatibility_version,1")
530512
if(SWIFT_COMPILER_VERSION)

include/swift/AST/DiagnosticsSema.def

+6
Original file line numberDiff line numberDiff line change
@@ -5036,6 +5036,12 @@ NOTE(property_wrapper_direct_init,none,
50365036
ERROR(property_wrapper_incompatible_property, none,
50375037
"property type %0 does not match that of the 'wrappedValue' property of "
50385038
"its wrapper type %1", (Type, Type))
5039+
ERROR(wrapped_value_mismatch, none,
5040+
"property type %0 does not match 'wrappedValue' type %1",
5041+
(Type, Type))
5042+
ERROR(composed_property_wrapper_mismatch, none,
5043+
"composed wrapper type %0 does not match former 'wrappedValue' type %1",
5044+
(Type, Type))
50395045

50405046
ERROR(property_wrapper_type_access,none,
50415047
"%select{%select{variable|constant}0|property}1 "

include/swift/AST/IRGenOptions.h

+20-12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ enum class IRGenDebugInfoFormat : unsigned {
6565
CodeView
6666
};
6767

68+
enum class IRGenLLVMLTOKind : unsigned {
69+
None,
70+
Thin,
71+
Full,
72+
};
73+
6874
enum class IRGenEmbedMode : unsigned {
6975
None,
7076
EmbedMarker,
@@ -220,6 +226,8 @@ class IRGenOptions {
220226
/// Whether we should embed the bitcode file.
221227
IRGenEmbedMode EmbedMode : 2;
222228

229+
IRGenLLVMLTOKind LLVMLTOKind : 2;
230+
223231
/// Add names to LLVM values.
224232
unsigned HasValueNamesSetting : 1;
225233
unsigned ValueNames : 1;
@@ -320,21 +328,21 @@ class IRGenOptions {
320328
DebugInfoLevel(IRGenDebugInfoLevel::None),
321329
DebugInfoFormat(IRGenDebugInfoFormat::None),
322330
DisableClangModuleSkeletonCUs(false), UseJIT(false),
323-
DisableLLVMOptzns(false),
324-
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
325-
Playground(false), EmitStackPromotionChecks(false),
326-
FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
327-
HasValueNamesSetting(false), ValueNames(false),
328-
EnableReflectionMetadata(true), EnableReflectionNames(true),
329-
EnableAnonymousContextMangledNames(false), ForcePublicLinkage(false),
330-
LazyInitializeClassMetadata(false),
331+
DisableLLVMOptzns(false), DisableSwiftSpecificLLVMOptzns(false),
332+
DisableLLVMSLPVectorizer(false), Playground(false),
333+
EmitStackPromotionChecks(false), FunctionSections(false),
334+
PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
335+
LLVMLTOKind(IRGenLLVMLTOKind::None), HasValueNamesSetting(false),
336+
ValueNames(false), EnableReflectionMetadata(true),
337+
EnableReflectionNames(true), EnableAnonymousContextMangledNames(false),
338+
ForcePublicLinkage(false), LazyInitializeClassMetadata(false),
331339
LazyInitializeProtocolConformances(false), DisableLegacyTypeInfo(false),
332340
PrespecializeGenericMetadata(false), UseIncrementalLLVMCodeGen(true),
333-
UseSwiftCall(false), UseTypeLayoutValueHandling(true), GenerateProfile(false),
334-
EnableDynamicReplacementChaining(false),
341+
UseSwiftCall(false), UseTypeLayoutValueHandling(true),
342+
GenerateProfile(false), EnableDynamicReplacementChaining(false),
335343
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
336-
DisableConcreteTypeMetadataMangledNameAccessors(false),
337-
CmdArgs(), SanitizeCoverage(llvm::SanitizerCoverageOptions()),
344+
DisableConcreteTypeMetadataMangledNameAccessors(false), CmdArgs(),
345+
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
338346
TypeInfoFilter(TypeInfoDumpFilter::All) {}
339347

340348
/// Appends to \p os an arbitrary string representing all options which

include/swift/Option/Options.td

+4
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ def disable_bridging_pch : Flag<["-"], "disable-bridging-pch">,
523523
Flags<[HelpHidden]>,
524524
HelpText<"Disable automatic generation of bridging PCH files">;
525525

526+
def lto : Joined<["-"], "lto=">,
527+
Flags<[FrontendOption, NoInteractiveOption]>,
528+
HelpText<"Specify the LTO type to either 'llvm-thin' or 'llvm-full'">;
529+
526530
// Experimental feature options
527531

528532
// Note: this flag will be removed when JVP/differential generation in the

lib/AST/ASTVerifier.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,14 @@ class Verifier : public ASTWalker {
988988
}
989989

990990
if (S->hasResult()) {
991+
if (isa<ConstructorDecl>(func)) {
992+
Out << "Expected ReturnStmt not to have a result. A constructor "
993+
"should not return a result. Returned expression: ";
994+
S->getResult()->dump(Out);
995+
Out << "\n";
996+
abort();
997+
}
998+
991999
auto result = S->getResult();
9921000
auto returnType = result->getType();
9931001
// Make sure that the return has the same type as the function.

lib/ClangImporter/ImportDecl.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,7 @@ synthesizeEnumRawValueConstructorBody(AbstractFunctionDecl *afd,
502502
/*implicit*/ true);
503503
assign->setType(TupleType::getEmpty(ctx));
504504

505-
auto result = TupleExpr::createEmpty(ctx, SourceLoc(), SourceLoc(),
506-
/*Implicit=*/true);
507-
auto ret = new (ctx) ReturnStmt(SourceLoc(), result, /*Implicit=*/true);
505+
auto ret = new (ctx) ReturnStmt(SourceLoc(), nullptr, /*Implicit=*/true);
508506

509507
auto body = BraceStmt::create(ctx, SourceLoc(), {assign, ret}, SourceLoc(),
510508
/*implicit*/ true);
@@ -1366,11 +1364,7 @@ synthesizeValueConstructorBody(AbstractFunctionDecl *afd, void *context) {
13661364
}
13671365
}
13681366

1369-
auto result = TupleExpr::createEmpty(ctx, SourceLoc(), SourceLoc(),
1370-
/*Implicit=*/true);
1371-
result->setType(TupleType::getEmpty(ctx));
1372-
1373-
auto ret = new (ctx) ReturnStmt(SourceLoc(), result, /*Implicit=*/true);
1367+
auto ret = new (ctx) ReturnStmt(SourceLoc(), nullptr, /*Implicit=*/true);
13741368
stmts.push_back(ret);
13751369

13761370
// Create the function body.
@@ -1567,9 +1561,7 @@ synthesizeRawValueBridgingConstructorBody(AbstractFunctionDecl *afd,
15671561
/*Implicit=*/true);
15681562
assign->setType(TupleType::getEmpty(ctx));
15691563

1570-
auto result = TupleExpr::createEmpty(ctx, SourceLoc(), SourceLoc(),
1571-
/*Implicit=*/true);
1572-
auto ret = new (ctx) ReturnStmt(SourceLoc(), result, /*Implicit=*/true);
1564+
auto ret = new (ctx) ReturnStmt(SourceLoc(), nullptr, /*Implicit=*/true);
15731565

15741566
auto body = BraceStmt::create(ctx, SourceLoc(), {assign, ret}, SourceLoc());
15751567
return { body, /*isTypeChecked=*/true };

lib/Frontend/CompilerInvocation.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,18 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
14611461
}
14621462
}
14631463

1464+
if (const Arg *A = Args.getLastArg(options::OPT_lto)) {
1465+
auto LLVMLTOKind =
1466+
llvm::StringSwitch<Optional<IRGenLLVMLTOKind>>(A->getValue())
1467+
.Case("llvm-thin", IRGenLLVMLTOKind::Thin)
1468+
.Case("llvm-full", IRGenLLVMLTOKind::Full)
1469+
.Default(llvm::None);
1470+
if (LLVMLTOKind)
1471+
Opts.LLVMLTOKind = LLVMLTOKind.getValue();
1472+
else
1473+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
1474+
A->getAsString(Args), A->getValue());
1475+
}
14641476

14651477
if (const Arg *A = Args.getLastArg(options::OPT_sanitize_coverage_EQ)) {
14661478
Opts.SanitizeCoverage =

lib/IRGen/IRGen.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,14 @@ bool swift::performLLVM(const IRGenOptions &Opts,
550550
case IRGenOutputKind::LLVMAssembly:
551551
EmitPasses.add(createPrintModulePass(*RawOS));
552552
break;
553-
case IRGenOutputKind::LLVMBitcode:
554-
EmitPasses.add(createBitcodeWriterPass(*RawOS));
553+
case IRGenOutputKind::LLVMBitcode: {
554+
if (Opts.LLVMLTOKind == IRGenLLVMLTOKind::Thin) {
555+
EmitPasses.add(createWriteThinLTOBitcodePass(*RawOS));
556+
} else {
557+
EmitPasses.add(createBitcodeWriterPass(*RawOS));
558+
}
555559
break;
560+
}
556561
case IRGenOutputKind::NativeAssembly:
557562
case IRGenOutputKind::ObjectFile: {
558563
CodeGenFileType FileType;

0 commit comments

Comments
 (0)