X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FHowToSubmitABug.html;h=93e0d2107f0d33a4a4997b5a5194b9bfb96b1311;hb=8d3f36f05cb97efb1cc24a5c64d6c792651cd897;hp=387e1a5523ee6f3a3c788289f452473cdb2dab95;hpb=ddaf500c26489169046eb130bf282d8f583c23ec;p=oota-llvm.git diff --git a/docs/HowToSubmitABug.html b/docs/HowToSubmitABug.html index 387e1a5523e..93e0d2107f0 100644 --- a/docs/HowToSubmitABug.html +++ b/docs/HowToSubmitABug.html @@ -1,198 +1,355 @@ - -How to submit an LLVM bug report - - - - - -
  How to submit an LLVM bug report
- - -
-

+ + + + How to submit an LLVM bug report + + + + +

+ How to submit an LLVM bug report +
+ + + + +
  • Compile-time optimization bugs +
  • Code generator bugs +
  • +
  • Miscompilations
  • +
  • Incorrect code generation (JIT and LLC)
  • + +
    +

    Written by Chris Lattner and + Misha Brukman

    +
    + + +
      -
    1. Introduction - Got bugs? +
    2. Introduction - Got bugs?
    3. Crashing Bugs -
    4. Miscompilations - -

      Written by Chris Lattner

      -

    -

    - -
    + Debugging +
    - - -
    -Introduction - Got bugs? -
      + -If you're working with LLVM and run into a bug, we definitely want to know about -it. This document describes what you can do to increase the odds of getting it -fixed quickly.

      +

      + +

      If you're working with LLVM and run into a bug, we definitely want to know +about it. This document describes what you can do to increase the odds of +getting it fixed quickly.

      -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 +

      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 (i.e., the +compiler successfully produces an executable, but it doesn't run right). 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.

      +more easily.

      -Once you have a reduced test-case, email information about the bug to: llvmbugs@cs.uiuc.edu. This should -include all of the information necessary to reproduce the problem, including -where you got the LLVM tree from (if you're not working out of CVS).

      +

      Once you have a reduced test-case, go to the LLVM Bug Tracking +System and fill out the form with the necessary details (note that you don't +need to pick a catagory, just use the "new-bugs" catagory if you're not sure). +The bug description should contain the following +information:

      -Thanks for helping us make LLVM better!

      +

        +
      • All information necessary to reproduce the problem.
      • +
      • The reduced test-case that triggers the bug.
      • +
      • The location where you obtained LLVM (if not from our Subversion + repository).
      • +
      + +

      Thanks for helping us make LLVM better!

      +
      -
    -
    -Crashing Bugs -
      + -More often than not, bugs in the compiler cause it to crash - often due to an -assertion failure of some sort. If you are running opt or -analyze directly, and something crashes, jump to the section on -bugs in LLVM passes. Otherwise, the most important -piece of the puzzle is to figure out if it is the GCC-based front-end that is -buggy or if it's one of the LLVM tools that has problems.

      +

      + +

      More often than not, bugs in the compiler cause it to crash—often due +to an assertion failure of some sort. The most important +piece of the puzzle is to figure out if it is crashing in the GCC front-end +or if it is one of the LLVM libraries (e.g. the optimizer or code generator) +that has problems.

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

      +

      To figure out which component is crashing (the front-end, +optimizer or code generator), run the +llvm-gcc command line as you were when the crash occurred, but +with the following extra command line options:

      +

    • -O0 -emit-llvm: If llvm-gcc still crashes when + passed these options (which disable the optimizer and code generator), then + the crash is in the front-end. Jump ahead to the section on front-end bugs.
    • +
    • -emit-llvm: If llvm-gcc crashes with this option + (which disables the code generator), you found an optimizer bug. Jump ahead + to compile-time optimization bugs.
    • - -
    -
       - -Front-end bugs -
    -If the problem is in the front-end, pretty much the only thing you can do is -preprocess the input (compile with the -E option) and send us the -results. There is no good way to reduce source-level test-cases that I know -of... if you do know, send me information and we can extend this section. :)

    + + +

    + +
    + +

    If the problem is in the front-end, you should re-run the same +llvm-gcc command that resulted in the crash, but add the +-save-temps option. The compiler will crash again, but it will leave +behind a foo.i file (containing preprocessed C source code) and +possibly foo.s for each +compiled foo.c file. Send us the foo.i file, +along with the options you passed to llvm-gcc, and a brief description of the +error it caused.

    + +

    The delta tool helps to reduce the +preprocessed file down to the smallest amount of code that still replicates the +problem. You're encouraged to use delta to reduce the code to make the +developers' lives easier. This website +has instructions on the best way to use delta.

    + +
    - -
       - -GCCAS bugs -
      + -If you find that a bug crashes in the gccas stage of -compilation, compile your test-case to a .s file with the -S -option to llvm-gcc. Then run:

      +

      -
      -  gccas -debug-pass=Arguments < /dev/null -o - > /dev/null
      -

      +

      If you find that a bug crashes in the optimizer, compile your test-case to a +.bc file by passing "-emit-llvm -O0 -c -o foo.bc". +Then run:

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

      +

      +

      opt -std-compile-opts -debug-pass=Arguments foo.bc + -disable-output

      +
      +

      This command should do two things: it should print out a list of passes, and +then it should crash in the same was as llvm-gcc. If it doesn't crash, please +follow the instructions for a front-end bug.

      - -
    -
       - -GCCLD bugs -
      +

      If this does crash, then you should be able to debug this with the following +bugpoint command:

      -If you find that a bug crashes in the gccld stage of -compilation, gather all of the .o bytecode files and libraries that are -being linked together (the "llvm-gcc -v" output should include -the full list of objects linked). Then run:

      +

      +

      bugpoint foo.bc <list of passes printed by +opt>

      +
      -
      -  as < /dev/null > null.bc
      -  gccld -debug-pass=Arguments null.bc
      -

      +

      Please run this, then file a bug with the instructions and reduced .bc files +that bugpoint emits. If something goes wrong with bugpoint, please submit the +"foo.bc" file and the list of passes printed by opt.

      -... 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 -
      + -At this point, you should have some number of LLVM assembly files or bytecode -files and a list of passes which crash when run on the specified input. In -order to reduce the list of passes (which is probably large) and the input to -something tractable, use the bugpoint tool as follows:

      +

      -
      -  bugpoint <input files> <list of passes>
      -

      +

      If you find a bug that crashes llvm-gcc in the code generator, compile your +source file to a .bc file by passing "-emit-llvm -c -o foo.bc" +to llvm-gcc (in addition to the options you already pass). Once your have +foo.bc, one of the following commands should fail:

      -bugpoint will print a bunch of output as it reduces the -test-case, but it should eventually print something like this:

      +

        +
      1. llc foo.bc -f
      2. +
      3. llc foo.bc -f -relocation-model=pic
      4. +
      5. llc foo.bc -f -relocation-model=static
      6. +
      7. llc foo.bc -f -enable-eh
      8. +
      9. llc foo.bc -f -relocation-model=pic -enable-eh
      10. +
      11. llc foo.bc -f -relocation-model=static -enable-eh
      12. +
      + +

      If none of these crash, please follow the instructions for a +front-end bug. If one of these do crash, you should +be able to reduce this with one of the following bugpoint command lines (use +the one corresponding to the command above that failed):

      -
      -  ...
      -  Emitted bytecode to 'bugpoint-reduced-simplified.bc'
      +
        +
      1. bugpoint -run-llc foo.bc
      2. +
      3. bugpoint -run-llc foo.bc --tool-args + -relocation-model=pic
      4. +
      5. bugpoint -run-llc foo.bc --tool-args + -relocation-model=static
      6. +
      7. bugpoint -run-llc foo.bc --tool-args -enable-eh
      8. +
      9. bugpoint -run-llc foo.bc --tool-args + -relocation-model=pic -enable-eh
      10. +
      11. bugpoint -run-llc foo.bc --tool-args + -relocation-model=static -enable-eh
      12. +
      + +

      Please run this, then file a bug with the instructions and reduced .bc file +that bugpoint emits. If something goes wrong with bugpoint, please submit the +"foo.bc" file and the option that llc crashes with.

      + +
      + + + + - *** 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.

      +

      If llvm-gcc successfully produces an executable, but that executable doesn't +run right, this is either a bug in the code or a bug in the +compiler. The first thing to check is to make sure it is not using undefined +behavior (e.g. reading a variable before it is defined). In particular, check +to see if the program valgrinds clean, +passes purify, or some other memory checker tool. Many of the "LLVM bugs" that +we have chased down ended up being bugs in the program being compiled, not + LLVM.

      +

      Once you determine that the program itself is not buggy, you should choose +which code generator you wish to compile the program with (e.g. C backend, the +JIT, or LLC) and optionally a series of LLVM passes to run. For example:

      - -
    -
    -Miscompilations -
      - +
      +

      +bugpoint -run-cbe [... optzn passes ...] file-to-test.bc --args -- [program arguments]

      +
      -Fortunately we haven't had to many miscompilations. Because of this, this -section is a TODO. Basically, use bugpoint to track down the problem.

      +

      bugpoint will try to narrow down your list of passes to the one pass +that causes an error, and simplify the bitcode file as much as it can to assist +you. It will print a message letting you know how to reproduce the resulting +error.

      + -
    + -
    -
    Chris Lattner
    - - -Last modified: Fri May 23 09:48:53 CDT 2003 - -
    +
    + +

    Similarly to debugging incorrect compilation by mis-behaving passes, you can +debug incorrect code generation by either LLC or the JIT, using +bugpoint. The process bugpoint follows in this case is to try +to narrow the code down to a function that is miscompiled by one or the other +method, but since for correctness, the entire program must be run, +bugpoint will compile the code it deems to not be affected with the C +Backend, and then link in the shared object it generates.

    + +

    To debug the JIT:

    + +
    +
    +bugpoint -run-jit -output=[correct output file] [bitcode file]  \
    +         --tool-args -- [arguments to pass to lli]               \
    +         --args -- [program arguments]
    +
    +
    + +

    Similarly, to debug the LLC, one would run:

    + +
    +
    +bugpoint -run-llc -output=[correct output file] [bitcode file]  \
    +         --tool-args -- [arguments to pass to llc]               \
    +         --args -- [program arguments]
    +
    +
    + +

    Special note: if you are debugging MultiSource or SPEC tests that +already exist in the llvm/test hierarchy, there is an easier way to +debug the JIT, LLC, and CBE, using the pre-written Makefile targets, which +will pass the program options specified in the Makefiles:

    + +
    +

    +cd llvm/test/../../program
    +make bugpoint-jit +

    +
    + +

    At the end of a successful bugpoint run, you will be presented +with two bitcode 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:

    + +
      + +
    1. Regenerate the shared object from the safe bitcode file:

      + +
      +

      +llc -march=c safe.bc -o safe.c
      +gcc -shared safe.c -o safe.so +

      +
    2. + +
    3. If debugging LLC, compile test bitcode native and link with the shared + object:

      + +
      +

      +llc test.bc -o test.s -f
      +gcc test.s safe.so -o test.llc
      +./test.llc [program options] +

      +
    4. + +
    5. If debugging the JIT, load the shared object and supply the test + bitcode:

      + +
      +

      lli -load=safe.so test.bc [program options]

      +
    6. + +
    + +
    + + +
    +
    + Valid CSS! + Valid HTML 4.01! + + Chris Lattner
    + The LLVM Compiler Infrastructure +
    + Last modified: $Date$ +
    + + +