Quantcast

Newbie question : instrumenting code

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Newbie question : instrumenting code

Rahul Garg-2
Hi.

I am new to Clang and somewhat new to LLVM. I am doing a project where I need to instrument C code to add some profiling information such as timers and iteration counts of loops to some of the functions and then it will be compiled using clang+llvm. The transformation need not be source to source. All I am looking for is the ability to add instrumentation at some point during the compilation process. Is it reasonable to attempt to modify Clang so that it adds timers and logging calls at the places I need? Or should I be looking at some other part of the LLVM stack?

thanks,
rahul





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newbie question : instrumenting code

Douglas Gregor

On Dec 13, 2009, at 9:28 AM, Rahul Garg wrote:

> Hi.
>
> I am new to Clang and somewhat new to LLVM. I am doing a project  
> where I need to instrument C code to add some profiling information  
> such as timers and iteration counts of loops to some of the  
> functions and then it will be compiled using clang+llvm. The  
> transformation need not be source to source. All I am looking for is  
> the ability to add instrumentation at some point during the  
> compilation process. Is it reasonable to attempt to modify Clang so  
> that it adds timers and logging calls at the places I need? Or  
> should I be looking at some other part of the LLVM stack?


You will probably want to extend Clang's CodeGen to create LLVM IR for  
the timers/instrumentation directly. That will make it easy to tie  
that instrumentation to specific AST elements, which might be useful  
if you decide that you also want to add instrumentation pragmas or  
attributes that show up in the source code.

If you're interesting in perform more low-level instrumentation, you  
could consider adding an LLVM pass.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Loading...