[PATCH] D87798: [NewPM][CGSCC] Handle newly added functions in updateCGAndAnalysisManagerForPass

Xun Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 14 08:59:12 PST 2020


lxfind added a comment.

@aeubanks, I was wondering if you are familiar with this but it seems that the SCC update after CoroSplit couldn't handle the case when there is recursion in the original coroutine, that is, the newly generated functions by CoroSplit will contain cycles (foo calling foo.resume which then calls foo). Do you have suggestions/thoughts on how to fix it?
For example, test like this will fail assertions:

  ; 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 }



================
Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1491
   // allows CGSCC passes to insert "trivial" reference edges. We've ensured
   // above, by inserting the funclets into the same SCC as the corutine, that
   // the edges are trivial.
----------------
Seems like the comments wasn't updated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87798/new/

https://reviews.llvm.org/D87798



More information about the llvm-commits mailing list