[cfe-dev] Can I establish a relation between a SCoP in LLVM-IR and the corresponding line number in C-code?

Pieter Custers pieterjjmcusters at gmail.com
Tue Jan 17 06:19:03 PST 2012


On 17 jan 2012, at 14:57, Tobias Grosser wrote:

> On 01/17/2012 11:49 AM, Pieter Custers wrote:
>> Hi all,
>> 
>> I am using LLVM w/ Clang as front end. I use Clang to transform a C-file into LLVM-IR. Now I'm wondering if I can establish a relation between the SCoPs in this IR and the C-code. In other words, I want the line-number in the C-code of this SCoP (e.g. a loop nest) in LLVM-IR.
>> 
>> Is this possible, and if so, how do I obtain this?
> 
> Hi Pieter,
> 
> it is not supported out of the box, but you may try to use the debugging information to get this information. However, keep in mind,
> that debugging information is best afford and may not be available in all cases. If you really need accurate feedback based on C-code a source analysis tool like pet[1] may better fit your needs. pet uses clang and isl to extract a polyhedral model directly from the source code.
> 
> Tobi
> 
> [1] http://repo.or.cz/w/pet.git

I see now two possibilities:

1) pet would be okay to use, but then I loose the ability to transform loops in a canonical form (now I use a LLVM pass for that). Right?

2) I am looking to use CLang APIs in a C-program to construct the AST and try 'Mapping between cursors and source code' [2].

Cheers, Pieter

[2] http://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120117/d6463b2b/attachment.html>


More information about the cfe-dev mailing list