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

Lorenzo Casalino via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 6 07:27:21 PST 2020


Hi Christopher,

unfortunately, there still no facility/api able to support propagation of
IR Metadata down to the backend.

Nonetheless, I and another guy are working on a draft of proposal addressing
specifically this need. Here you find the link to the last message of the
on-going thread:

http [://] lists [.] llvm [.] 
org/pipermail/llvm-dev/2020-November/146387.html

Feel free to join the discussion!

However, do not despair: a short-term solution is to creatively employ 
ad-hoc
intrinsics, which carry the metadata you require. The backend won't 
touch such
elements, since it does not know how to operate on them.

Clearly, it may come with several important drawbacks.


Have a nice day :)
-- Lorenzo

> Message: 8
> Date: Thu, 5 Nov 2020 13:56:57 -0500
> From: K Jelesnianski via llvm-dev<llvm-dev at lists.llvm.org>
> To: llvm-dev<llvm-dev at lists.llvm.org>
> Subject: [llvm-dev] How to pass custom metadata from IR module pass to
> 	backend MF pass?
> Message-ID:
> 	<CAH=yU0a8YX=c3Jih_52PXCvodW5dT1ogsd3MHrEQVqJ_A0raOQ at mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> 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