<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 - stack-protector-strong: Bad machine code: Using an undefined physical register"
   href="https://bugs.llvm.org/show_bug.cgi?id=41417">41417</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>stack-protector-strong: Bad machine code: Using an undefined physical register
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>dimitry@andric.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As reported in <a href="https://bugs.freebsd.org/237074">https://bugs.freebsd.org/237074</a>, the multimedia/vlc3 port fails
to build for armv6 with a fatal backend error:

[... lots of stuff ... ]
*** Bad machine code: Using an undefined physical register ***
- function:    AVI_ChunkRead
- basic block: %bb.11 if.then13 (0x804066b68)
- instruction: TCRETURNri %22:tcgpr, implicit $sp, implicit $r0, implicit
killed $r1
- operand 2:   implicit $r0

*** Bad machine code: Using an undefined physical register ***
- function:    AVI_ChunkRead
- basic block: %bb.11 if.then13 (0x804066b68)
- instruction: TCRETURNri %22:tcgpr, implicit $sp, implicit $r0, implicit
killed $r1
- operand 3:   implicit killed $r1
fatal error: error in backend: Found 2 machine code errors.

Minimized test case:

// clang -cc1 -triple armv6kz---gnueabihf -S -target-cpu arm1176jzf-s -O2
-stack-protector 2 libavi-min.c
void c(_Bool *);
void a() {
  _Bool b;
  c(&b);
}
const struct {
  int d;
  int (*e)();
} f[] = {};
int h(void);
int AVI_ChunkRead_p_chk() {
  int g = h();
  if (g)
    return f[g].e(0, 0);
  a();
  return 0;
}

Using -stack-protector 1, or lowering the optimization level to -O1 makes it
work again.

Also, if you add (int, int) to the 'e' member of the struct, like so:

const struct {
  int d;
  int (*e)(int, int);
} f[] = {};

it works.  So maybe this is related to C varargs functions.</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>