[llvm-commits] Specification for Run-time Checks
John Criswell
criswell at illinois.edu
Tue May 15 21:48:49 PDT 2012
On 5/14/12 10:37 AM, Nuno Lopes wrote:
> Hi John et al.,
>
> I read your proposal and all emails in the discussion.
To make things a little more concrete, I've thrown together an initial
implementation of the simple bounds checks you described in your first
email. I implemented them using the SAFECode infrastructure (which is
the basis of the proposal I wrote).
If anyone's up for trying it out, you can download it from
http://sva.cs.illinois.edu/fastsc-llvm.tar.gz.
To compile it, just run the top-level configure in the llvm directory
and type make. The generated clang executable will be in
llvm/projects/safecode/<build_type>/bin/clang.
To turn on the lightweight safety checks, use the -fmemsafety option.
The code uses just 4 LLVM passes:
1) One pass to insert checks:
http://llvm.org/viewvc/llvm-project/safecode/trunk/lib/InsertPoolChecks/LoadStoreChecks.cpp?view=log
2) One pass to optimize checks into fastlscheck when the bounds can be
determined through local data-flow analysis:
http://llvm.org/viewvc/llvm-project/safecode/trunk/lib/OptimizeChecks/OptimizeChecks.cpp?view=log
3) One pass to remove the checks that you consider too slow:
http://llvm.org/viewvc/llvm-project/safecode/trunk/lib/OptimizeChecks/RemoveSlowChecks.cpp?view=log
4) One pass to inline the implementation of fastlscheck:
http://llvm.org/viewvc/llvm-project/safecode/trunk/lib/OptimizeChecks/InlineFastChecks.cpp?view=log
The first two passes have been in SAFECode for a long time. The other
two I wrote in the late afternoon and evening. I think it took me about
2 to 2.5 hours.
Obviously, I haven't put this code through much testing, but it seems to
work on a trivial test case and doesn't break small programs.
I have other things that I need to work on, but I'll probably come back
to it, do some more testing on it, and see if it's a feature that people
want SAFECode to have.
Feedback is appreciated.
-- John T.
More information about the llvm-commits
mailing list