[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

@@ -799,6 +799,10 @@ PromotedParamCloner::populateCloned() {
Cloned->getModule().Types, 0);
auto *promotedArg =
ClonedEntryBB->createFunctionArgument(promotedTy, (*I)->getDecl());
promotedArg->setNoImplicitCopy(
cast<SILFunctionArgument>(*I)->isNoImplicitCopy());
promotedArg->setLifetimeAnnotation(
cast<SILFunctionArgument>(*I)->getLifetimeAnnotation());
OrigPromotedParameters.insert(*I);
NewPromotedArgs[ArgNo] = promotedArg;
@@ -811,8 +815,13 @@ PromotedParamCloner::populateCloned() {
entryArgs.push_back(SILValue());
} else {
// Create a new argument which copies the original argument.
entryArgs.push_back(ClonedEntryBB->createFunctionArgument(
(*I)->getType(), (*I)->getDecl()));
auto *newArg = ClonedEntryBB->createFunctionArgument((*I)->getType(),
(*I)->getDecl());
newArg->setNoImplicitCopy(
cast<SILFunctionArgument>(*I)->isNoImplicitCopy());
newArg->setLifetimeAnnotation(
cast<SILFunctionArgument>(*I)->getLifetimeAnnotation());
entryArgs.push_back(newArg);
}
++ArgNo;
++I;