Request for Review: SAFECode Patch

Dear All,

I've developed a patch for mainline LLVM that integrates parts of the SAFECode memory safety compiler (http://sva.cs.illinois.edu) into LLVM. The patch includes transforms that add run-time safety checks to loads and stores and GetElementPtr instructions, a run-time library that implements the checks, a transform that enhances the run-time checks with source file debugging information (essentially making the compiler a valgrind-like tool), and one of the simpler but more critical run-time check optimization passes.

Working under the assumption that people are interested in memory safety transforms being in LLVM, we'd like to integrate this code into LLVM and would like to know if someone is willing to review the patch and provide feedback. I have commit access already, so I can commit the code myself provided that it passes review.

The patch is available as a tar archive at http://llvm.cs.uiuc.edu/~criswell/sc.tar.gz and can be extracted into the top-level LLVM source tree (*). I have also created two new test Makefiles for the test-suite that run the transforms on programs in the LLVM test suite; those can be found (as a regular patch to test-suite) at http://llvm.cs.uiuc.edu/~criswell/patch.

BTW, there are more optimizations and other code from SAFECode that we'd like to integrate (including some memory safety check optimizations, the simple static array bounds checking passes, and the control-flow integrity pass), but I wanted to start with a small initial patch and work from there.

-- John T.

(*) I apologize for not creating a normal "diff" patch; I used svn copy to preserve the revision history when moving files from the SAFECode source tree to my LLVM working directory; a side effect of this is that the result of "svn diff" merely shows what changed relative to the original source files in the SAFECode source tree and not the differences relative to the LLVM source tree.

Dear All,

Just an FYI that I've updated this patch with a few fixes that I made after running the transform passes within Clang (the fixes mainly deal with the fact that using getGlobalContext() isn't the right thing to do; I didn't notice it before since it works in opt). The files to add to the LLVM source tree can be found in the following tarball:

http://llvm.cs.uiuc.edu/~criswell/sc.tar.gz

I've also added a patch that allows the memory safety passes to be loaded into opt and bugpoint (I think I omitted this in the last patch):

http://llvm.cs.uiuc.edu/~criswell/llvmpatch

I have also added a preliminary patch that I'll submit to Clang when the above code is approved that adds a -memsafety option that runs the instrumentation passes; hopefully this will make testing easier if reviewers want to do that:

http://llvm.cs.uiuc.edu/~criswell/clangpatch

-- John T.