Getting the use and def of an llvm instruction

Alk*_*Alk 5 c++ llvm dead-code

I am attempting to carry out liveness analysis and in order to do so I need to obtain the def and use sets for all of my nodes, where they are defined as follows:

def[n] = set of all variables defined at node n

use[n] = set of all variables used at node n

So for example in the line:

a = b + c

def[n] = {a}

use[n] = {b,c}
Run Code Online (Sandbox Code Playgroud)

How can I do this?

WON*_*WON 2

http://llvm.org/docs/ProgrammersManual.html#iteating-over-def-use-use-def-chains

我希望此页面可以帮助您。访问Value对象中的user_begin()、user_end()和users()方法的用户对象就是使用Value对象的用户对象。Instruction 类是 User 类的子类。

我可能是错的,但是要在 IR 级别获得 def-use 集,该集的元素应该是 Value 对象,每个节点应该是指令对象。
因此,每个节点的def集将是指令返回的Value对象(有可能是指令不返回,这种情况下,def集是空集。),而use集将是通过user_iterator指令访问用户对象