<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 - CTR not correctly saved for inline assembly clobbering CTR"
   href="https://bugs.llvm.org/show_bug.cgi?id=47812">47812</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CTR not correctly saved for inline assembly clobbering CTR
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.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>Backend: PowerPC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>programmerjake@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following IR is miscompiled:
<a href="https://gcc.godbolt.org/z/s5zcae">https://gcc.godbolt.org/z/s5zcae</a>

target triple = "powerpc64le-unknown-linux-gnu"

define void @f(void()* %fn) {
  call void asm sideeffect "mtctr 31", "~{ctr}"()
  tail call void %fn()
  ret void
}

Generated Assembly (trimmed to just f's instructions, comments added):
f:
.Lfunc_gep0:
        addis 2, 12, .TOC.-.Lfunc_gep0@ha
        addi 2, 2, .TOC.-.Lfunc_gep0@l
        mflr 0
        std 0, 16(1)
        stdu 1, -32(1)
        std 2, 24(1)
        mtctr 3
        mr      12, 3
        mtctr   31 # note how ctr not restored before the call on next line
        bctrl
        ld 2, 24(1)
        addi 1, 1, 32
        ld 0, 16(1)
        mtlr 0
        blr

This causes f to call whatever address was in r31 instead of %fn despite the
inline assembly including ctr in the clobber list.</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>