[LLVMdev] Can I get the binary address of a for-loop statement?

Jim Grosbach grosbach at apple.com
Tue Apr 26 20:32:59 PDT 2011

In general, this is not possible. Consider, for example, the fact that various optimization passes may reorder the code, including such things as hoisting computations outside of the loop, and enclosing loops, scheduling those instructions before others that did not originate from source lines within the loop, etc. That's not to mention things like loop unrolling.

That said, especially at low optimization levels, you may be able to get at least an approximation of what you're after from debug information. See http://llvm.org/docs/SourceLevelDebugging.html for an overview.


On Apr 26, 2011, at 7:57 PM, 陳韋任 wrote:

> Hi, all
>  What I want to do is to locate the range of a for-loop statement in
> a binary. For example, given a for-loop statement belows, 
> for (stat1; stat2; stat3) {
>  /* do something */
> }
>  Is it possible to get information about the range (binary address)
> of the above for-loop, say, 0x0100 - 0x0120.
>  One idea comes up in my mind is adding passes to retrieve such
> information in LLVM, then use llvm-gcc to compile the code.
>  Any suggestion appreciated.
> Regards,
> chenwj
> -- 
> Wei-Ren Chen (陳韋任)
> Computer Systems Lab, Institute of Information Science,
> Academia Sinica, Taiwan (R.O.C.)
> Tel:886-2-2788-3799 #1667
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list