[llvm-dev] Find the instructions where a particular value is defined

Syed Rafiul Hussain via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 27 17:42:01 PST 2016


Sorry, I should ask the following:
finds all the instructions of a function where a particular variable is defined?
Lets consider the following code snippet:

1. void foo(){
2. int a, b;
3. if(a > 10)
4.   b = 10;
5. if(a<10)
6.   b = 5;
7. cout << b;
8. }

I would like to know the instructions where variable b can be be
defined, i.e, in this case, the instructions 4 and 6.

On Wed, Jan 27, 2016 at 8:15 PM, Tim Northover <t.p.northover at gmail.com> wrote:
> On 27 January 2016 at 17:08, Syed Rafiul Hussain via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
>> I am wondering if there is anything like def-use chain which finds all
>> the instructions of a function where a particular value is defined?
>
> How do you mean? LLVM IR is in SSA form, which means that each Value
> has precisely one definition (which may or may not be an instruction).
> If you've got a "Value *V" in C++ you can just
> "dyn_cast<Instruction>(V)" to find the instruction (again, if it
> exists).
>
> Cheers.
>
> Tim.



-- 
Rafi


More information about the llvm-dev mailing list