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

            Bug ID: 36102
           Summary: RewriteStatepointsForGC probably shouldn't turn
                    musttail calls into statepoints
           Product: libraries
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: ben...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 19753
  --> https://bugs.llvm.org/attachment.cgi?id=19753&action=edit
A minimal example of input that the pass mangles

Applying the RewriteStatepointsForGC pass to a function definition that
contains a `musttail` call turns that call into a statepoint, which produces a
malformed module (since the parameter counts mismatch). The attached file is a
valid module, but running `opt -rewrite-statepoints-for-gc -S
tail_statepoint.ll` produces the following error message:

    cannot guarantee tail call due to mismatched parameter counts
      %statepoint_token = musttail call token (i64, i32, i32 (i32
addrspace(1)*)*, i32, i32, ...)
@llvm.experimental.gc.statepoint.p0f_i32p1i32f(i64 2882400000, i32 0, i32 (i32
addrspace(1)*)* @foo, i32 1, i32 0, i32 addrspace(1)* %x, i32 0, i32 0, i32
addrspace(1)* %x)
    LLVM ERROR: Broken function found, compilation aborted!

As far as I can tell, the decision on whether to rewrite a given callsite is
made here:
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp#L2522

It seems to me that just adding a clause to verify that the call is not
`musttail` would be an improvement, but I'm not at all familiar with what other
repercussions it could possibly have.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to