[LLVMdev] Instruction->mayReadFromMemory
Chris Lattner
sabre at nondot.org
Sat May 13 19:15:45 PDT 2006
On Fri, 12 May 2006, Seiden Tiger wrote:
> Ok, i'll try to put it in different words: I am looking for the points where
> data is flowing into the basic blocks (and later where data is going out). So
> essentially i want to extract the dataflow out of the llvm internal
> representation.
Ok
> As Example i have the first block in a function:
> int %main(int %argc, sbyte** %argv) {
> entry:
> %tmp.1 = seteq int %argc, 2 ; <bool> [#uses=1]
> br bool %tmp.1, label %then, label %no_exit
>
> At first i thought that %argc must be a memory access. But its a function
> argument, so it is a register value.
Right. Memory is explicitly accessed with load/store. SSA values are not
memory objects.
> But looking locally at my block "entry" i have currently no idea that
> %argc is a function argument an thus data beeing readily available for
> usage. So i am looking at an way to find all the variables which already
> contain valid data at the beginning, contrary to data which is computed
> in the block.
If you have a Value*, you can use queries like:
isa<Argument>(V)
isa<Constant>(V)
etc. In practice, if you want to find things like in to a function, the
predicate "if (!isa<Instruction>(V))" will work, because all
non-instruction values dominate all instructions.
You might also want to check this information out, for traversing use/def
def/use chains:
http://llvm.org/docs/ProgrammersManual.html#iterate_chains
there is lots of other good stuff in that document as well.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list