I am writing a compiler for an assignment for a language that has empty statements. For structures like if-then-else it could be convenient if I could use a no-op statement in llvm but I didnt find any "official" nop. I have some ideas but ideally I would like to have llvm to optimize that part of the code and remove the instruction; any advice?
There is no no-op opcode in the IR. But you can safely use any side-effects-free dead instruction as a replacement (that is, if you really need to emit a no-op) because the optimizers will delete them easily enough. E.g. %nop = add i1 0, 0
or %nop = alloca i1, i1 0
could work.