Value &operator=(const Value &) = delete;

Does it mean we can not dereference the Value variables?

Value *val = some operand of an instruction;
Value *val2= some operand of another instruction;

I am trying to rewire the operand values of an instruction using:

*val = *val2;

It seems that this is not allowed.

Thanks,

Hi Abid,

I don’t work on the LLVM-IR level very often so this may be incorrect but I believe you’re looking for either:
val.replaceAllUsesWith(val2)or:
instruction.getOperandUse(Index).set(val2)

The first one should change all instructions that use val2 so that they use val instead. The second should change one specific operand of an instruction to use val2 instead.

Hi Abid,

I don't work on the LLVM-IR level very often so this may be incorrect
but I believe you're looking for either:
    val.replaceAllUsesWith(val2)
or:
    instruction.getOperandUse(Index).set(val2)

The first one should change all instructions that use val2 so that
they use val instead. The second should change one specific operand of
an instruction to use val2 instead.

This should work. The shorter version is `setOperand(i, NewOpVal)`.