|How to submit an LLVM bug report|
|Introduction - Got bugs?|
Basically you have to do two things at a minimum. First, decide whether the bug crashes the compiler (or an LLVM pass), or if the compiler is miscompiling the program. Based on what type of bug it is, follow the instructions in the linked section to narrow down the bug so that the person who fixes it will be able to find the problem more easily.
Once you have a reduced test-case, go to the LLVM Bug Tracking System, select the catagory in which the bug falls, and fill out the form with the necessary details. The bug description should contain the following information:
Thanks for helping us make LLVM better!
To figure out which program is crashing (the front-end, gccas, or gccld), run the llvm-gcc command line as you were when the crash occurred, but add a -v option to the command line. The compiler will print out a bunch of stuff, and should end with telling you that one of cc1, gccas, or gccld crashed.
gccas -debug-pass=Arguments < /dev/null -o - > /dev/null
... which will print a list of arguments, indicating the list of passes that gccas runs. Once you have the input file and the list of passes, go to the section on debugging bugs in LLVM passes.
llvm-as < /dev/null > null.bc gccld -debug-pass=Arguments null.bc
... which will print a list of arguments, indicating the list of passes that gccld runs. Once you have the input files and the list of passes, go to the section on debugging bugs in LLVM passes.
|Bugs in LLVM passes|
bugpoint <input files> <list of passes>
bugpoint will print a bunch of output as it reduces the test-case, but it should eventually print something like this:
... Emitted bytecode to 'bugpoint-reduced-simplified.bc' *** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -licm
Once you complete this, please send the LLVM bytecode file and the command line to reproduce the problem to the llvmbugs mailing list.
To debug a miscompilation, you should choose which program you wish to run the output through, e.g. C backend, the JIT, or LLC, and a selection of passes, one of which may be causing the error, and run, for example:
bugpoint -run-cbe [... optimization passes ...] file-to-test.bcbugpoint will try to narrow down your list of passes to the one pass that causes an error, and simplify the bytecode file as much as it can to assist you. It will print a message letting you know how to reproduce the resulting error.
|Incorrect code generation|
To debug the JIT:
bugpoint -run-jit -output=[correct output file] [bytecodefile]Similarly, to debug the LLC, one would run:
bugpoint -run-llc -output=[correct output file] [bytecodefile]At the end of a successful bugpoint run, you will be presented with two bytecode files: a safe file which can be compiled with the C backend and the test file which either LLC or the JIT mis-codegenerates, and thus causes the error.
To reproduce the error that bugpoint found, it is sufficient to do the following:
llvm-dis -c safe.bc -o safe.c
gcc -shared safe.c -o safe.so
llc test.bc -o test.s -f
gcc test.s safe.so -o test.llc
./test.llc [program options]
If debugging the JIT, load the shared object and supply the test bytecode:
lli -load=safe.so test.bc [program options]