Skip to content

Commit f067cb7

Browse files
committed
IRGen: address TODO for COMDATing
Enable COMDATing in `createFunction`. This is particularly important for the emission of the GetEnumTagSinglePayload. The function emission is marked as linkonce ODR but does not get COMDAT'ed currently, breaking emission on PE/COFF targets like Windows.
1 parent 29e4c67 commit f067cb7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,9 +1594,6 @@ llvm::Function *irgen::createFunction(IRGenModule &IGM,
15941594

15951595
llvm::Function *fn =
15961596
llvm::Function::Create(signature.getType(), linkInfo.getLinkage(), name);
1597-
// TODO(compnerd) apply COMDAT to definitions
1598-
fn->setVisibility(linkInfo.getVisibility());
1599-
fn->setDLLStorageClass(linkInfo.getDLLStorage());
16001597
fn->setCallingConv(signature.getCallingConv());
16011598

16021599
if (insertBefore) {
@@ -1605,6 +1602,9 @@ llvm::Function *irgen::createFunction(IRGenModule &IGM,
16051602
IGM.Module.getFunctionList().push_back(fn);
16061603
}
16071604

1605+
ApplyIRLinkage({linkInfo.getLinkage(), linkInfo.getVisibility(), linkInfo.getDLLStorage()})
1606+
.to(fn);
1607+
16081608
llvm::AttrBuilder initialAttrs;
16091609
IGM.constructInitialFnAttributes(initialAttrs, FuncOptMode);
16101610
// Merge initialAttrs with attrs.

0 commit comments

Comments
 (0)