Not Understanding Use

Let's say I have the following IR code:

21> %tmp = load i32* @myrand.z, align 4
22> %tmp1 = and i32 %tmp, 5535
23> %tmp2 = mul nsw i32 %tmp1, 36969
24> %tmp3 = ashr i32 %tmp, 16

And I have an Instruction *inst that is the instruction on line 22.

then have the code:

Use *operand1 = &(inst->getOperandUse(0));

I expect that operand1->getNext() will return the the Use* for %tmp in the instruction on line 24. However, what I get is a null pointer. Why is this exactly? I feel I'm not understanding the point of the Use if I can't even see the very next usage only 2 instructions away.

So I must be missing something.

Thank you.
-Brandon

Hi Brandon,

Let's say I have the following IR code:

21> %tmp = load i32* @myrand.z, align 4
22> %tmp1 = and i32 %tmp, 5535
23> %tmp2 = mul nsw i32 %tmp1, 36969
24> %tmp3 = ashr i32 %tmp, 16

And I have an Instruction *inst that is the instruction on line 22.

then have the code:

Use *operand1 =&(inst->getOperandUse(0));

I expect that operand1->getNext() will return the the Use* for %tmp in
the instruction on line 24.

aren't you assuming that the Use list is ordered in the same order as the
instructions in the basic block? What if line 24 is the first use, and
line 22 is the second use?

Ciao, Duncan.

  However, what I get is a null pointer. Why