<div dir="ltr"><div><div dir="auto">No, I don't. But I’m sure it is not optimized because I can see this variable in the final binary file emitted. </div></div><div dir="auto"><br></div><div dir="auto">Do you mean if I don’t refer to this variable in the front end, then I can’t see it in the backend? (although it’s in the final binary file)</div><div dir="auto"><br></div><div>Thank you!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 19, 2019 at 3:52 PM n3v3rm03 <<a href="mailto:n3v3rm03@gmail.com">n3v3rm03@gmail.com</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><div><div dir="auto">No, I don't. But I’m sure it is not optimized because I can see this variable in the final binary file emitted. </div></div><div dir="auto"><br></div><div dir="auto">Do you mean if I don’t refer to this variable in the front end, then I can’t see it in the backend? (although it’s in the final binary file)</div><div dir="auto"><br></div><div>Thank you!<br><div class="gmail_quote"><div dir="ltr">2019年1月19日(土) 2:00 <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>>:<br></div></div></div></div><div><div><div class="gmail_quote"><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_3993582784525582615m_-1578992637024306577m_-3029430411328008854WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Do you have a use of the new variable as well?  If not, it might be optimized out between the point where you create it and your MachineFunction pass.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_3993582784525582615_m_-1578992637024306577_m_-3029430411328008854__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></a></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>n3v3rm03 via llvm-dev<br>
<b>Sent:</b> Friday, January 18, 2019 5:57 AM<br>
<b>To:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [llvm-dev] Can't find symbol from llvm backend<u></u><u></u></span></p>
</div>
</div></div></div></div><div lang="EN-US"><div class="gmail-m_3993582784525582615m_-1578992637024306577m_-3029430411328008854WordSection1"><div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi, I am new to llvm. <u></u><u></u></p>
<div>
<p class="MsoNormal">I create a global variable called "test_llvm_var" in the front end function pass like this:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">            new GlobalVariable(*m, tmp->getType(), true, llvm::GlobalValue::ExternalLinkage, tmp, "test_llvm_var");<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">where tmp is a function.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Then I tried to access this global variable in the back end MachineFunctionPass like this:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">            MCContext& MCC = MF.getContext();<br>
            MCSymbol* MCS = MCC.lookupSymbol("test_llvm_var");<br>
            if (MCS == NULL) {<br>
                errs() << ">>> MCSymbol is null\n";<br>
            }  <br>
            else {<br>
                MCS->dump();<br>
            }  <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"> (MF is a MachineFunction).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">However I always get MCS==NULL, there is no symbol called test_llvm_var in the backend.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Am I doing something wrong? What I would like to do is to modify the global variable's value from the backend pass.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Any help would be appreciated.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thank you!<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div></div>
</div>
</blockquote></div>