Testcase for OS kernel

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.

  1. 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?

Thanks,

Keun Soo

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.

This has been fixed in 2.5.
http://llvm.org/bugs/show_bug.cgi?id=3045
http://llvm.org/bugs/show_bug.cgi?id=1779

Andrew