[LLVMdev] Random C Program Generator

Bryan Turner bryan.turner at pobox.com
Sat Jul 2 19:13:25 PDT 2005


Hello,

    I've written a random program generator and have successfuly used it to
locate LLVM and GCC bugs.  I'm releasing it to public domain for others to
use or improve as needed.

    It creates a program by generating a call graph and using reverse data
flow to populate local variables, function parameters, and globals.  The
programs it generates are all error-free (except for a few corner cases
involving modulus and shift operators), and of arbitrary complexity.

    The generated programs output a hash value after sucessful termination
which is uniquely derrived from the exection of the program.  This value may
be used to check for errors in the optimizer by comparing it to the output
from the debug version.

    Because the call graph is available immediately before the output of the
final program text, it may be possible to integrate this tool with the LLVM
back-end for automatic test-case reduction to locate the offending source
text.  Also, as this tool uses general programming concepts, it would be
fairly easy to generate other C-like languages on the back-end (Pascal, Ada,
C#, Java, etc).

You can get the code from here:
http://www.fractalscape.org/RandomProgramGenerator

--Bryan
bryan.turner at pobox.com




More information about the llvm-dev mailing list