问题
I'm trying to write an LLVM optimization pass. And I need a way to determine if one LLVM instruction affects the other (or depends on the other).
These dependencies can have different nature:
- first instruction creates a value, the other uses it as operand
- first instructions writes to memory location, the other reads from there
- other possibilities?
In short, first instruction must always be executed before the other in order to preserve code correctness. Three-way answer (depends, may depend, doesn't depend) will also do.
I understand that I can use use-def chains to find dependencies of type 1, and AliasAnalysis can help me with dependencies of type 2. But I'm afraid there can be other dependency types...
Does LLVM provide any general mechanism for that?
来源:https://stackoverflow.com/questions/9376958/how-to-figure-out-if-particular-llvm-instruction-depends-on-the-other