@@ -325,16 +325,10 @@ PointerAuthInfo::getOtherDiscriminator(IRGenModule &IGM,
325
325
llvm_unreachable (" bad kind" );
326
326
}
327
327
328
- static llvm::ConstantInt *getDiscriminatorForHash (IRGenModule &IGM,
329
- uint64_t rawHash) {
330
- uint16_t reducedHash = (rawHash % 0xFFFF ) + 1 ;
331
- return llvm::ConstantInt::get (IGM.Int64Ty , reducedHash);
332
- }
333
-
334
328
static llvm::ConstantInt *getDiscriminatorForString (IRGenModule &IGM,
335
329
StringRef string) {
336
- uint64_t rawHash = llvm::getPointerAuthStableSipHash (string);
337
- return getDiscriminatorForHash (IGM, rawHash );
330
+ return llvm::ConstantInt::get (IGM. Int64Ty ,
331
+ llvm::getPointerAuthStableSipHash (string) );
338
332
}
339
333
340
334
static std::string mangle (AssociatedTypeDecl *assocType) {
@@ -571,7 +565,8 @@ static void hashStringForFunctionType(IRGenModule &IGM, CanSILFunctionType type,
571
565
}
572
566
}
573
567
574
- static uint64_t getTypeHash (IRGenModule &IGM, CanSILFunctionType type) {
568
+ static llvm::ConstantInt *getTypeDiscriminator (IRGenModule &IGM,
569
+ CanSILFunctionType type) {
575
570
// The hash we need to do here ignores:
576
571
// - thickness, so that we can promote thin-to-thick without rehashing;
577
572
// - error results, so that we can promote nonthrowing-to-throwing
@@ -591,10 +586,11 @@ static uint64_t getTypeHash(IRGenModule &IGM, CanSILFunctionType type) {
591
586
hashStringForFunctionType (
592
587
IGM, type, Out,
593
588
genericSig.getCanonicalSignature ().getGenericEnvironment ());
594
- return llvm::getPointerAuthStableSipHash ( Out.str ());
589
+ return getDiscriminatorForString (IGM, Out.str ());
595
590
}
596
591
597
- static uint64_t getYieldTypesHash (IRGenModule &IGM, CanSILFunctionType type) {
592
+ static llvm::ConstantInt *
593
+ getCoroutineYieldTypesDiscriminator (IRGenModule &IGM, CanSILFunctionType type) {
598
594
SmallString<32 > buffer;
599
595
llvm::raw_svector_ostream out (buffer);
600
596
auto genericSig = type->getInvocationGenericSignature ();
@@ -630,7 +626,7 @@ static uint64_t getYieldTypesHash(IRGenModule &IGM, CanSILFunctionType type) {
630
626
out << " :" ;
631
627
}
632
628
633
- return llvm::getPointerAuthStableSipHash ( out.str ());
629
+ return getDiscriminatorForString (IGM, out.str ());
634
630
}
635
631
636
632
llvm::ConstantInt *
@@ -650,8 +646,7 @@ PointerAuthEntity::getTypeDiscriminator(IRGenModule &IGM) const {
650
646
llvm::ConstantInt *&cache = IGM.getPointerAuthCaches ().Types [fnType];
651
647
if (cache) return cache;
652
648
653
- auto hash = getTypeHash (IGM, fnType);
654
- cache = getDiscriminatorForHash (IGM, hash);
649
+ cache = ::getTypeDiscriminator (IGM, fnType);
655
650
return cache;
656
651
}
657
652
@@ -668,15 +663,6 @@ PointerAuthEntity::getTypeDiscriminator(IRGenModule &IGM) const {
668
663
llvm_unreachable (" invalid representation" );
669
664
};
670
665
671
- auto getCoroutineYieldTypesDiscriminator = [&](CanSILFunctionType fnType) {
672
- llvm::ConstantInt *&cache = IGM.getPointerAuthCaches ().Types [fnType];
673
- if (cache) return cache;
674
-
675
- auto hash = getYieldTypesHash (IGM, fnType);
676
- cache = getDiscriminatorForHash (IGM, hash);
677
- return cache;
678
- };
679
-
680
666
switch (StoredKind) {
681
667
case Kind::None:
682
668
case Kind::Special:
@@ -688,7 +674,13 @@ PointerAuthEntity::getTypeDiscriminator(IRGenModule &IGM) const {
688
674
689
675
case Kind::CoroutineYieldTypes: {
690
676
auto fnType = Storage.get <CanSILFunctionType>(StoredKind);
691
- return getCoroutineYieldTypesDiscriminator (fnType);
677
+
678
+ llvm::ConstantInt *&cache = IGM.getPointerAuthCaches ().Types [fnType];
679
+ if (cache)
680
+ return cache;
681
+
682
+ cache = getCoroutineYieldTypesDiscriminator (IGM, fnType);
683
+ return cache;
692
684
}
693
685
694
686
case Kind::CanSILFunctionType: {
0 commit comments