[LLVMdev] global optimizer precision

Frits van Bommel fvbommel at gmail.com
Thu Oct 28 09:18:49 PDT 2010


On Thu, Oct 28, 2010 at 2:54 PM, Gordon Haak <gordon.haak at googlemail.com> wrote:
> The comment above the test states the reason for the check for main
> which is: main is not recursive.
> My proposal is to introduce a routine to check if a function is
> recursiv (returning false, only if its not recursiv for
> sure). Than one can replace the check for main with the call to the
> 'isrecursiv'-Function. The implemention of 'isrecursiv' can first
> check for main and later improve the precision by inspecting the call
> graph. This finally would lead to a more aggressiv interprocedural
> optimizer.
> Whats your opinion?

That's not the only needed condition; for this to be safe you also
need to know that one of the following holds:
a) The function is only called at most once.
b) The global is constant.
c) The function always overwrites (any part of) the value before
reading it (or that part).
d) Any situations I forgot :).

The reason for this is that local variables don't preserve their value
between calls, so you can't just do this for most (non-recursive)
functions without verifying it's safe for some reason.

main() of course satisfies option (a), so there it's always safe.



More information about the llvm-dev mailing list