<div dir="ltr">I would encourage you to look at the "cfguard" bundle added for Windows Control Flow Integrity. AsmPrinter is probably far too late for the transform you want to do. You probably need to implement it somewhere in call lowering, so assuming this is for x86, you would implement this in X86ISelLowering::LowerCall.<div><br></div><div>I think it would be less invasive to attach your metadata to the existing call instructions, and then change code generation later, rather than replacing the IR instructions completely.<br><br>The implementation for cfguard is mostly here:<div><a href="http://github.com/llvm/llvm-project/commit/d157a9bc8ba1085cc4808c6941412322a7fd884e">http://github.com/llvm/llvm-project/commit/d157a9bc8ba1085cc4808c6941412322a7fd884e</a>  <br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 27, 2020 at 1:28 AM Felix Berlakovich 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">





<div lang="EN-US">
<div class="gmail-m_-774017834544232385WordSection1">
<p class="MsoNormal">Hi!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have written a ModulePass that calculates various things and adds custom metadata attributes to certain instructions. Depending on the attributes, I would like to change the machine code of these instructions. For example, I would like
 to replace certain calls with jumps, but as far as I can tell the IR metadata is not accessible anymore on the level of machine instructions (e.g. in the AsmPrinter). What is the best way to pass the information calculated by the pass (e.g the attributes)
 to the part where the target specific instructions are emitted?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Regards<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Felix<u></u><u></u></p>
</div>
</div>

_______________________________________________<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>