Joshua Warner
2011-May-05 04:17 UTC
[LLVMdev] Could LLVM or Clang go backward to modify c source code?
Forgot to CC the list. On Wed, May 4, 2011 at 10:16 PM, Joshua Warner <joshuawarner32 at gmail.com>wrote:> Wen-Han, > > 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. > > So the short answer is "no." > > -Joshua > > On Wed, May 4, 2011 at 9:16 PM, Wenhan Gu <nowar100 at gmail.com> wrote: > >> Hi all, >> >> I have a source code: >> int* p = malloc(...); >> >> After translating to llvm::Module, We can know the source code did not >> call free. >> I know we can hack this into Module. >> >> But my question is, >> could we hack it back to source code? >> After fixing, the source will become: >> int *p = malloc(...); >> free(p); >> >> Is this feasible? >> >> Thanks all very much. >> >> -- >> Best regards, >> Wen-Han >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110504/f99b8d1b/attachment.html>
Reasonably Related Threads
- [LLVMdev] Could LLVM or Clang go backward to modify c source code?
- [LLVMdev] Data flow analysis
- [LLVMdev] [cfe-dev] __builtin_va_list different on targets
- [LLVMdev] Could LLVM or Clang go backward to modify c source code?
- [LLVMdev] [cfe-dev] __builtin_va_list different on targets