<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have a somewhat similar scenario in a downstream back-end. You might try #2 and then call one of:<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
  /// Set this block to reflect that it potentially is the target of an indirect branch.
<div>  void setHasAddressTaken() { AddressTaken = true; }</div>
<div><br>
</div>
<div>  /// Test whether this block must have its label emitted.</div>
<div>  bool hasLabelMustBeEmitted() const { return LabelMustBeEmitted; }</div>
<div><br>
</div>
<br>
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Diogo Sampaio via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> Tuesday, December 1, 2020 6:06 PM<br>
<b>To:</b> llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [llvm-dev] Using a MachineInstruction Address</font>
<div> </div>
</div>
<div>
<table bgcolor="#FFEB9C" border="1">
<tbody>
<tr>
<td><font face="verdana" color="black" size="1"><b>External email: Use caution opening links or attachments</b>
</font></td>
</tr>
</tbody>
</table>
<br>
<div>
<div style="font-family:arial,helvetica,sans-serif; font-size:12pt; color:#000000">
<div>
<div style="font-family:'arial' ,'helvetica' ,sans-serif; font-size:12pt; color:#000000">
<div>Hi,<br>
</div>
<div>Is there a straight-forward way to obtain an arbitrary MachineInstruction address and maintain it updated along the backend optimizations, even if it is in the middle of a MachineBasicBlock?<br>
</div>
<div>I have an instruction that takes a relative address. E.g<br>
</div>
<br>
<div>BB0:<br>
</div>
<div>     myInstruction BBN + 4*x<br>
</div>
<br>
<div>BBN:<br>
</div>
<div>     ... x instructions ...<br>
</div>
<div>     target_instruction       <<=== it points to here.<br>
</div>
<br>
<div>The issues I have are:</div>
<div>1) I only see the ability to obtain basic-block addresses/labels, and these are only updated in terminator instructions. So by change that basic block is renamed/merged the value in myInstruction gets corrupt.<br>
</div>
<div>2) Even if I set-up the instruction at the top of a basic block, eventually the BB gets merged, so just pointing to the BB label is not enough.<br>
</div>
<div><br>
</div>
<div>I do see MCSymbol, but I don't get it. It seems to be resolved during asm printing.<br>
</div>
<div><br>
</div>
<div>Thanks,<br>
</div>
<div><br>
</div>
</div>
<div style="font-family:'arial' ,'helvetica' ,sans-serif; font-size:12pt; color:#000000">
<div><br>
<div style="font-size:9pt; font-family:'arial' ,'helvetica' ,sans-serif"><span style="color:#4d4d4d; font-size:9pt"><strong>Diogo Sampaio</strong></span><br>
<span style="color:#11588f; font-size:9pt"><strong>Senior Compiler Engineer • Kalray</strong></span><br>
<span style="color:#11588f; font-size:8pt"><u>dsampaio@kalrayinc.com</u> • <a href="https://www.kalrayinc.com" rel="nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer" target="_blank" style="color:#11588f">
<u>www.kalrayinc.com</u></a></span> </div>
<div><br>
</div>
<table cellpadding="0px" border="0px">
<tbody>
<tr>
<td>
<div><a href="https://www.kalrayinc.com" rel="nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer" target="_blank"><img alt="Kalray logo" src="https://www.kalrayinc.com/IMG/png/signature_logo_kalray.png"></a>
</div>
</td>
<td>
<div style="padding-left:10px; border-left:1px solid #58585a"><span style="color:#58585a; font-size:8pt; font-family:'arial' ,'helvetica' ,sans-serif; display:block; line-height:120%">The Processor at the Heart<br>
of Intelligent Systems</span></div>
</td>
</tr>
</tbody>
</table>
<div><br>
<span style="color:#7db621; font-size:8pt; font-family:'arial' ,'helvetica' ,sans-serif"><strong>Please consider the environment before printing this e-mail.</strong></span></div>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>