Keun Soo Yim wrote:> Hi,
>
> The source attached at the bottom is a testcase which causes a back-end
error in LLVM 2.4.
> These types of assembly routines are mainly used in OS kernels.
> I checked that GCC 4.3 works for this routine.
>
> The error messsage is ...
> Couldn't allocate output reg for constraint 'A'!
>
> I just need help or comments so that I could analyze and fix this bug.
> My question is how can we efficiently debug this type of bug?
>
> 1. Typically we have a large size of testcase source code.
> Thus we need to locate the specific location of bug in the testcase source
code.
> Is there any debugging message that LLVM gives to make it easy to identify
this information?
> I don’t except that information in source code because that is belong to
GCC front-end
> but what about in terms of LLVM asm code, e.g., line # of LLVM asm code
that generate this error.
>
Have you used LLVM's bugpoint tool before? It won't tell you the line
number of the LLVM assembly that's causing the problem, but it can
automatically reduce large test cases to small test cases. It looks
like the test case you've attached below is pretty small, but if you had
a larger testcase, bugpoint can reduce it for you.> 2. Then we need to find a code in LLVM that generates this error message.
> But how can I efficiently find that buggy routine in LLVM pass or backend?
>
If it's an assertion, you can run the gdb command on the whatever LLVM
tool you're having problems with. If you run it on the debug version of
the tool, the asserts will break into the debugger, and you can get a
stack trace with source filename and line numbers.
If it's not an assertion, I'd just search through the code for the error
message. I would use a combination of find/grep to do that:
cd llvm
find . -type f -print | xargs grep -l "Couldn't allocate output
reg"
-- John T.
> Thanks,
> Keun Soo
>
> -----
>
> /*
> * @title A Testcase for LLVM
> *
> * @about This faces an error with LLVM 2.4 (but not with GCCC)
> * The error messsage is ...
> * Couldn't allocate output reg for constraint
'A'!
> *
> * @author Keun Soo Yim
> */
>
> struct a_struct{
> unsigned int a,b;
> };
>
> void x()
> {
> long err;
> struct a_struct a;
> struct a_struct *pa;
>
> __asm__ __volatile__(
> "1: movl 0(%2),%%eax\n"
> "2: movl 4(%2),%%edx\n"
> "3:\n" ".section .fixup,\"ax\"\n"
> "4: movl %3,%0\n"
> " xorl %%eax,%%eax\n"
> " xorl %%edx,%%edx\n"
> " jmp 3b\n" ".previous\n"
> ".section __ex_table,\"a\"\n"
> " .align 4\n"
> " .long 1b,4b\n"
> " .long 2b,4b\n"
> ".previous" : "=r" (err),
> "=&A" (((a)))
> : "r" (((pa))),
> "i"(-14),
> "0"(err));
> }
>
>
>