<div dir="ltr">Hi Christopher,<div><br></div><div>We just started a discussion about introducing the metadata mechanism to the MIR, just as the IR does, i.e. attaching metadata to a MachineInstr: <a href="http://lists.llvm.org/pipermail/llvm-dev/2020-July/143639.html">http://lists.llvm.org/pipermail/llvm-dev/2020-July/143639.html</a> and <a href="http://lists.llvm.org/pipermail/llvm-dev/2020-September/144886.html">http://lists.llvm.org/pipermail/llvm-dev/2020-September/144886.html</a></div><div>However, there is currently a special metadata that survives DAG lowering: debug info.</div><div>In the IR, llvm.dbg.value intrinsics maps an SSA value to the metadata describing a given source-level variable.</div><div>In the MIR, DBG_VALUE pseudo-instructions map a register to the metadata describing a given source-level variable.</div><div>In fact, there is a 1:1 mapping between llvm.dbg.value and DBG_VALUE, and the same variable metadata is used for a given pair of (llvm.dbg.value, DBG_VALUE). This metadata is kept aside in SelectionDAG, and is inserted in the DBG_VALUE during instruction emitting phase.</div><div>Maybe you can mimic this process for lowering your metadata?</div><div><br></div><div>HTH,</div><div> <br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Son Tuan Vu</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 5, 2020 at 7:57 PM K Jelesnianski via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear All,<br>
<br>
I am performing some analysis on a traditional IR Module Pass in LLVM,<br>
with that analysis I want to tag the places I will need to extract<br>
file offsets from as custom symbols.<br>
<br>
Ideally I would want to attach some metadata to a IR instruction, and<br>
have it be accessible when I perform a backend MF pass.<br>
<br>
Essentially I want to pass the information I collected and generated<br>
in the IR pass, to the backend machineFunction pass and ASMPrinter<br>
that will be able to write out custom symbols with my metadata.<br>
<br>
The problem I'm running into is two-fold:<br>
1) IR Instructions are being expanded to multiple x86 assembly,<br>
machine instructions. (No surprise about that, but if I tag at the<br>
BasicBlock level, the tag will be in the wrong place)<br>
2) I do not know know how to tag an IR instruction with metadata, so<br>
that that metadata survives the DAG lowering to x86 machine<br>
instructions. Has anyone done this before?<br>
<br>
Options I have in my head is to write out my metadata into a output<br>
text file (gathered from the IR pass) and have the MF pass read that<br>
output text file in again to do the tagging I need. (Another issue<br>
here is how to code opt to take in a text file as pass data and NOT a<br>
file to be compiled/opted)<br>
<br>
Thanks!<br>
<br>
Sincerely,<br>
<br>
Christopher Jelesnianski<br>
Virginia Tech Research Assistant<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>