File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -640,13 +640,13 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
640
640
addUsedGlobal (COMDATKey);
641
641
}
642
642
643
- // If comdats are in use and supported, place the initializer function into
644
- // the comdat group of the global. In the MS ABI, initializers are mangled
645
- // and have their own comdat, so we don't include them in the group for
646
- // consistency with MSVC.
643
+ // If we used a COMDAT key for the global ctor, the init function can be
644
+ // discarded if the global ctor entry is discarded.
645
+ // FIXME: Do we need to restrict this to ELF and Wasm?
647
646
llvm::Comdat *C = Addr->getComdat ();
648
- if (COMDATKey && C && getTriple ().supportsCOMDAT () &&
649
- !getTarget ().getCXXABI ().isMicrosoft ()) {
647
+ if (COMDATKey && C &&
648
+ (getTarget ().getTriple ().isOSBinFormatELF () ||
649
+ getTarget ().getTriple ().isOSBinFormatWasm ())) {
650
650
Fn->setComdat (C);
651
651
}
652
652
} else {
You can’t perform that action at this time.
0 commit comments