Skip to content

Commit e187c65

Browse files
committed
IRGen: only apply DLLStorage if appropriate
Sinking this logic into the IRLinkage application means that we can clean up the various sites that are handling the IRLinkage and/or DLLStorage to apply IRLinkage semantically, making the code easier to understand as well as avoiding the proliferation of the `useDLLStorage` checks.
1 parent a6df046 commit e187c65

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

include/swift/IRGen/Linking.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,23 +1052,23 @@ class ApplyIRLinkage {
10521052
public:
10531053
ApplyIRLinkage(IRLinkage IRL) : IRL(IRL) {}
10541054
void to(llvm::GlobalValue *GV) const {
1055+
llvm::Module *M = GV->getParent();
1056+
const llvm::Triple Triple(M->getTargetTriple());
1057+
10551058
GV->setLinkage(IRL.Linkage);
10561059
GV->setVisibility(IRL.Visibility);
1057-
GV->setDLLStorageClass(IRL.DLLStorage);
1058-
1059-
if (IRL.Linkage == llvm::GlobalValue::LinkOnceODRLinkage ||
1060-
IRL.Linkage == llvm::GlobalValue::WeakODRLinkage) {
1061-
llvm::Module *M = GV->getParent();
1062-
const llvm::Triple Triple(M->getTargetTriple());
1060+
if (Triple.isOSBinFormatCOFF() && !Triple.isOSCygMing())
1061+
GV->setDLLStorageClass(IRL.DLLStorage);
10631062

1064-
// TODO: BFD and gold do not handle COMDATs properly
1065-
if (Triple.isOSBinFormatELF())
1066-
return;
1063+
// TODO: BFD and gold do not handle COMDATs properly
1064+
if (Triple.isOSBinFormatELF())
1065+
return;
10671066

1067+
if (IRL.Linkage == llvm::GlobalValue::LinkOnceODRLinkage ||
1068+
IRL.Linkage == llvm::GlobalValue::WeakODRLinkage)
10681069
if (Triple.supportsCOMDAT())
10691070
if (llvm::GlobalObject *GO = dyn_cast<llvm::GlobalObject>(GV))
10701071
GO->setComdat(M->getOrInsertComdat(GV->getName()));
1071-
}
10721072
}
10731073
};
10741074

0 commit comments

Comments
 (0)