[llvm-dev] How to pass custom metadata from IR module pass to backend MF pass?

K Jelesnianski via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 5 10:56:57 PST 2020


Dear All,

I am performing some analysis on a traditional IR Module Pass in LLVM,
with that analysis I want to tag the places I will need to extract
file offsets from as custom symbols.

Ideally I would want to attach some metadata to a IR instruction, and
have it be accessible when I perform a backend MF pass.

Essentially I want to pass the information I collected and generated
in the IR pass, to the backend machineFunction pass and ASMPrinter
that will be able to write out custom symbols with my metadata.

The problem I'm running into is two-fold:
1) IR Instructions are being expanded to multiple x86 assembly,
machine instructions. (No surprise about that, but if I tag at the
BasicBlock level, the tag will be in the wrong place)
2) I do not know know how to tag an IR instruction with metadata, so
that that metadata survives the DAG lowering to x86 machine
instructions. Has anyone done this before?

Options I have in my head is to write out my metadata into a output
text file (gathered from the IR pass) and have the MF pass read that
output text file in again to do the tagging I need. (Another issue
here is how to code opt to take in a text file as pass data and NOT a
file to be compiled/opted)

Thanks!

Sincerely,

Christopher Jelesnianski
Virginia Tech Research Assistant


More information about the llvm-dev mailing list