diff options
author | Gor Nishanov <GorNishanov@gmail.com> | 2017-05-23 01:13:17 +0000 |
---|---|---|
committer | Gor Nishanov <GorNishanov@gmail.com> | 2017-05-23 01:13:17 +0000 |
commit | 94d54559c8b356234d10ec7febdab4055d8256c0 (patch) | |
tree | 2931b85acf5476b32ac9f25f5e858e4ea6e619e5 /test/CodeGenCoroutines | |
parent | 3da358854c17d41667c3b64c698c721742112d2e (diff) |
[coroutines] Add support for allocation elision
Summary:
We wrap allocation code so that backend can elide it if necessary.
llvm.coro.alloc intrinsic returns true, when allocation is needed and false otherwise.
```
%NeedAlloc = call i1 @llvm.coro.alloc(token %2)
br i1 %NeedAlloc, label %AllocBB, label %InitBB
AllocBB:
%5 = call i64 @llvm.coro.size.i64()
%call = call i8* @_Znwm(i64 %5) ; operator new
br label %InitBB
InitBB:
%Phi = phi i8* [ null, %0 ], [ %call, %4 ]
call i8* @llvm.coro.begin(token %2, i8* %Phi)
```
Reviewers: majnemer, EricWF
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D31584
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303596 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCoroutines')
-rw-r--r-- | test/CodeGenCoroutines/coro-alloc.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/CodeGenCoroutines/coro-alloc.cpp b/test/CodeGenCoroutines/coro-alloc.cpp index b551257f14..14e429ebc2 100644 --- a/test/CodeGenCoroutines/coro-alloc.cpp +++ b/test/CodeGenCoroutines/coro-alloc.cpp @@ -56,8 +56,17 @@ struct std::experimental::coroutine_traits<void, global_new_delete_tag> { // CHECK-LABEL: f0( extern "C" void f0(global_new_delete_tag) { // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 + // CHECK: %[[NeedAlloc:.+]] = call i1 @llvm.coro.alloc(token %[[ID]]) + // CHECK: br i1 %[[NeedAlloc]], label %[[AllocBB:.+]], label %[[InitBB:.+]] + + // CHECK: [[AllocBB]]: // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() - // CHECK: call i8* @_Znwm(i64 %[[SIZE]]) + // CHECK: %[[MEM:.+]] = call i8* @_Znwm(i64 %[[SIZE]]) + // CHECK: br label %[[InitBB]] + + // CHECK: [[InitBB]]: + // CHECK: %[[PHI:.+]] = phi i8* [ null, %{{.+}} ], [ %call, %[[AllocBB]] ] + // CHECK: call i8* @llvm.coro.begin(token %[[ID]], i8* %[[PHI]]) // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame() // CHECK: %[[MEM:.+]] = call i8* @llvm.coro.free(token %[[ID]], i8* %[[FRAME]]) |