[llvm-bugs] [Bug 48190] New: updateCGAndAnalysisManagerForPass cannot handle cycles introduced by CoroSplit

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 16 10:56:47 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48190

            Bug ID: 48190
           Summary: updateCGAndAnalysisManagerForPass cannot handle cycles
                    introduced by CoroSplit
           Product: new-bugs
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: lxfind at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

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
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/CGSCCPassManager.cpp#L409.


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 }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201116/57dd76b5/attachment-0001.html>


More information about the llvm-bugs mailing list