Skip to content

Commit a1c6568

Browse files
committed
[Coro] RetconOnceDynamic: Annotate alloc param.
Mark the allocator parameter passed to the allocation functions swiftcoro.
1 parent b45f016 commit a1c6568

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

llvm/lib/Transforms/Coroutines/Coroutines.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ Value *coro::Shape::emitAlloc(IRBuilder<> &Builder, Value *Size,
559559
Args.push_back(TypeId);
560560
}
561561
auto *Call = Builder.CreateCall(Alloc, Args);
562+
if (ABI == coro::ABI::RetconOnceDynamic) {
563+
Call->addParamAttr(1, Attribute::SwiftCoro);
564+
}
562565
propagateCallAttrsFromCallee(Call, Alloc);
563566
addCallToCallGraph(CG, Call, Alloc);
564567
return Call;
@@ -598,6 +601,9 @@ void coro::Shape::emitDealloc(IRBuilder<> &Builder, Value *Ptr,
598601
Ptr, Dealloc->getFunctionType()->getParamType(allocationParamIndex));
599602
Args.push_back(Ptr);
600603
auto *Call = Builder.CreateCall(Dealloc, Args);
604+
if (ABI == coro::ABI::RetconOnceDynamic) {
605+
Call->addParamAttr(1, Attribute::SwiftCoro);
606+
}
601607
propagateCallAttrsFromCallee(Call, Dealloc);
602608
addCallToCallGraph(CG, Call, Dealloc);
603609
return;

llvm/test/Transforms/Coroutines/coro-retcon-once-dynamic.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ declare { ptr, ptr } @allocating_something_else(ptr noalias %frame, ptr swiftcor
187187
; CHECK: %size = call i32 @getSize()
188188
; CHECK: call swiftcorocc ptr @allocate(
189189
; CHECK-SAME: ptr %frame,
190-
; CHECK-SAME: ptr %allocator,
190+
; CHECK-SAME: ptr swiftcoro %allocator,
191191
; CHECK-SAME: i32 %size
192192
; CHECK-SAME: )
193193
; CHECK: call swiftcorocc ptr @allocate_frame(
194194
; CHECK-SAME: ptr %frame,
195-
; CHECK-SAME: ptr %allocator,
195+
; CHECK-SAME: ptr swiftcoro %allocator,
196196
; CHECK-SAME: i32
197197
; CHECK-SAME: )
198198
; CHECK-LABEL: @allocating_something.resume.0(
@@ -202,12 +202,12 @@ declare { ptr, ptr } @allocating_something_else(ptr noalias %frame, ptr swiftcor
202202
; CHECK-SAME: {
203203
; CHECK: call void @deallocate_frame(
204204
; CHECK-SAME: ptr %0,
205-
; CHECK-SAME: ptr %1,
205+
; CHECK-SAME: ptr swiftcoro %1,
206206
; CHECK-SAME: ptr
207207
; CHECK-SAME: )
208208
; CHECK: call void @deallocate(
209209
; CHECK-SAME: ptr %0,
210-
; CHECK-SAME: ptr %1,
210+
; CHECK-SAME: ptr swiftcoro %1,
211211
; CHECK-SAME: ptr
212212
; CHECK-SAME: )
213213
@allocating_something_cfp = constant <{ i32, i32 }>

0 commit comments

Comments
 (0)