LLVM Discussion Forums

Using metadata to instrument

I want to implement a simpy load and store check with a ISA extension, the basic idea is that:

load t0, 0(s0)  ->  check 0(t0)      ; A extension inst
                    load t0, 0(s0)

Since I’m a beginner to LLVM, I try to avoiding changing LLVM source code, I don’t want to extend IR.
My plan is to use metadata to tag the security load inst related IR, and at backend recongnize the tag and generate extention inst in MIR

But … I find that it seems hard to get the IR metadata in MIR, is this possible ? How to use metadata for codegen ? thks !