Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/IRGen/GenPointerAuth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,18 @@ void ConstantAggregateBuilderBase::addSignedPointer(llvm::Constant *pointer,
llvm::ConstantInt::get(IGM().Int64Ty, otherDiscriminator));
}

llvm::ConstantInt *IRGenModule::getMallocTypeId(llvm::Function *fn) {
if (!getOptions().EmitTypeMallocForCoroFrame) {
// Even when typed malloc isn't enabled, a type id may be required for ABI
// reasons (e.g. as an argument to swift_coro_alloc). Use a cheaply
// materialized value.
return llvm::ConstantInt::get(Int64Ty, 0);
}
uint64_t hash = llvm::getStableSipHash(fn->getName());
uint32_t hash32 = (hash % std::numeric_limits<uint32_t>::max()) + 1;
return llvm::ConstantInt::get(Int64Ty, hash32);
}

llvm::ConstantInt* IRGenFunction::getMallocTypeId() {
return getDiscriminatorForString(IGM, CurFn->getName());
return IGM.getMallocTypeId(CurFn);
}
2 changes: 2 additions & 0 deletions lib/IRGen/IRGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,8 @@ private: \
llvm::AttributeList constructInitialAttributes();
StackProtectorMode shouldEmitStackProtector(SILFunction *f);

llvm::ConstantInt *getMallocTypeId(llvm::Function *fn);

void emitProtocolDecl(ProtocolDecl *D);
void emitEnumDecl(EnumDecl *D);
void emitStructDecl(StructDecl *D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ sil @marker : $(Builtin.Int32) -> ()
// CHECK-SAME: [[CORO_ATTRIBUTES:#[0-9]+]]
sil @test_simple : $@yield_once () -> () {
entry:
// 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)
// 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)
// 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)
// 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)
// CHECK-NEXT: [[BEGIN:%.*]] = call ptr @llvm.coro.begin(token [[ID]], ptr null)

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