Open Quuxplusone opened 15 years ago
Attached mpegvideo_mmx.i
(263300 bytes, application/octet-stream): Preprocessed source showing the problem
Problem occurs only with a combination of -O and -fomit-frame-pointer.
Easiest way to reproduce:
llvm-gcc -O -fomit-frame-pointer -c mpegvideo_mmx.i
I believe that this works on mainline, the fix didn't make it into 2.6.
(In reply to comment #3)
> I believe that this works on mainline, the fix didn't make it into 2.6.
No, fails for me on tot. Reducing.
Attached bugpoint-reduced-simplified.bc
(5240 bytes, application/octet-stream): Bugpoint reduction
EDX is live across the big asm, so the only way to get enough registers is spill EDX. Apparently it doesn't know how to do that. The def and use of EDX are made into a "fixed interval" which, I think, isn't considered for spilling. Maybe we shouldn't do that when there's an asm in the range?
Compiles with the simple RA but the code isn't right, EAX tries to hold multiple values in a couple of places. Appears to produce correct code with local RA.
I haven't looked carefully, but I think this is a dup of bug 4668.
Here's another testcase if anyone is interested...
regehr@john-home:~/volatile/tmp216$ clang -v
clang version 1.1 (trunk 85644)
Target: i386-pc-linux-gnu
Thread model: posix
regehr@john-home:~/volatile/tmp216$ clang -c -w -Os small.c
fatal error: error in backend: Ran out of registers during register allocation!
regehr@john-home:~/volatile/tmp216$ cat small.c
static unsigned char
foo (char _left, unsigned int _right)
{
return _left || _right >= 1 * 8 ? _left : _left >> _right;
}
static unsigned short
bar (unsigned short _ui1, unsigned char _ui2)
{
return 0 ? : (_ui1 % _ui2);
}
unsigned char g_147;
uint648 (short p_9, int int32p11, unsigned char p_12, int uint32p_13)
{
unsigned char l_131;
unsigned char *l = &l_131;
for (l;; 1)
{
unsigned char l_153;
if (func_46 (0) |
bar (foo
(g_147,
+p_12) ^
foo (func_39
(0),
p_9 != 0) >
(safe (0), 0), ~l_153))
assert (&l_131);
}
}
_Bug 5362 has been marked as a duplicate of this bug._
Another one I got by building ffmpeg as llvm bytecode (-O4) and then building
native code from the bytecode [1]
Note that building native code with clang (-O3) doesn't produce any error for
me (svn version of yesterday).
[1]
Generating Bitcode To ffmpeg_g.bc
Generating Assembly With:
'/data/build/userspace/llvm/llvm/Release/bin/llc' '-x86-asm-syntax=att' '-f' '-
o' 'ffmpeg_g.s' 'ffmpeg_g.bc'
LLVM ERROR: Ran out of registers during register allocation!
Please check your inline asm statement for invalid constraints:
INLINEASM <es:movd %eax, %mm3
pshufw $$0, %mm3, %mm3
pxor %mm7, %mm7
pxor %mm4, %mm4
movq ($2), %mm5
pxor %mm6, %mm6
psubw ($3), %mm6
mov $$-128, %eax
.align 1 << 4
1:
movq ($1, %eax), %mm0
pxor %mm1, %mm1
pcmpgtw %mm0, %mm1
pxor %mm1, %mm0
psubw %mm1, %mm0
psubusw %mm6, %mm0
pmulhw %mm5, %mm0
por %mm0, %mm4
pxor %mm1, %mm0
psubw %mm1, %mm0
movq %mm0, ($5, %eax)
pcmpeqw %mm7, %mm0
movq ($4, %eax), %mm1
movq %mm7, ($1, %eax)
pandn %mm1, %mm0
pmaxsw %mm0, %mm3
add $$8, %eax
js 1b
pshufw $$0x0E, %mm3, %mm0
pmaxsw %mm0, %mm3
pshufw $$0x01, %mm3, %mm0
pmaxsw %mm0, %mm3
movd %mm3, %eax
movzb %al, %eax
>, 10, %EAX<def>, 9, %reg1326<kill>, 9, %reg1332, 9, %reg1323<kill>, 9, %reg1320<kill>, 9, %reg1321<kill>, 2147483657, %EAX, 14, %EFLAGS<earlyclobber,def,dead>; dbg:mpegvideo_mmx_template.c:152:9
mpegvideo_mmx.i
(263300 bytes, application/octet-stream)bugpoint-reduced-simplified.bc
(5240 bytes, application/octet-stream)