[llvm-bugs] [Bug 51691] New: [mips] After a26f1bf67ec, Bad machine code: Using an undefined physical register

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 31 13:34:25 PDT 2021


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

            Bug ID: 51691
           Summary: [mips] After a26f1bf67ec, Bad machine code: Using an
                    undefined physical register
           Product: new-bugs
           Version: trunk
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dimitry at andric.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

This backend error appeared when compiling the FreeBSD base system for mips or
mips64 with clang 13:

*** Bad machine code: Using an undefined physical register ***
- function:    checkfstab
- basic block: %bb.27 if.end51 (0x80768a568)
- instruction: %161:gpr32 = COPY $v1
- operand 1:   $v1
fatal error: error in backend: Found 1 machine code errors.

Bisection shows this error starts occurring after
https://github.com/llvm/llvm-project/commit/a26f1bf67ec ("[PassManager] Run
additional LICM before LoopRotate "), so I am suspecting that this exposes a
latent bug somewhere in the Mips backend? (As these test cases seem to work
fine on other architectures.)

Minimized test case for 32-bit mips:

// clang -cc1 -triple mips-- -S -mrelocation-model static -target-cpu mips2 -O2
preen-min.c
typedef struct {
  int a[0];
} b;
b c;
extern _Thread_local b *d;
int e, f, ay;
struct {
  int g;
  int h;
} * k;
char *ax;
b *l() {
  if (d)
    return d;
  return &c;
}
int m() {
  int i = 0, j = i;
  f = l()->a[j];
  return e;
}
char *n();
void o();
void q() {
  if (k)
    o(&k->h, k);
}
void o(char *r, int *s, int *t) {
  char aw = *s;
  char *p = n();
  if (p)
    p = &aw;
  for (; *p && m(); p++)
    for (; 0; ay = *t)
      ;
  ax = r;
}

Minimized test case for 64-bit mips (looking very similar, though derived from
a very different source file):

// clang -cc1 -triple mips64-- -S -target-cpu mips3 -O2
-ftls-model=initial-exec tw-min.c
typedef struct {
  int a[0];
} b;
b *c;
extern _Thread_local b *d;
int e, f;
b *g() {
  if (d)
    return d;
  return c;
}
int h(j) {
  int i = j;
  e = g()->a[i];
  return 1;
}
void k() {
  int *a;
  for (a = 0; f;)
    if (0 ?: h) {
      int b;
      a++;
      if (*a) {
        b = 0;
        a++;
      }
      for (; h(*a);)
        ;
    }
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210831/b1e2466d/attachment.html>


More information about the llvm-bugs mailing list