mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
IRGen: fix multithreaded COMDAT handling for PE/COFF
Correct the COMDAT handling for the type metadata emission. In particular, declarations should not be emitted with COMDATs. The pattern used in the compiler for the metadata emission is different than the other structures. In particular, `getAddrOfTypeMetadata` emits the declaration for the type metadata symbol. The definition for the type metadata will be emitted via `defineTypeMetadata`. This change adjusts the IRGen to remove the COMDAT on the declaration permitting the definition from `defineTypeMetadata` being emitted strongly. This exposes a bug in the LLVM MC layer which is a separate change that will enable this to function properly.
This commit is contained in:
@@ -3629,6 +3629,8 @@ ConstantReference IRGenModule::getAddrOfTypeMetadata(CanType concreteType,
|
||||
|
||||
auto addr = getAddrOfLLVMVariable(*entity, ConstantInit(), DbgTy, refKind,
|
||||
defaultVarTy);
|
||||
if (auto *GV = dyn_cast<llvm::GlobalVariable>(addr.getValue()))
|
||||
GV->setComdat(nullptr);
|
||||
|
||||
// FIXME: MC breaks when emitting alias references on some platforms
|
||||
// (rdar://problem/22450593 ). Work around this by referring to the aliasee
|
||||
|
||||
Reference in New Issue
Block a user