[LLVMdev] Last use of operand within BasicBlock?

Duncan Sands baldrick at free.fr
Tue Jul 17 00:31:17 PDT 2012


Hi Ryan,

> Given an instruction and the basic block that it's in, is there an easy way to
> tell if the operands are ever referenced after the instruction?

if the operand only has one use (->hasOneUse()) then you know it.  Otherwise it
is more tricky.  Why do you care?

Ciao, Duncan.

>
> For example, if i have
> ...
> %mul = mul nsw i32 %a, %val
> %add = add nsw i32 %b, %val
> ...
>
> And I'm iterating through this basic block, can I tell when I get to the
> multiply instruction that another instruction is going to be using %val?
>
> Since I'm running my code through reg2mem, I don't really care much about other
> basicblocks (anything outside the basicblock should have an eliminated phi
> instruction so it will be pulled from memory anyways).
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>





More information about the llvm-dev mailing list