[SILOptimizer] Preserve arg attrs at cloning.

Arguments are copied into new cloned functions in a number of places.
Wherever that happens, be sure to transfer the attributes as well.
This commit is contained in:
Nate Chandler
2022-09-13 10:15:45 -07:00
parent e03c5683b1
commit 5d14610043
19 changed files with 480 additions and 16 deletions

View File

@@ -2544,8 +2544,12 @@ SILFunction *ReabstractionThunkGenerator::createThunk() {
if (!SILModuleConventions(M).useLoweredAddresses()) {
for (auto SpecArg : SpecializedFunc->getArguments()) {
SILArgument *NewArg = EntryBB->createFunctionArgument(SpecArg->getType(),
SpecArg->getDecl());
auto *NewArg = EntryBB->createFunctionArgument(SpecArg->getType(),
SpecArg->getDecl());
NewArg->setNoImplicitCopy(
cast<SILFunctionArgument>(SpecArg)->isNoImplicitCopy());
NewArg->setLifetimeAnnotation(
cast<SILFunctionArgument>(SpecArg)->getLifetimeAnnotation());
Arguments.push_back(NewArg);
}
FullApplySite ApplySite = createReabstractionThunkApply(Builder);
@@ -2642,8 +2646,12 @@ SILArgument *ReabstractionThunkGenerator::convertReabstractionThunkArguments(
auto cloneSpecializedArgument = [&]() {
// No change to the argument.
SILArgument *SpecArg = *SpecArgIter++;
SILArgument *NewArg =
auto *NewArg =
EntryBB->createFunctionArgument(SpecArg->getType(), SpecArg->getDecl());
NewArg->setNoImplicitCopy(
cast<SILFunctionArgument>(SpecArg)->isNoImplicitCopy());
NewArg->setLifetimeAnnotation(
cast<SILFunctionArgument>(SpecArg)->getLifetimeAnnotation());
Arguments.push_back(NewArg);
};
// ReInfo.NumIndirectResults corresponds to SubstTy's formal indirect
@@ -2685,6 +2693,10 @@ SILArgument *ReabstractionThunkGenerator::convertReabstractionThunkArguments(
SILArgument *SpecArg = *SpecArgIter++;
SILFunctionArgument *NewArg =
EntryBB->createFunctionArgument(ParamTy, SpecArg->getDecl());
NewArg->setNoImplicitCopy(
cast<SILFunctionArgument>(SpecArg)->isNoImplicitCopy());
NewArg->setLifetimeAnnotation(
cast<SILFunctionArgument>(SpecArg)->getLifetimeAnnotation());
if (!NewArg->getArgumentConvention().isGuaranteedConvention()) {
SILValue argVal = Builder.emitLoadValueOperation(
Loc, NewArg, LoadOwnershipQualifier::Take);