Skip to content

[mips] After a26f1bf67ec, Bad machine code: Using an undefined physical register #51033

@DimitryAndric

Description

@DimitryAndric
Bugzilla Link 51691
Resolution FIXED
Resolved on Oct 22, 2021 00:34
Version trunk
OS All
Blocks #50580 #51489
CC @emaste,@jrtc27,@LebedevRI,@arsenm,@nickdesaulniers,@atanasyan,@tstellar
Fixed by commit(s) f5755c0 47f53ee

Extended Description

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 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);)
;
}
}

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzilla

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions