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:
Saleem Abdulrasool
2019-06-25 20:05:25 -07:00
parent b951eedbd3
commit 053425a6a1

View File

@@ -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