Correlating clang::CFGs with LLVM-CFGs

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

Correlating clang::CFGs with LLVM-CFGs

philipp.legrum

Hello LLVM-Developers,

I'd like to write a program slicer that operates on LLVM-CFGs. The result, however,  should be displayed to code reviewers in a CFG that is close to the C source code. The Graphviz output of clang::CFG is already pretty close to what I intend to do.

Obviously, debug-info helps me to determine the origin of LLVM-instructions within the source code.
So I am wondering now, if there is an (more) elegant way to correlate unoptimized LLVM-basic blocks (and the instructions contained by them) with the nodes of clang::CFGs (and the statements contained by those). Initially it would be ok to run the slicer on unoptimized code because I suspect optimization to complicate the correlation.

Thanks in advance for your support.

Kind regards,
Philipp Legrum
If you are not the intended addressee, please inform us immediately that you have received this e-mail in error, and delete it. We thank you for your cooperation.


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

Re: Correlating clang::CFGs with LLVM-CFGs

Daniel Dunbar
On Thu, Jan 28, 2010 at 2:49 AM,  <[hidden email]> wrote:

>
> Hello LLVM-Developers,
>
> I'd like to write a program slicer that operates on LLVM-CFGs. The result,
> however,  should be displayed to code reviewers in a CFG that is close to
> the C source code. The Graphviz output of clang::CFG is already pretty close
> to what I intend to do.
>
> Obviously, debug-info helps me to determine the origin of LLVM-instructions
> within the source code.
> So I am wondering now, if there is an (more) elegant way to correlate
> unoptimized LLVM-basic blocks (and the instructions contained by them) with
> the nodes of clang::CFGs (and the statements contained by those). Initially
> it would be ok to run the slicer on unoptimized code because I suspect
> optimization to complicate the correlation.

Short answer is no. Your best bet is to use debug info to do this.
Once you have used debug info to map instructions to the source they
came from, it is always possible to use the clang APIs to map those
source locations to clang AST nodes (see the APIs vended via
clang/include/clang-c/Index.h for example).

 - Daniel

>
> Thanks in advance for your support.
>
> Kind regards,
> Philipp Legrum
> If you are not the intended addressee, please inform us immediately that you
> have received this e-mail in error, and delete it. We thank you for your
> cooperation.
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>

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