I'm trying to follow the instructions on how to add a new bitcode
This is my first foray into the guts of LLVM and I'm not sure I'm doing
things the right way. I came up with a patch that adds a NOP (no
operation) that will work with llvm-as, llvm-dis, and lli. It would be
nice if one of the experts could take a look and give some quick feedback:
I’m not really sure what a NOP even means in SSA. Sure, you can make the assembler and disassembler and interpreter do the right thing, but in any optimisation pass the right thing will be to delete them.
If you don’t want them to be deleted then, as they have no inputs and no outputs, optimisation could well decide to move other instructions up past a NOP, move it out of loops, etc, until it ends up after the return instruction.
If you don’t want instructions to be moved past it … it will have to be like a memory barrier instruction, except even stricter.
What do you want it to do?
By the way, Apple’s B3 optimiser in WebKit (which they wrote to replace LLVM there) does have a NOP instruction – and an IDENTITY instruction, which also is meaningless in SSA. When an optimisation wants to delete an instruction it turns it into a NOP instead. When an optimisation in LLVM would do a “replace all uses with”, B3 inserts an IDENTITY instruction. A later pass deletes all NOPs and propagates inputs of IDENTITYs to their (recursive) users.
I'm taking my very first baby steps with LLVM and I figured a NOP is a
reasonable starting point. Of course you are right that for optimization
purposes this is nonsensical. Perhaps some simple new instruction with
input/output should be my next goal. If you are aware of a resource that
is a little more detailed than the ExtendingLLVM.html page, I'd
Either way, thanks for your response.