Forgot to CC the list.<br><br><div class="gmail_quote">On Wed, May 4, 2011 at 10:16 PM, Joshua Warner <span dir="ltr"><<a href="mailto:joshuawarner32@gmail.com">joshuawarner32@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Wen-Han, <div><br></div><div>It sounds like there are two problems here: first is detecting when free is not properly called, and figuring out where to insert the call - which seems like an intractable problem by iteself.  Second is a reversible translation from C to LLVM IR.  LLVM does (did?) have support for generating C code again on the back end, but the result doesn't look that much like the original code.  In order to translate changes from the IR back to the source code, detailed information would have to be kept on what IR structures resulted from what source statements and how they interact.  There has been work on such reversible transformations done (I can't recall where atm), but that was only in very simple cases that could be described by regular expressions.</div>

<div><br></div><div>So the short answer is "no."</div><div><br></div><div>-Joshua<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Wed, May 4, 2011 at 9:16 PM, Wenhan Gu <span dir="ltr"><<a href="mailto:nowar100@gmail.com" target="_blank">nowar100@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">Hi all,<div><br></div><div>I have a source code:</div><div><font face="'courier new', monospace">int* p = malloc(...);</font></div>

<div><br></div><div>After translating to llvm::Module, We can know the source code did not call <font face="'courier new', monospace">free</font>.</div>
<div>I know we can hack this into Module.</div><div><br></div><div>But my question is,</div><div>could we hack it back to source code?</div><div>After fixing, the source will become:</div><div><font face="'courier new', monospace">int *p = malloc(...);</font></div>


<div><font face="'courier new', monospace">free(p);</font></div><div><br></div><div>Is this feasible?</div><div><br></div><div>Thanks all very much.</div><div><br>-- <br>Best regards,<br>Wen-Han<br>

</div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br>