replace instruction

Hello all,

Suppose I have an Instruction like

%1 = add i32 %a, %b

and I want to convert it like

%t = add i32 %a, %b
and assign the value of %t to %1 (something like %1 <- %t )

how can I accomplish this?

Regards,
Chayan

Chayan Sarkar wrote:

Hello all,

Suppose I have an Instruction like

%1 = add i32 %a, %b

and I want to convert it like

%t = add i32 %a, %b

This is not an assignment, that is a common misunderstanding. There is no register being assigned to the result of the add. The format is "%<name of instruction> = <instruction>". If you want your instruction to have the name "t" then call MyAddInst->setName("t");

and assign the value of %t to %1 (something like %1<- %t )

There is no copy instruction in LLVM. You can fake it with bitcast but you should never need to do that.

Nick