Current Values ​​in LLVM

Suppose I have in CFG (among others) two base blocks A and B with an edge from A to B. I need to do the following:

  • get a set S of live values ​​through this edge (this may be an excessive approximation, i.e. it may contain values ​​that are not alive anymore)
  • match each of them with a different value (S-> S ')
  • replace - in B and its successors - all types of use of values ​​in S with displayed values ​​(S ')

Does LLVM provide an easy way to make the first and third points (because I seem to be unable to find it)? If not, do you have any suggestions on how to do this?

Note: cross-pointer on the LLVM mailing list

+4
source share
1 answer

I do not have a clear answer to your question, but the director should follow, it occurred to me. Hope this helps you in some way.

First, I would look at “Iterating over instructions in BasicBlock” and “Iterating over def-use and use-def chains” from the LLVM Programmers Manual . It gives an idea of ​​how to iterate through the instructions in the base unit and to users of this value.

As you need to know living values ​​around the edge, I would look at “Iterating over BasicBlocks in a Function” and try to determine where the users are located (more than ech, which you iterate), for example const BasicBlock * llvm :: Instruction :: getParent () const .

If the information the users are placed in is not enough, you can take advantage of [dominant analyzers and analysts], check:

This can help you determine the dominance ratio between blocks or instructions, which can help you create your sets.

+2
source

All Articles