Skip to content

Commit f0f9b56

Browse files
committed
[IRGen] Use 32-bit string hash for type id.
1 parent 83df3f5 commit f0f9b56

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/IRGen/GenPointerAuth.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,9 @@ llvm::ConstantInt *IRGenModule::getMallocTypeId(llvm::Function *fn) {
778778
// materialized value.
779779
return llvm::ConstantInt::get(Int64Ty, 0);
780780
}
781-
return getDiscriminatorForString(*this, fn->getName());
781+
uint64_t hash = llvm::getStableSipHash(fn->getName());
782+
uint32_t hash32 = (hash % std::numeric_limits<uint32_t>::max()) + 1;
783+
return llvm::ConstantInt::get(Int64Ty, hash32);
782784
}
783785

784786
llvm::ConstantInt* IRGenFunction::getMallocTypeId() {

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)