[LLVMdev] How to know if an instruction is "usable"

Krzysztof Parzyszek kparzysz at codeaurora.org
Thu Apr 25 10:17:08 PDT 2013


On 4/25/2013 12:06 PM, Giacomo Tagliabue wrote:
> Thanks,
> So, how do I check if a block dominates another one?

In IR use analysis DominatorTree from 
"include/llvm/Analysis/Dominators.h".  For machine instructions, use 
MachineDominatorTree
from "include/llvm/CodeGen/MachineDominators.h".

Both of them implement function "dominates" that takes two blocks 
(BasicBlock* or MachineBasicBlock*) and returns a boolean value 
indicating whether one dominates the other.  A block will always 
dominate itself, so this case needs to be handled separately to 
determine relative position between the def and the use instruction.

-Krzysztof

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list