<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 - [Statepoint] Statepoint lowering crashes with -O0 but not -On (n>=1)"
   href="https://bugs.llvm.org/show_bug.cgi?id=40545">40545</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Statepoint] Statepoint lowering crashes with -O0 but not -On (n>=1)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>jh@jakehughes.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When given this simple IR:




define i64 addrspace(1)* @bar(i64 addrspace(1)* %x1) gc "statepoint-example" {
entry:
  ret i64 addrspace(1)* %x1
}

define i64 addrspace(1)* @foo(i64 addrspace(1)* %y1) gc "statepoint-example" {
entry:
  %0 = call i64 addrspace(1)* @bar(i64 addrspace(1)* %y1)
  ret i64 addrspace(1)* %0
}




I generate statepoint relocation sequences in IR using the command: 

opt -rewrite-statepoints-for-gc -S -o out.ll in.ll 

This creates the following IR with statepoint intrinsics: 



define i64 addrspace(1)* @bar(i64 addrspace(1)* %x1) gc "statepoint-example" {
entry:
  ret i64 addrspace(1)* %x1
}

define i64 addrspace(1)* @foo(i64 addrspace(1)* %y1) gc "statepoint-example" {
entry:
  %statepoint_token = call token (i64, i32, i64 addrspace(1)* (i64
addrspace(1)*)*, i32, i32, ...)
@llvm.experimental.gc.statepoint.p0f_p1i64p1i64f(i64 2882400000, i32 0, i64
addrspace(1)* (i64 addrspace(1)*)* @bar, i32 1, i32 0, i64 addrspace(1)* %y1,
i32 0, i32 0, i64 addrspace(1)* %y1)
  %0 = call i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(token
%statepoint_token)
  %y1.relocated = call coldcc i8 addrspace(1)*
@llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 8, i32 8) ;
(%y1, %y1)
  %y1.relocated.casted = bitcast i8 addrspace(1)* %y1.relocated to i64
addrspace(1)*
  ret i64 addrspace(1)* %0
}

declare void @__tmp_use(...)

declare token @llvm.experimental.gc.statepoint.p0f_p1i64p1i64f(i64, i32, i64
addrspace(1)* (i64 addrspace(1)*)*, i32, i32, ...)

; Function Attrs: nounwind readonly
declare i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(token) #0

; Function Attrs: nounwind readonly
declare i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token, i32, i32)
#0

attributes #0 = { nounwind readonly }



When I try to compile this with llc -O0, this crashes with the error: 

LLVM ERROR: Cannot select: 0x558477a567e0: i64 = any_extend 0x558477a56778
In function: foo


Compilation is successful, however, if I use the default optimisation level,
-O2. I have also tested this with -O1 and -O3, both of which successfully
compile.</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>