Code analysis

Hi All,

I think , I was unclear in my last post.

I am looking for source code analysis of a program, something similar to
what SUIF does.

Consider a simple example of Matrix addition
A[i][j]+=B[i][j];

I want to know how matrix A is accessed, like whether it is A[i][j] in
this case or A[j][i].

Is there anyway in llvm to write a pass to identify this? Can someone give
pointers to it?

Regards,
Kamal

Kamal,

There isn't an existing pass that does what you want but, if you wanted to write such analyses *and* use them for other compiler tasks, I think it would be easier to do so in in LLVM than in may source-to-source infrastructures.

Assuming you are interested in a *somewhat language-specific* analysis (e.g., one that applies to Fortran or to C/C++/Obj-C), you would need to essentially write a pass or passes to do the following:

(a) Identify the variables, functions, etc., at the LLVM level, corresponding to those entities you are interested in at the source-level. I think this is the primary step that would be language-specific.

(b) Perform the analyses you want (such as the one below) using the existing LLVM analysis passes and utilities, e.g., the scalar evolution pass and loop info, plus some custom analysis, to do the one below. This part can be quite language-independent, at least to the extent that the queries are language-independent.

(c) Try to build more complex queries from simpler ones so that you can maximize reuse of the analyses. E.g., for the one below, you could do it using two simpler queries: one that checks whether the i or j loops is innermost, and another one that checks how the A index expression is related to the various loop bounds.

I'm sure others on this list have other suggestions (and perhaps some better ones).

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.org