Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

error: ran out of registers during register allocation #11570

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR11395
Status NEW
Importance P enhancement
Reported by Kostya Serebryany (kcc@google.com)
Reported on 2011-11-17 11:57:42 -0800
Last modified on 2012-01-11 15:28:43 -0800
Version trunk
Hardware PC Linux
CC echristo@gmail.com, efriedma@quicinc.com, llvm-bugs@lists.llvm.org, stoklund@2pi.dk
Fixed by commit(s)
Attachments z.o.ll (23682 bytes, application/octet-stream)
y.ll (1110 bytes, application/octet-stream)
Blocks
Blocked by
See also
Reproducer:
% ./Release+Asserts/bin/llc  z.o.ll
error: ran out of registers during register allocation

Reduced from ffmpeg sources (with inline assembly) building with
AddressSanitizer for x86_32

Observed on r144798
Quuxplusone commented 12 years ago

Attachment is missing.

Quuxplusone commented 12 years ago

This is another case where "m" constraints referring to alloca objects get their own register instead of using the stack/frame pointer.

Quuxplusone commented 12 years ago

Attached z.o.ll (23682 bytes, application/octet-stream): .ll file

Quuxplusone commented 12 years ago

Attached y.ll (1110 bytes, application/octet-stream): further reduced testcase

Quuxplusone commented 12 years ago
(In reply to comment #3)
> This is another case where "m" constraints referring to alloca objects get
> their own register instead of using the stack/frame pointer.

Err, no, I'm pretty sure the issue is that there's an inline asm which requires
7 registers in a function using stack realignment (which means there are only 6
registers available).
Quuxplusone commented 12 years ago
> Err, no, I'm pretty sure the issue is that there's an inline asm which
requires
> 7 registers in a function using stack realignment (which means there are only
6
> registers available).

Interesting, bugpoint changes it from one to the other.
Quuxplusone commented 12 years ago

r144962 added a workaround for AddressSanitizer.

Quuxplusone commented 12 years ago
I had to extend the workaround (r147953).
Before that revision codegen fails even if -faddress-sanitizer does not cause
stack realignment.

% cat bug11395.c
void foo_386(int *a, const int *b,
             unsigned int f, int d,
             int h, int *c, int *e, int *g)
{
  __asm__ volatile(
      "int3"
      : "+r"(a),
      "+r"(b),
      "+r"(c),
      "+m"(h)
      : "m"( d), "m"(g),
      "m"(e) , "m"(f)
      : "eax", "edx", "esi", "ecx"
      );
}

clang  -m32  -O1 -c -faddress-sanitizer    -fno-omit-frame-pointer bug11395.c
bug11395.c:6:7: error: ran out of registers during register allocation
      "int3"
      ^
1 error generated.
Quuxplusone commented 12 years ago
(In reply to comment #8)
> clang  -m32  -O1 -c -faddress-sanitizer    -fno-omit-frame-pointer bug11395.c
> bug11395.c:6:7: error: ran out of registers during register allocation
>       "int3"
>       ^

The given example doesn't compile even without -faddress-sanitizer: it requires
7 registers, and there are only 6 registers available.
Quuxplusone commented 12 years ago

Hm. It compiles fine for me w/o -faddress-sanitizer.

Quuxplusone commented 12 years ago
But it indeed fails with -mstackrealign:

clang -m32 bug11395.c -c -mstackrealign
bug11395.c:6:7: error: ran out of registers during register allocation
Quuxplusone commented 12 years ago

That's because the realignment will need another register.