Skip to content

Commit de9b696

Browse files
committed
Don't always give shared linkage to spl functions
private functions on specialization were being given shared linkage. Use swift::getSpecializeLinkage to correctly get the linkage for the specialized function based on the linkage of the original function.
1 parent 417e173 commit de9b696

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/SIL/SILCloner.h"
2020
#include "swift/SILOptimizer/PassManager/Passes.h"
2121
#include "swift/SILOptimizer/PassManager/Transforms.h"
22+
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
2223
#include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h"
2324
#include "swift/SILOptimizer/Utils/SpecializationMangler.h"
2425
#include "swift/SILOptimizer/Utils/StackNesting.h"
@@ -633,11 +634,12 @@ SILFunction *PromotedParamCloner::initCloned(SILOptFunctionBuilder &FuncBuilder,
633634
&& "SILFunction missing DebugScope");
634635
assert(!Orig->isGlobalInit() && "Global initializer cannot be cloned");
635636
auto *Fn = FuncBuilder.createFunction(
636-
SILLinkage::Shared, ClonedName, ClonedTy, Orig->getGenericEnvironment(),
637-
Orig->getLocation(), Orig->isBare(), Orig->isTransparent(), Serialized,
638-
IsNotDynamic, Orig->getEntryCount(), Orig->isThunk(),
639-
Orig->getClassSubclassScope(), Orig->getInlineStrategy(),
640-
Orig->getEffectsKind(), Orig, Orig->getDebugScope());
637+
swift::getSpecializedLinkage(Orig, Orig->getLinkage()), ClonedName,
638+
ClonedTy, Orig->getGenericEnvironment(), Orig->getLocation(),
639+
Orig->isBare(), Orig->isTransparent(), Serialized, IsNotDynamic,
640+
Orig->getEntryCount(), Orig->isThunk(), Orig->getClassSubclassScope(),
641+
Orig->getInlineStrategy(), Orig->getEffectsKind(), Orig,
642+
Orig->getDebugScope());
641643
for (auto &Attr : Orig->getSemanticsAttrs()) {
642644
Fn->addSemanticsAttr(Attr);
643645
}

0 commit comments

Comments
 (0)