Adding a new instruction?


We 're working on an llvm interpreter. We perform some static analysis
to detect some blocks with a specific property, and we need the
interpreter to be able to recognise these blocks fast in time it
reaches them. We thought of adding a new instruction in the LLVM
instruction set and put it in the beginning of such blocks, so that
the interpreter would be instantly alerted that the current block is
'special'. Is there an easier/quicker way to do this?


Sorry, forgot to post to list.

For 2.7 I'm wondering if you could use custom metadata attached to the first instruction of a "special" block? You could register a unique kind (not sure how to guarantee uniqueness), and attach a metadata node via the context to the first instruction with this kind. Your pass would look for this. I have never tried this, so I don't know if predecessor passes that your pass would depend on would affect this metadata; if different threads with their own context would see metadata attached via a specific context; and what the resultant performance effect would be.

Just a thought