Is there anything currently in clang that creates a call graph for all the functions defined in a file? Any other whole program optimization phases? Where might I look in the source to find such info or inject a phase to do a whole program analysis?
Can you work on LLVM IR, or do you really need to work on Clang's AST?
I'm interested in similar thing and I believe I need AST because identifier names do matter for my goals.
Identifiers of local variables?
My best suggestion would be to hack Clang's IR generation code to add the metadata you need to the variables you're interested in, or even to do the optimization directly if it's really that local.