modify instructions

Hi, I have a question about the modify of instruction:
Say I want to modify
%a = getelementptr %struct %S, long 0, ubyte 1
into
%a.f0 = getelementptr int* %S.f0, long 0

There are 3 ways I can think of to implement, but I'm not sure
what should I do.

1. I can use new GetElementPtr to create a new instruction and
use ReplaceInstWithInst() function to replace the old one.

2. I can use new GetElementPtr to create a new instruction and
then insert it into the code, then delete the old instruction,
but the problem is the program will automatically change the
name of the new instruction if you give it the same name with
the old one?

3. Just modify the operand 0 and delete the operand 2. But I
didn't see an command to delete an operand.

Please let me know in LLVM, what's the best way to handle
this? Thanks,

xiaodong

Hi, I have a question about the modify of instruction:
Say I want to modify
%a = getelementptr %struct %S, long 0, ubyte 1
into
%a.f0 = getelementptr int* %S.f0, long 0

There are 3 ways I can think of to implement, but I'm not sure
what should I do.

the LLVM system. The best way to do that, IMO, is to experiment with it
and see what works best.

Why don't you try doing one of the various approaches, see if it has
drawbacks, and if so, try another one? You can look for examples in the
source base of passes that modify and move around instructions...

-Chris

http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/

The simplest way is to create a new instruction and use replaceAllUsesWith
on the old one.

Think about a simple way to get rid of the old one (without producing
illegal LLVM as the output of your phase).

--Vikram