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

            Bug ID: 41417
           Summary: stack-protector-strong: Bad machine code: Using an
                    undefined physical register
           Product: new-bugs
           Version: trunk
          Hardware: Other
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: dimi...@andric.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

As reported in https://bugs.freebsd.org/237074, 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.

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

Reply via email to