llvm/test/Transforms/Coroutines/coro-early.ll
Gor Nishanov fa2883261f Part 4c: Coroutine Devirtualization: Devirtualize coro.resume and coro.destroy.
Summary:
This is the 4c patch of the coroutine series. CoroElide pass now checks if PostSplit coro.begin
is referenced by coro.subfn.addr intrinsics. If so replace coro.subfn.addrs with an appropriate coroutine
subfunction associated with that coro.begin.

Documentation and overview is here: http://llvm.org/docs/Coroutines.html.

Upstreaming sequence (rough plan)
1.Add documentation. (https://reviews.llvm.org/D22603)
2.Add coroutine intrinsics. (https://reviews.llvm.org/D22659)
3.Add empty coroutine passes. (https://reviews.llvm.org/D22847)
4.Add coroutine devirtualization + tests.
ab) Lower coro.resume and coro.destroy (https://reviews.llvm.org/D22998)
c) Do devirtualization <= we are here
5.Add CGSCC restart trigger + tests.
6.Add coroutine heap elision + tests.
7.Add the rest of the logic (split into more patches)

Reviewers: majnemer

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D23229

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277908 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-06 02:16:35 +00:00

42 lines
1.2 KiB
LLVM

; Tests that CoroEarly pass correctly lowers coro.resume and coro.destroy
; intrinsics.
; RUN: opt < %s -S -coro-early | FileCheck %s
; CHECK-LABEL: @callResume(
define void @callResume(i8* %hdl) {
; CHECK-NEXT: entry
entry:
; CHECK-NEXT: %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
; CHECK-NEXT: %1 = bitcast i8* %0 to void (i8*)*
; CHECK-NEXT: call fastcc void %1(i8* %hdl)
call void @llvm.coro.resume(i8* %hdl)
; CHECK-NEXT: %2 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 1)
; CHECK-NEXT: %3 = bitcast i8* %2 to void (i8*)*
; CHECK-NEXT: call fastcc void %3(i8* %hdl)
call void @llvm.coro.destroy(i8* %hdl)
ret void
; CHECK-NEXT: ret void
}
; CHECK-LABEL: @eh(
define void @eh(i8* %hdl) personality i8* null {
; CHECK-NEXT: entry
entry:
; CHECK-NEXT: %0 = call i8* @llvm.coro.subfn.addr(i8* %hdl, i8 0)
; CHECK-NEXT: %1 = bitcast i8* %0 to void (i8*)*
; CHECK-NEXT: invoke fastcc void %1(i8* %hdl)
invoke void @llvm.coro.resume(i8* %hdl)
to label %cont unwind label %ehcleanup
cont:
ret void
ehcleanup:
%0 = cleanuppad within none []
cleanupret from %0 unwind to caller
}
declare void @llvm.coro.resume(i8*)
declare void @llvm.coro.destroy(i8*)