How to find out if a particular LLVM instruction depends on another?

I am trying to write an LLVM optimization pass. And I need a way to determine if one LLVM command affects another (or depends on another).

These dependencies can have a different nature:

  • the first instruction creates a value, the other uses it as an operand
  • the first instructions are written to the memory cell, the other reads from there
  • other features?

In short, the first command should always be executed before the other in order to keep the code correct. A tripartite response will also be executed (depends, may depend, does not depend).

I understand that I can use use-def chains to look for type 1 dependencies, and AliasAnalysis may help me with type 2 dependencies. But I'm afraid there might be other types of dependencies ...

Does LLVM provide any general mechanism for this?

+4
source share

Source: https://habr.com/ru/post/1397592/


All Articles