<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - updateCGAndAnalysisManagerForPass cannot handle cycles introduced by CoroSplit"
href="https://bugs.llvm.org/show_bug.cgi?id=48190">48190</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>updateCGAndAnalysisManagerForPass cannot handle cycles introduced by CoroSplit
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lxfind@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Assuming we have a coroutine function named @foo(), which is a recursive
function (i.e. it calls @foo()). Initially @foo() will be an SCC by itself.
After CoroSplit, we will have the following functions:
- @foo()
- @foo.resume()
- @foo.destroy()
- @foo.cleanup()
Their call relationships will look like this:
- @foo() calls @foo.resume(), and refers @foo.destroy and @foo.cleanup().
- @foo.resume() calls @foo().
As you can see this will lead to the new list of SCCs looking like this:
- (@foo, @foo.resume)
- (@foo.destroy)
- (@foo.cleanup)
CoroSplit will call updateCGAndAnalysisManagerForPass, which will eventually
add @foo to the list of DemotedCallTargets, and then incorporateNewSCCRange is
called, with "NewSCCRange" equals to ((@foo.destroy), (@foo.cleanup)), but the
SCC that maps to @foo is (@foo, @foo.resume). This will trigger assertion
failure at
<a href="https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/CGSCCPassManager.cpp#L409">https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/CGSCCPassManager.cpp#L409</a>.
The following test case can be used to reproduce this issue:
; RUN: opt < %s --enable-new-pm --enable-coroutines -O3 -S
; Function Attrs: argmemonly nounwind readonly
declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #0
; Function Attrs: nounwind
declare i8* @llvm.coro.begin(token, i8* writeonly) #1
; Function Attrs: nounwind
declare token @llvm.coro.save(i8*) #1
; Function Attrs: nounwind
declare i8 @llvm.coro.suspend(token, i1) #1
define dso_local void @foo() align 2 personality i8* undef {
entry:
%__promise = alloca i32, align 8
%0 = bitcast i32* %__promise to i8*
%1 = call token @llvm.coro.id(i32 16, i8* %0, i8* null, i8* null)
%2 = call i8* @llvm.coro.begin(token %1, i8* null)
br i1 undef, label %if.then154, label %init.suspend
init.suspend: ; preds = %entry
%save = call token @llvm.coro.save(i8* null)
%3 = call i8 @llvm.coro.suspend(token %save, i1 false)
%cond = icmp eq i8 %3, 0
br i1 %cond, label %if.then154, label %invoke.cont163
if.then154: ; preds = %init.suspend,
%entry
call void @foo()
br label %invoke.cont163
invoke.cont163: ; preds = %if.then154,
%init.suspend
ret void
}
attributes #0 = { argmemonly nounwind readonly }
attributes #1 = { nounwind }</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>