Assertion `InReg && "Value not in map!"' failed

Thanks Nick! ok. I ran through the verifier and this is the issue:
verifying... Instruction does not dominate all uses!
  %tmp3 = add i32 %b, %a ; <i32> [#uses=2]
  store i32 %tmp3, i32* %0, align 4
Broken module found, compilation aborted!
add is existing instruction in function. store is the instruction I have added to the function. How do I fix this now :(?

Thanks,
Bhavani

bhavani krishnan wrote:

Thanks Nick! ok. I ran through the verifier and this is the issue:
verifying... Instruction does not dominate all uses!
  %tmp3 = add i32 %b, %a ; <i32> [#uses=2]
  store i32 %tmp3, i32* %0, align 4
Broken module found, compilation aborted!
add is existing instruction in function. store is the instruction I have added to the function. How do I fix this now :(?

Yep, you need all uses of an instruction to be dominated by the definition of the instruction.

Within a single basic block, it means that the instructions need to be in order. You can't have 'store %tmp3' before the '%tmp3 = ...' has been executed.

If they're in two different basic blocks, you need to make sure that the basic block your store is in is actually dominated by the basic block that defines %tmp3.

Nick