[LLVMdev] Instruction->mayReadFromMemory

Chris Lattner sabre at nondot.org
Fri May 12 10:09:26 PDT 2006


On Fri, 12 May 2006, Silken Tiger wrote:
> To find the first instructions which are not depending on others results. So
> far it seems to be working but i am missing instructions like:
> %tmp.1 = seteq int %argc, 2             ; <bool> [#uses=1]
> There seems only an function like llvm::Instruction::mayWriteToMemory
> but nothing like llvm::Instruction::mayReadFromMemory or s.t. with similiar
> functionality?
>
> Or else: if there is an even easier way to get the non data depending
> instruction from a block i missed, i would be also happy.

I'm not sure what you're looking for.  LLVM has effectively four types of 
instructions:

1. Instructions that read memory (load).
2. Instructions that write memory (store).
3. Instructions that may read or write memory (those that return true for
    mayWriteToMemory), e.g. calls.
4. Instructions without side effects, like seteq,add,and,getelementptr,
    etc.  The data dependencies are the only thing you need to know here.

I'd suggest you test instructions in that order for the properties they 
have.  Later, as a refinement, you can use the alias analysis interfaces 
to query mod/ref properties of function calls, which may make your 
analysis slightly more precise.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-dev mailing list