Neal N. Wang
2010-Apr-15 00:45 UTC
[LLVMdev] whether these transformations are doable and how?
Thanks for all the replies which are really helpful. one more question regarding transformation: 4. Given an instruction %x1 = I1, can I replace the rhs "I1" with "I2" and get a new instruction %x1 = I2? Alternatively, I can add a new instruction %x2 = I2, and replace all uses of %x1 with %x2, and then delete %x1 = I1, but it seems the former is simpler or faster if it's doable. Any suggestion? Neal On Mon, Apr 12, 2010 at 11:20 PM, Devang Patel <devang.patel at gmail.com>wrote:> > 3. can I modify a function to take extra formal parameters? can I update > > all calls of the original function to take extra actual paramters? The > > function might be called across multiple modules. It seems this has to > be > > done at both ModulePass and FunctionPass levels. > > > > Check out DeadArgumentElimination pass. It does opposite of what you > want, but you'll get an idea. > > - > Devang >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100414/f5ca41f7/attachment.html>
Neal N. Wang
2010-Apr-15 01:38 UTC
[LLVMdev] whether these transformations are doable and how?
It's a silly question. I rephrase it as "is it possible to use different instruction to def the same ssa variable?" On Wed, Apr 14, 2010 at 5:45 PM, Neal N. Wang <neal.wang at gmail.com> wrote:> Thanks for all the replies which are really helpful. > > one more question regarding transformation: > > 4. Given an instruction %x1 = I1, can I replace the rhs "I1" with "I2" > and get a new instruction %x1 = I2? Alternatively, I can add a new > instruction %x2 = I2, and replace all uses of %x1 with %x2, and then delete > %x1 = I1, but it seems the former is simpler or faster if it's doable. > > Any suggestion? > Neal > > > > > On Mon, Apr 12, 2010 at 11:20 PM, Devang Patel <devang.patel at gmail.com>wrote: > >> > 3. can I modify a function to take extra formal parameters? can I >> update >> > all calls of the original function to take extra actual paramters? The >> > function might be called across multiple modules. It seems this has to >> be >> > done at both ModulePass and FunctionPass levels. >> > >> >> Check out DeadArgumentElimination pass. It does opposite of what you >> want, but you'll get an idea. >> >> - >> Devang >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100414/770b3065/attachment.html>
Eli Friedman
2010-Apr-15 02:51 UTC
[LLVMdev] whether these transformations are doable and how?
On Wed, Apr 14, 2010 at 5:45 PM, Neal N. Wang <neal.wang at gmail.com> wrote:> Thanks for all the replies which are really helpful. > > one more question regarding transformation: > > 4. Given an instruction %x1 = I1, can I replace the rhs "I1" with "I2" > and get a new instruction %x1 = I2? Alternatively, I can add a new > instruction %x2 = I2, and replace all uses of %x1 with %x2, and then delete > %x1 = I1, but it seems the former is simpler or faster if it's doable.Creating a new instruction, replacing all the uses, and deleting the old instruction is the standard procedure; for various reasons, LLVM doesn't allow editing certain aspects of an Instruction. -Eli
Reid Kleckner
2010-Apr-15 03:09 UTC
[LLVMdev] whether these transformations are doable and how?
The code you're looking for is Value::replaceAllUsesWith(Value*). Values maintain backpointers to users, so it doesn't need to search for users in the rest of the function, making this an efficient operation. Reid On Wed, Apr 14, 2010 at 10:51 PM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Wed, Apr 14, 2010 at 5:45 PM, Neal N. Wang <neal.wang at gmail.com> wrote: >> Thanks for all the replies which are really helpful. >> >> one more question regarding transformation: >> >> 4. Given an instruction %x1 = I1, can I replace the rhs "I1" with "I2" >> and get a new instruction %x1 = I2? Alternatively, I can add a new >> instruction %x2 = I2, and replace all uses of %x1 with %x2, and then delete >> %x1 = I1, but it seems the former is simpler or faster if it's doable. > > Creating a new instruction, replacing all the uses, and deleting the > old instruction is the standard procedure; for various reasons, LLVM > doesn't allow editing certain aspects of an Instruction. > > -Eli > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Apparently Analagous Threads
- [LLVMdev] whether these transformations are doable and how?
- [LLVMdev] whether these transformations are doable and how?
- [LLVMdev] whether these transformations are doable and how?
- [LLVMdev] whether these transformations are doable and how?
- [LLVMdev] Writing a pass that modifies the IR