<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 12/7/10 10:16 AM, Vincent De Bruyne wrote:
<blockquote cite="mid:BAY128-W2903A7BC09859C2E078329B42C0@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
Hi,<br>
<br>
I'm a student who is going to make a countermeasure for dangling
pointers in c for his thesis.<br>
I need to make my source transformation using llvm. Nobody in my
university already used LLVM.<br>
<br>
I already read a some documentation about llvm but i'm still lost.
<br>
<br>
Do there exist some " examples/Tutorials" for making small source
transformations.<br>
Or is there somebody who can help me a bit to get started.<br>
</blockquote>
<br>
The LLVM Programmer's Manual
(<a class="moz-txt-link-freetext" href="http://llvm.org/docs/ProgrammersManual.html">http://llvm.org/docs/ProgrammersManual.html</a>) and the Writing an
LLVM Pass Guide (<a class="moz-txt-link-freetext" href="http://llvm.org/docs/WritingAnLLVMPass.html">http://llvm.org/docs/WritingAnLLVMPass.html</a>) are
good documents on how to write transform and analysis passes that
plug into the LLVM opt tool.<br>
<br>
Some of the passes in the SAFECode compiler
(<a class="moz-txt-link-freetext" href="http://safecode.cs.illinois.edu">http://safecode.cs.illinois.edu</a>) are pretty simple and illustrate
simple tasks like instrumenting loads and stores or modifying calls
to functions. If you check out the mainline code, you can look at
lib/InsertPoolChecks/LoadStoreChecks.cpp,
lib/InsertPoolChecks/insert.cpp, and
lib/DebugInstrumentation/DebugInstrumentation.cpp for examples of
relatively simple passes.<br>
<br>
That said, LLVM is not really suitable for Source to Source
transformations. While LLVM can convert C code to LLVM IR and back
to C code, it does not preserve comments, and the generated C code
isn't really designed to be readable by humans. I would normally
recommend Clang for Source to Source transformations, but in your
case, working with Clang's AST is probably more trouble than it's
worth (from what I hear). For dangling pointer detection, working
on the LLVM IR is probably easier.<br>
<br>
As an aside, I work on SAFECode which (among other memory safety
guarantees) provides various protections for dangling pointer
errors. It enforces the points-to graph at run-time (as described
in Dinakar Dhurjati's PLDI 2006 paper) and includes a prototype
implementation of Dhurjati's et. al. dangling pointer detection
method (DSN 2006). You may want to take a look the CETS paper by
Santosh Nagarakatte et. al. (ISMM 2010) and Dinakar Dhurjati's PLDI
2006 paper (for which I can provide an informal explanation if you
don't like type-system proofs).<br>
<br>
Links to these papers are at:<br>
<a class="moz-txt-link-freetext" href="http://llvm.org/pubs/2006-DSN-DanglingPointers.html">http://llvm.org/pubs/2006-DSN-DanglingPointers.html</a><br>
<a class="moz-txt-link-freetext" href="http://www.cis.upenn.edu/~santoshn/ismm10-cets.pdf">http://www.cis.upenn.edu/~santoshn/ismm10-cets.pdf</a><br>
<a class="moz-txt-link-freetext" href="http://llvm.org/pubs/2006-06-12-PLDI-SAFECode.html">http://llvm.org/pubs/2006-06-12-PLDI-SAFECode.html</a><br>
<br>
SAFECode is publicly available at <a class="moz-txt-link-freetext" href="http://safecode.cs.illinois.edu">http://safecode.cs.illinois.edu</a>.
CETS may be available from Santosh's website.<br>
<br>
-- John T.<br>
<br>
<blockquote cite="mid:BAY128-W2903A7BC09859C2E078329B42C0@phx.gbl"
type="cite"><br>
Thx<br>
Vincent<br>
<br>
</blockquote>
<br>
</body>
</html>