[LLVMdev] Remove an instruction through Dead Code Elimination pass of llvm
dpatel at apple.com
Mon Feb 13 09:45:30 PST 2012
Usually the pass should handle such simple and clear clean ups itself. If you grep for Inst->eraseFromParent() in source based then you'll see that many transformations are doing it immediately after they know that they have replaced all occurrences of %7.
On Feb 11, 2012, at 1:43 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Adarsh,
> On 11/02/12 09:47, Adarsh Konchady wrote:
>> My pass in LLVM generates an IR like this
>> %5 = icmp eq i32 %4, 0
>> %7 = or i1 %5, %5
>> ;. . .
>> Since the 'or' instruction is actually not needed(dead code), I replaced all
>> occurences of %7 with %5.
>> Now, the 'or' instruction should get deleted. How can I call Dead Code
>> Elimination pass of LLVM from my pass or is there any method to remove that 'or'
> in LLVM passes don't schedule other passes. Whoever schedules your pass to run
> can just schedule a dead code elimination pass after yours (or instcombine, or
> some other pass that will zap this kind of thing). Alternatively, your pass
> can use a utility function to do it, for example SimplifyInstructionsInBlock,
> defined in llvm/Transforms/Utils/Local.h
> Ciao, Duncan.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev