[llvm] ea6a3f9 - [NFC] [Coroutines] Fix incorrect use of coroutine intrinsics

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 3 19:14:27 PST 2022


Author: Chuanqi Xu
Date: 2022-01-04T11:13:48+08:00
New Revision: ea6a3f9f960e52ea39edd5edddf5afad3c11f7a0

URL: https://github.com/llvm/llvm-project/commit/ea6a3f9f960e52ea39edd5edddf5afad3c11f7a0
DIFF: https://github.com/llvm/llvm-project/commit/ea6a3f9f960e52ea39edd5edddf5afad3c11f7a0.diff

LOG: [NFC] [Coroutines] Fix incorrect use of coroutine intrinsics

The inlined llvm.coro.id should contain the function it refers to.
The modifed test would caused the compiler crash under O2. See
issue52912 for example.

Added: 
    

Modified: 
    llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll b/llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
index fd1d7c3b4ecd..dbd5a9fa79a1 100644
--- a/llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
+++ b/llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll
@@ -7,6 +7,8 @@
 
 declare void @g.dummy(%g.Frame*)
 
+declare i8* @g()
+
 define i8* @f() "coroutine.presplit"="1" {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
@@ -14,7 +16,7 @@ entry:
   %alloc = call i8* @malloc(i32 %size)
   %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
 
-  %innerid = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* bitcast ([3 x void (%g.Frame*)*]* @g.resumers to i8*))
+  %innerid = call token @llvm.coro.id(i32 0, i8* null, i8* bitcast (i8* ()* @g to i8*), i8* bitcast ([3 x void (%g.Frame*)*]* @g.resumers to i8*))
   %innerhdl = call noalias nonnull i8* @llvm.coro.begin(token %innerid, i8* null)
   %gframe = bitcast i8* %innerhdl to %g.Frame*
 
@@ -41,7 +43,7 @@ suspend:
 
 ; See if the g's coro.begin was spilled into the frame
 ; CHECK-LABEL: @f(
-; CHECK: %innerid = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* bitcast ([3 x void (%g.Frame*)*]* @g.resumers to i8*))
+; CHECK: %innerid = call token @llvm.coro.id(i32 0, i8* null, i8* bitcast (i8* ()* @g to i8*), i8* bitcast ([3 x void (%g.Frame*)*]* @g.resumers to i8*))
 ; CHECK: %innerhdl = call noalias nonnull i8* @llvm.coro.begin(token %innerid, i8* null)
 ; CHECK: %[[spilladdr:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 2
 ; CHECK: store i8* %innerhdl, i8** %[[spilladdr]]


        


More information about the llvm-commits mailing list