Skip to content

Commit 6b582f7

Browse files
Merge pull request #4948 from swiftwasm/main
[pull] swiftwasm from main
2 parents cf93ebf + 9159f87 commit 6b582f7

File tree

147 files changed

+888
-164
lines changed

Some content is hidden

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

147 files changed

+888
-164
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ WARNING(warning_cannot_multithread_batch_mode,none,
106106
"ignoring -num-threads argument; cannot multithread batch mode", ())
107107
ERROR(error_cannot_explicit_interface_build_in_mode,none,
108108
"'-explicit-interface-module-build' only supported when building a module from interface ('-compile-module-from-interface')'", ())
109+
ERROR(error_cannot_direct_cc1_pcm_build_in_mode,none,
110+
"'-direct-clang-cc1-module-build' only supported when building a PCM ('-emit-pcm')'", ())
109111
ERROR(error_unsupported_option_argument,none,
110112
"unsupported argument '%1' to option '%0'", (StringRef, StringRef))
111113
ERROR(error_immediate_mode_missing_stdlib,none,

include/swift/Basic/LangOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,11 @@ namespace swift {
808808
/// contains the full option set.
809809
bool ExtraArgsOnly = false;
810810

811+
/// When building a PCM, rely on the Swift frontend's command-line -Xcc flags
812+
/// to build the Clang module via Clang frontend directly,
813+
/// and completly bypass the Clang driver.
814+
bool DirectClangCC1ModuleBuild = false;
815+
811816
/// Return a hash code of any components from these options that should
812817
/// contribute to a Swift Bridging PCH hash.
813818
llvm::hash_code getPCHHashComponents() const {

include/swift/Frontend/FrontendOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ class FrontendOptions {
392392
/// header.
393393
bool ExposePublicDeclsInClangHeader = false;
394394

395+
/// Emit C++ bindings for the exposed Swift declarations in the generated
396+
/// clang header.
397+
bool EnableExperimentalCxxInteropInClangHeader = false;
398+
395399
/// \return true if the given action only parses without doing other compilation steps.
396400
static bool shouldActionOnlyParse(ActionType);
397401

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,10 @@ def explicit_interface_module_build :
889889
Flag<["-"], "explicit-interface-module-build">,
890890
HelpText<"Use the specified command-line to build the module from interface, instead of flags specified in the interface">;
891891

892+
def direct_clang_cc1_module_build :
893+
Flag<["-"], "direct-clang-cc1-module-build">,
894+
HelpText<"Use the specified -Xcc options to build a PCM by using Clang frontend directly, bypassing the Clang driver">;
895+
892896
def build_module_from_parseable_interface :
893897
Flag<["-"], "build-module-from-parseable-interface">,
894898
Alias<compile_module_from_interface>,

include/swift/Option/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ def enable_experimental_cxx_interop :
630630
Flags<[FrontendOption, HelpHidden, ModuleInterfaceOption]>,
631631
HelpText<"Enable experimental C++ interop code generation and config directives">;
632632

633+
def enable_experimental_cxx_interop_in_clang_header :
634+
Flag<["-"], "enable-experimental-cxx-interop-in-clang-header">,
635+
Flags<[FrontendOption, NoDriverOption, HelpHidden]>,
636+
HelpText<"Enable experimental Swift to C++ interop code generation in generated Clang header">;
637+
633638
def experimental_cxx_stdlib :
634639
Separate<["-"], "experimental-cxx-stdlib">,
635640
Flags<[HelpHidden]>,

include/swift/PrintAsClang/PrintAsClang.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "swift/AST/Identifier.h"
1919

2020
namespace swift {
21+
class FrontendOptions;
2122
class IRGenOptions;
2223
class ModuleDecl;
2324
class ValueDecl;
@@ -34,7 +35,7 @@ class ValueDecl;
3435
/// Returns true on error.
3536
bool printAsClangHeader(raw_ostream &out, ModuleDecl *M,
3637
StringRef bridgingHeader,
37-
bool ExposePublicDeclsInClangHeader,
38+
const FrontendOptions &frontendOpts,
3839
const IRGenOptions &irGenOpts);
3940
}
4041

lib/ClangImporter/ClangImporter.cpp

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,27 +1040,51 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
10401040
invocationArgs.reserve(invocationArgStrs.size());
10411041
for (auto &argStr : invocationArgStrs)
10421042
invocationArgs.push_back(argStr.c_str());
1043-
// Set up a temporary diagnostic client to report errors from parsing the
1044-
// command line, which may be important for Swift clients if, for example,
1045-
// they're using -Xcc options. Unfortunately this diagnostic engine has to
1046-
// use the default options because the /actual/ options haven't been parsed
1047-
// yet.
1048-
//
1049-
// The long-term client for Clang diagnostics is set up below, after the
1050-
// clang::CompilerInstance is created.
1051-
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> tempDiagOpts{
1052-
new clang::DiagnosticOptions
1053-
};
10541043

1055-
ClangDiagnosticConsumer tempDiagClient{importer->Impl, *tempDiagOpts,
1056-
importerOpts.DumpClangDiagnostics};
1057-
llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> tempClangDiags =
1058-
clang::CompilerInstance::createDiagnostics(tempDiagOpts.get(),
1059-
&tempDiagClient,
1060-
/*owned*/false);
1044+
llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> clangDiags;
1045+
std::unique_ptr<clang::CompilerInvocation> CI;
1046+
if (importerOpts.DirectClangCC1ModuleBuild) {
1047+
// In this mode, we bypass createInvocationFromCommandLine, which goes
1048+
// through the Clang driver, and use strictly cc1 arguments to instantiate a
1049+
// clang Instance directly, assuming that the set of '-Xcc <X>' frontend flags is
1050+
// fully sufficient to do so.
1051+
1052+
// Because we are bypassing the Clang driver, we must populate
1053+
// the diagnostic options here explicitly.
1054+
std::unique_ptr<clang::DiagnosticOptions> clangDiagOpts =
1055+
clang::CreateAndPopulateDiagOpts(invocationArgs);
1056+
ClangDiagnosticConsumer diagClient{importer->Impl, *clangDiagOpts,
1057+
importerOpts.DumpClangDiagnostics};
1058+
clangDiags = clang::CompilerInstance::createDiagnostics(
1059+
clangDiagOpts.release(), &diagClient,
1060+
/*owned*/ false);
1061+
1062+
// Finally, use the CC1 command-line and the diagnostic engine
1063+
// to instantiate our Invocation.
1064+
CI = std::make_unique<clang::CompilerInvocation>();
1065+
if (!clang::CompilerInvocation::CreateFromArgs(
1066+
*CI, invocationArgs, *clangDiags, invocationArgs[0]))
1067+
return nullptr;
1068+
} else {
1069+
// Set up a temporary diagnostic client to report errors from parsing the
1070+
// command line, which may be important for Swift clients if, for example,
1071+
// they're using -Xcc options. Unfortunately this diagnostic engine has to
1072+
// use the default options because the /actual/ options haven't been parsed
1073+
// yet.
1074+
//
1075+
// The long-term client for Clang diagnostics is set up below, after the
1076+
// clang::CompilerInstance is created.
1077+
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> tempDiagOpts{
1078+
new clang::DiagnosticOptions};
10611079

1062-
auto CI = clang::createInvocationFromCommandLine(
1063-
invocationArgs, tempClangDiags, VFS, false, CC1Args);
1080+
ClangDiagnosticConsumer tempDiagClient{importer->Impl, *tempDiagOpts,
1081+
importerOpts.DumpClangDiagnostics};
1082+
clangDiags = clang::CompilerInstance::createDiagnostics(tempDiagOpts.get(),
1083+
&tempDiagClient,
1084+
/*owned*/ false);
1085+
CI = clang::createInvocationFromCommandLine(invocationArgs, clangDiags, VFS,
1086+
false, CC1Args);
1087+
}
10641088

10651089
if (!CI) {
10661090
return CI;
@@ -1077,8 +1101,9 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
10771101
// rdar://77516546 is tracking that the clang importer should be more
10781102
// resilient and provide a module even if there were building it.
10791103
auto TempVFS = clang::createVFSFromCompilerInvocation(
1080-
*CI, *tempClangDiags,
1104+
*CI, *clangDiags,
10811105
VFS ? VFS : importer->Impl.SwiftContext.SourceMgr.getFileSystem());
1106+
10821107
std::vector<std::string> FilteredModuleMapFiles;
10831108
for (auto ModuleMapFile : CI->getFrontendOpts().ModuleMapFiles) {
10841109
if (TempVFS->exists(ModuleMapFile)) {
@@ -1105,13 +1130,11 @@ ClangImporter::create(ASTContext &ctx,
11051130
if (importerOpts.DumpClangDiagnostics) {
11061131
llvm::errs() << "'";
11071132
llvm::interleave(
1108-
invocationArgStrs, [](StringRef arg) { llvm::errs() << arg; },
1109-
[] { llvm::errs() << "' '"; });
1133+
invocationArgStrs, [](StringRef arg) { llvm::errs() << arg; },
1134+
[] { llvm::errs() << "' '"; });
11101135
llvm::errs() << "'\n";
11111136
}
11121137

1113-
1114-
11151138
if (isPCHFilenameExtension(importerOpts.BridgingHeader)) {
11161139
importer->Impl.setSinglePCHImport(importerOpts.BridgingHeader);
11171140
importer->Impl.IsReadingBridgingPCH = true;

lib/ClangImporter/SwiftDeclSynthesizer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
981981
Ctx, structDecl->getDeclContext(), clang::SourceLocation(),
982982
clang::SourceLocation(), cGetterName, cGetterType, cGetterTypeInfo,
983983
clang::SC_Static);
984+
cGetterDecl->setImplicit();
984985
cGetterDecl->setImplicitlyInline();
985986
assert(!cGetterDecl->isExternallyVisible());
986987

@@ -1002,6 +1003,7 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
10021003
Ctx, structDecl->getDeclContext(), clang::SourceLocation(),
10031004
clang::SourceLocation(), cSetterName, cSetterType, cSetterTypeInfo,
10041005
clang::SC_Static);
1006+
cSetterDecl->setImplicit();
10051007
cSetterDecl->setImplicitlyInline();
10061008
assert(!cSetterDecl->isExternallyVisible());
10071009

@@ -1017,6 +1019,7 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
10171019
auto cGetterSelf = clang::ParmVarDecl::Create(
10181020
Ctx, cGetterDecl, clang::SourceLocation(), clang::SourceLocation(),
10191021
cGetterSelfId, recordType, recordTypeInfo, clang::SC_None, nullptr);
1022+
cGetterSelf->setImplicit();
10201023
cGetterDecl->setParams(cGetterSelf);
10211024

10221025
auto cGetterSelfExpr = new (Ctx)
@@ -1040,13 +1043,15 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
10401043
Ctx, cSetterDecl, clang::SourceLocation(), clang::SourceLocation(),
10411044
/* nameID? */ nullptr, fieldType, fieldTypeInfo, clang::SC_None,
10421045
nullptr);
1046+
cSetterValue->setImplicit();
10431047
cSetterParams.push_back(cSetterValue);
10441048
auto recordPointerTypeInfo =
10451049
Ctx.getTrivialTypeSourceInfo(recordPointerType);
10461050
auto cSetterSelf = clang::ParmVarDecl::Create(
10471051
Ctx, cSetterDecl, clang::SourceLocation(), clang::SourceLocation(),
10481052
/* nameID? */ nullptr, recordPointerType, recordPointerTypeInfo,
10491053
clang::SC_None, nullptr);
1054+
cSetterSelf->setImplicit();
10501055
cSetterParams.push_back(cSetterSelf);
10511056
cSetterDecl->setParams(cSetterParams);
10521057

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ bool ArgsToFrontendOptionsConverter::convert(
286286
Opts.DisableBuildingInterface = Args.hasArg(OPT_disable_building_interface);
287287
Opts.ExposePublicDeclsInClangHeader =
288288
Args.hasArg(OPT_clang_header_expose_public_decls);
289+
Opts.EnableExperimentalCxxInteropInClangHeader =
290+
Args.hasArg(OPT_enable_experimental_cxx_interop_in_clang_header);
289291

290292
computeImportObjCHeaderOptions();
291293
computeImplicitImportModuleNames(OPT_import_module, /*isTestable=*/false);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
12731273
}
12741274

12751275
Opts.ExtraArgsOnly |= Args.hasArg(OPT_extra_clang_options_only);
1276+
Opts.DirectClangCC1ModuleBuild |= Args.hasArg(OPT_direct_clang_cc1_module_build);
12761277

12771278
if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) {
12781279
Opts.PrecompiledHeaderOutputDir = A->getValue();

lib/FrontendTool/FrontendTool.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ static bool writeSIL(SILModule &SM, const PrimarySpecificPaths &PSPs,
181181
/// \see swift::printAsClangHeader
182182
static bool printAsClangHeaderIfNeeded(StringRef outputPath, ModuleDecl *M,
183183
StringRef bridgingHeader,
184-
bool ExposePublicDeclsInClangHeader,
184+
const FrontendOptions &frontendOpts,
185185
const IRGenOptions &irGenOpts) {
186186
if (outputPath.empty())
187187
return false;
188-
return withOutputFile(
189-
M->getDiags(), outputPath, [&](raw_ostream &out) -> bool {
190-
return printAsClangHeader(out, M, bridgingHeader,
191-
ExposePublicDeclsInClangHeader, irGenOpts);
192-
});
188+
return withOutputFile(M->getDiags(), outputPath,
189+
[&](raw_ostream &out) -> bool {
190+
return printAsClangHeader(out, M, bridgingHeader,
191+
frontendOpts, irGenOpts);
192+
});
193193
}
194194

195195
/// Prints the stable module interface for \p M to \p outputPath.
@@ -936,8 +936,8 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
936936
}
937937
hadAnyError |= printAsClangHeaderIfNeeded(
938938
Invocation.getClangHeaderOutputPathForAtMostOnePrimary(),
939-
Instance.getMainModule(), BridgingHeaderPathForPrint,
940-
opts.ExposePublicDeclsInClangHeader, Invocation.getIRGenOptions());
939+
Instance.getMainModule(), BridgingHeaderPathForPrint, opts,
940+
Invocation.getIRGenOptions());
941941
}
942942

943943
// Only want the header if there's been any errors, ie. there's not much

lib/IRGen/GenConstant.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,11 @@ llvm::Constant *irgen::emitConstantObject(IRGenModule &IGM, ObjectInst *OI,
288288
IGM.swiftImmortalRefCount = var;
289289
}
290290
if (!IGM.swiftStaticArrayMetadata) {
291+
// HACK: This should be an alias to this symbol rather than a direct
292+
// reference.
291293
auto *var = new llvm::GlobalVariable(IGM.Module, IGM.TypeMetadataStructTy,
292294
/*constant*/ true, llvm::GlobalValue::ExternalLinkage,
293-
/*initializer*/ nullptr, "_swiftStaticArrayMetadata");
295+
/*initializer*/ nullptr, "$ss19__EmptyArrayStorageCN");
294296
IGM.swiftStaticArrayMetadata = var;
295297
}
296298
elts[0] = llvm::ConstantStruct::get(ObjectHeaderTy, {

lib/IRGen/IRGenModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
138138
CGO.TrapFuncName = Opts.TrapFuncName;
139139
}
140140

141+
// We don't need to perform coverage mapping for any Clang decls we've
142+
// synthesized, as they have no user-written code. This is also needed to
143+
// avoid a Clang crash when attempting to emit coverage for decls without
144+
// source locations (rdar://100172217).
145+
CGO.CoverageMapping = false;
146+
141147
auto &VFS = Importer->getClangInstance().getVirtualFileSystem();
142148
auto &HSI = Importer->getClangPreprocessor()
143149
.getHeaderSearchInfo()

lib/PrintAsClang/PrintAsClang.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/PrettyStackTrace.h"
2121
#include "swift/Basic/Version.h"
2222
#include "swift/ClangImporter/ClangImporter.h"
23+
#include "swift/Frontend/FrontendOptions.h"
2324

2425
#include "clang/Basic/Module.h"
2526

@@ -506,7 +507,7 @@ static std::string getModuleContentsCxxString(
506507

507508
bool swift::printAsClangHeader(raw_ostream &os, ModuleDecl *M,
508509
StringRef bridgingHeader,
509-
bool ExposePublicDeclsInClangHeader,
510+
const FrontendOptions &frontendOpts,
510511
const IRGenOptions &irGenOpts) {
511512
llvm::PrettyStackTraceString trace("While generating Clang header");
512513

@@ -523,12 +524,15 @@ bool swift::printAsClangHeader(raw_ostream &os, ModuleDecl *M,
523524
emitObjCConditional(os, [&] { os << objcModuleContents.str(); });
524525
emitCxxConditional(os, [&] {
525526
// FIXME: Expose Swift with @expose by default.
526-
if (ExposePublicDeclsInClangHeader ||
527-
M->DeclContext::getASTContext().LangOpts.EnableCXXInterop) {
527+
bool enableCxx = frontendOpts.ExposePublicDeclsInClangHeader ||
528+
frontendOpts.EnableExperimentalCxxInteropInClangHeader ||
529+
M->DeclContext::getASTContext().LangOpts.EnableCXXInterop;
530+
if (enableCxx) {
528531
SmallPtrSet<ImportModuleTy, 8> imports;
529532
auto contents = getModuleContentsCxxString(
530533
*M, imports, interopContext,
531-
/*requiresExposedAttribute=*/!ExposePublicDeclsInClangHeader);
534+
/*requiresExposedAttribute=*/
535+
!frontendOpts.ExposePublicDeclsInClangHeader);
532536
// FIXME: In ObjC++ mode, we do not need to reimport duplicate modules.
533537
writeImports(os, imports, *M, bridgingHeader, /*useCxxImport=*/true);
534538
os << contents;

lib/SIL/IR/SILBasicBlock.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ void SILBasicBlock::cloneArgumentList(SILBasicBlock *Other) {
123123
if (isEntry()) {
124124
assert(args_empty() && "Expected to have no arguments");
125125
for (auto *FuncArg : Other->getSILFunctionArguments()) {
126-
createFunctionArgument(FuncArg->getType(),
127-
FuncArg->getDecl());
126+
auto *NewArg =
127+
createFunctionArgument(FuncArg->getType(), FuncArg->getDecl());
128+
NewArg->setNoImplicitCopy(FuncArg->isNoImplicitCopy());
129+
NewArg->setLifetimeAnnotation(FuncArg->getLifetimeAnnotation());
128130
}
129131
return;
130132
}

lib/SILOptimizer/FunctionSignatureTransforms/ArgumentExplosionTransform.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,12 @@ void FunctionSignatureTransform::ArgumentExplosionFinalizeOptimizedFunction() {
390390

391391
for (auto *Node : LeafNodes) {
392392
auto OwnershipKind = *AD.getTransformedOwnershipKind(Node->getType());
393-
LeafValues.push_back(
393+
auto *Argument =
394394
BB->insertFunctionArgument(ArgOffset, Node->getType(), OwnershipKind,
395-
BB->getArgument(OldArgIndex)->getDecl()));
395+
BB->getArgument(OldArgIndex)->getDecl());
396+
Argument->setNoImplicitCopy(AD.Arg->isNoImplicitCopy());
397+
Argument->setLifetimeAnnotation(AD.Arg->getLifetimeAnnotation());
398+
LeafValues.push_back(Argument);
396399
TransformDescriptor.AIM[TotalArgIndex - 1] = AD.Index;
397400
++ArgOffset;
398401
++TotalArgIndex;

lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ void ExistentialSpecializerCloner::cloneArguments(
165165
LoweredTy.getCategoryType(ArgDesc.Arg->getType().getCategory());
166166
auto *NewArg =
167167
ClonedEntryBB->createFunctionArgument(MappedTy, ArgDesc.Decl);
168+
NewArg->setNoImplicitCopy(ArgDesc.Arg->isNoImplicitCopy());
169+
NewArg->setLifetimeAnnotation(ArgDesc.Arg->getLifetimeAnnotation());
168170
NewArg->setOwnershipKind(ValueOwnershipKind(
169171
NewF, MappedTy, ArgDesc.Arg->getArgumentConvention()));
170172
entryArgs.push_back(NewArg);
@@ -180,6 +182,8 @@ void ExistentialSpecializerCloner::cloneArguments(
180182
GenericSILType, ArgDesc.Decl,
181183
ValueOwnershipKind(NewF, GenericSILType,
182184
ArgDesc.Arg->getArgumentConvention()));
185+
NewArg->setNoImplicitCopy(ArgDesc.Arg->isNoImplicitCopy());
186+
NewArg->setLifetimeAnnotation(ArgDesc.Arg->getLifetimeAnnotation());
183187
// Determine the Conformances.
184188
SILType ExistentialType = ArgDesc.Arg->getType().getObjectType();
185189
CanType OpenedType = NewArg->getType().getASTType();
@@ -402,7 +406,10 @@ void ExistentialTransform::populateThunkBody() {
402406
auto *ThunkBody = F->createBasicBlock();
403407
for (auto &ArgDesc : ArgumentDescList) {
404408
auto argumentType = ArgDesc.Arg->getType();
405-
ThunkBody->createFunctionArgument(argumentType, ArgDesc.Decl);
409+
auto *NewArg =
410+
ThunkBody->createFunctionArgument(argumentType, ArgDesc.Decl);
411+
NewArg->setNoImplicitCopy(ArgDesc.Arg->isNoImplicitCopy());
412+
NewArg->setLifetimeAnnotation(ArgDesc.Arg->getLifetimeAnnotation());
406413
}
407414

408415
/// Builder to add new instructions in the Thunk.

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,10 @@ void FunctionSignatureTransform::createFunctionSignatureOptimizedFunction() {
566566
F->setInlineStrategy(AlwaysInline);
567567
SILBasicBlock *ThunkBody = F->createBasicBlock();
568568
for (auto &ArgDesc : TransformDescriptor.ArgumentDescList) {
569-
ThunkBody->createFunctionArgument(ArgDesc.Arg->getType(), ArgDesc.Decl);
569+
auto *NewArg =
570+
ThunkBody->createFunctionArgument(ArgDesc.Arg->getType(), ArgDesc.Decl);
571+
NewArg->setNoImplicitCopy(ArgDesc.Arg->isNoImplicitCopy());
572+
NewArg->setLifetimeAnnotation(ArgDesc.Arg->getLifetimeAnnotation());
570573
}
571574

572575
SILLocation Loc = RegularLocation::getAutoGeneratedLocation();

0 commit comments

Comments
 (0)