Skip to content

Commit c61e8c1

Browse files
committed
[IRGen] Use 32-bit string hash for type id.
Use all 32 bits of malloc_type_descriptor_t's hash.
1 parent e0ca132 commit c61e8c1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/IRGen/GenPointerAuth.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ PointerAuthInfo::getOtherDiscriminator(IRGenModule &IGM,
327327

328328
static llvm::ConstantInt *getDiscriminatorForString(IRGenModule &IGM,
329329
StringRef string) {
330-
return llvm::ConstantInt::get(IGM.Int64Ty,
331-
llvm::getPointerAuthStableSipHash(string));
330+
uint64_t hash = llvm::getStableSipHash(string);
331+
uint32_t hash32 = (hash % std::numeric_limits<uint32_t>::max()) + 1;
332+
return llvm::ConstantInt::get(IGM.Int64Ty, hash32);
332333
}
333334

334335
static std::string mangle(AssociatedTypeDecl *assocType) {

test/IRGen/yield_once_enable_emit_type_malloc_coro_frame.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ sil @marker : $(Builtin.Int32) -> ()
1111
// CHECK-SAME: [[CORO_ATTRIBUTES:#[0-9]+]]
1212
sil @test_simple : $@yield_once () -> () {
1313
entry:
14-
// CHECK-32: [[ID:%.*]] = call token (i32, i32, ptr, ptr, ptr, ptr, ...) @llvm.coro.id.retcon.once(i32 [[BUFFER_SIZE]], i32 [[BUFFER_ALIGN:4]], ptr %0, ptr @"$sIetA_TC", ptr @__swift_coroFrameAllocStub, ptr @free, i64 38223)
15-
// CHECK-64: [[ID:%.*]] = call token (i32, i32, ptr, ptr, ptr, ptr, ...) @llvm.coro.id.retcon.once(i32 [[BUFFER_SIZE]], i32 [[BUFFER_ALIGN:8]], ptr %0, ptr @"$sIetA_TC", ptr @__swift_coroFrameAllocStub, ptr @free, i64 38223)
14+
// CHECK-32: [[ID:%.*]] = call token (i32, i32, ptr, ptr, ptr, ptr, ...) @llvm.coro.id.retcon.once(i32 [[BUFFER_SIZE]], i32 [[BUFFER_ALIGN:4]], ptr %0, ptr @"$sIetA_TC", ptr @__swift_coroFrameAllocStub, ptr @free, i64 121146903)
15+
// CHECK-64: [[ID:%.*]] = call token (i32, i32, ptr, ptr, ptr, ptr, ...) @llvm.coro.id.retcon.once(i32 [[BUFFER_SIZE]], i32 [[BUFFER_ALIGN:8]], ptr %0, ptr @"$sIetA_TC", ptr @__swift_coroFrameAllocStub, ptr @free, i64 121146903)
1616
// CHECK-NEXT: [[BEGIN:%.*]] = call ptr @llvm.coro.begin(token [[ID]], ptr null)
1717

1818
// CHECK-NEXT: call swiftcc void @marker(i32 1000)

0 commit comments

Comments
 (0)