@@ -301,11 +301,17 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
301
301
// / Structure that captures data that is segregated into different
302
302
// / arenas.
303
303
struct Arena {
304
+ static_assert (alignof (TypeBase) >= 8 , " TypeBase not 8-byte aligned?" );
305
+ static_assert (alignof (TypeBase) > static_cast <unsigned >(
306
+ MetatypeRepresentation::Last_MetatypeRepresentation) + 1 ,
307
+ " Use std::pair for MetatypeTypes and ExistentialMetatypeTypes." );
308
+
304
309
llvm::DenseMap<Type, ErrorType *> ErrorTypesWithOriginal;
305
310
llvm::FoldingSet<TypeAliasType> TypeAliasTypes;
306
311
llvm::FoldingSet<TupleType> TupleTypes;
307
- llvm::DenseMap<std::pair<Type,char >, MetatypeType*> MetatypeTypes;
308
- llvm::DenseMap<std::pair<Type,char >,
312
+ llvm::DenseMap<llvm::PointerIntPair<TypeBase*, 3 , unsigned >,
313
+ MetatypeType*> MetatypeTypes;
314
+ llvm::DenseMap<llvm::PointerIntPair<TypeBase*, 3 , unsigned >,
309
315
ExistentialMetatypeType*> ExistentialMetatypeTypes;
310
316
llvm::DenseMap<Type, ArraySliceType*> ArraySliceTypes;
311
317
llvm::DenseMap<std::pair<Type, Type>, DictionaryType *> DictionaryTypes;
@@ -3492,13 +3498,16 @@ MetatypeType *MetatypeType::get(Type T, Optional<MetatypeRepresentation> Repr,
3492
3498
auto properties = T->getRecursiveProperties ();
3493
3499
auto arena = getArena (properties);
3494
3500
3495
- char reprKey;
3501
+ unsigned reprKey;
3496
3502
if (Repr.hasValue ())
3497
- reprKey = static_cast <char >(*Repr) + 1 ;
3503
+ reprKey = static_cast <unsigned >(*Repr) + 1 ;
3498
3504
else
3499
3505
reprKey = 0 ;
3500
3506
3501
- MetatypeType *&Entry = Ctx.getImpl ().getArena (arena).MetatypeTypes [{T, reprKey}];
3507
+ auto pair = llvm::PointerIntPair<TypeBase*, 3 , unsigned >(T.getPointer (),
3508
+ reprKey);
3509
+
3510
+ MetatypeType *&Entry = Ctx.getImpl ().getArena (arena).MetatypeTypes [pair];
3502
3511
if (Entry) return Entry;
3503
3512
3504
3513
return Entry = new (Ctx, arena) MetatypeType (
@@ -3517,13 +3526,16 @@ ExistentialMetatypeType::get(Type T, Optional<MetatypeRepresentation> repr,
3517
3526
auto properties = T->getRecursiveProperties ();
3518
3527
auto arena = getArena (properties);
3519
3528
3520
- char reprKey;
3529
+ unsigned reprKey;
3521
3530
if (repr.hasValue ())
3522
- reprKey = static_cast <char >(*repr) + 1 ;
3531
+ reprKey = static_cast <unsigned >(*repr) + 1 ;
3523
3532
else
3524
3533
reprKey = 0 ;
3525
3534
3526
- auto &entry = ctx.getImpl ().getArena (arena).ExistentialMetatypeTypes [{T, reprKey}];
3535
+ auto pair = llvm::PointerIntPair<TypeBase*, 3 , unsigned >(T.getPointer (),
3536
+ reprKey);
3537
+
3538
+ auto &entry = ctx.getImpl ().getArena (arena).ExistentialMetatypeTypes [pair];
3527
3539
if (entry) return entry;
3528
3540
3529
3541
return entry = new (ctx, arena) ExistentialMetatypeType (
0 commit comments