|
27 | 27 | #include "StructLayout.h" |
28 | 28 | #include "Callee.h" |
29 | 29 | #include "ConstantBuilder.h" |
| 30 | +#include "DebugTypeInfo.h" |
| 31 | +#include "swift/IRGen/Linking.h" |
30 | 32 | #include "swift/Basic/Range.h" |
31 | 33 | #include "swift/SIL/SILModule.h" |
32 | 34 | #include "llvm/Support/BLAKE3.h" |
@@ -438,11 +440,12 @@ llvm::Constant *irgen::emitConstantObject(IRGenModule &IGM, ObjectInst *OI, |
438 | 440 | IGM.swiftImmortalRefCount = var; |
439 | 441 | } |
440 | 442 | if (!IGM.swiftStaticArrayMetadata) { |
441 | | - // type metadata for class __StaticArrayStorage |
442 | | - auto *var = new llvm::GlobalVariable(IGM.Module, IGM.TypeMetadataStructTy, |
443 | | - /*constant*/ true, llvm::GlobalValue::ExternalLinkage, |
444 | | - /*initializer*/ nullptr, "$ss20__StaticArrayStorageCN"); |
445 | | - IGM.swiftStaticArrayMetadata = var; |
| 443 | + auto *classDecl = IGM.getStaticArrayStorageDecl(); |
| 444 | + assert(classDecl && "no __StaticArrayStorage in stdlib"); |
| 445 | + CanType classTy = CanType(ClassType::get(classDecl, Type(), IGM.Context)); |
| 446 | + LinkEntity entity = LinkEntity::forTypeMetadata(classTy, TypeMetadataAddress::AddressPoint); |
| 447 | + auto *metatype = IGM.getAddrOfLLVMVariable(entity, NotForDefinition, DebugTypeInfo()); |
| 448 | + IGM.swiftStaticArrayMetadata = cast<llvm::GlobalVariable>(metatype); |
446 | 449 | } |
447 | 450 | elements[0].add(llvm::ConstantStruct::get(ObjectHeaderTy, { |
448 | 451 | IGM.swiftStaticArrayMetadata, |
|
0 commit comments