<br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 23, 2017, 12:52 PM Robinson, Paul via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_1602229529789429866WordSection1">
<p class="MsoNormal"><span style="color:#1f497d">You are describing "function inlining" which is an optimization done by LLVM. This optimization is performed on the intermediate representation (IR), not at the source level, if that's what you need to know.</span></p></div></div></blockquote></div><div><br></div><div>I think Yonggang might be looking for a refactoring/source modification, rather than an optimization, but I'm not sure.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="#0563C1" vlink="#954F72"><div class="m_1602229529789429866WordSection1"><p class="MsoNormal"><span style="color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_1602229529789429866__MailEndCompose"><span style="color:#1f497d"><u></u> <u></u></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> cfe-dev [mailto:<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Yonggang Chen via cfe-dev<br>
<b>Sent:</b> Thursday, June 22, 2017 9:03 PM<br>
<b>To:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<b>Subject:</b> [cfe-dev] how to replace function call with actual code of function body?<br>
<b>Importance:</b> High<u></u><u></u></span></p>
</div>
</div></div></div></div><div lang="EN-US" link="#0563C1" vlink="#954F72"><div class="m_1602229529789429866WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d">Hello all,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver">int main()<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver">{<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver"> auto n = 9;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver"> auto x = cacul(n);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:21.0pt;text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver">return 0;<br>
</span><span style="font-size:10.5pt;color:#0d0d0d;background:silver">}</span><span style="font-size:10.5pt;color:#0d0d0d"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver">int cacul(int x)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver">{<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver"> return x * x + 3;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver">}</span><span style="font-size:10.5pt;color:#0d0d0d"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d">Suppose I have function
<span style="background:silver">main()</span>, in which <span style="background:silver">
cacul(int x)</span> is called.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d">Now I want Clang help me do this:<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver">int main()<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver">{<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver"> auto n = 9;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver"> auto x = n * n + 3;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:21.0pt;text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d;background:silver">return 0;<br>
</span><span style="font-size:10.5pt;color:#0d0d0d;background:silver">}<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver">int cacul(int x)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver">{<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver"> return x * x + 3;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d;background:silver">}</span><span style="font-size:10.5pt;color:#0d0d0d"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d">That’s to say, remove reference to
<span style="background:silver">cacul</span>. Can Clang help me do that? If so, how to do it?<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d">Best regards<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.5pt;color:#0d0d0d">Yonggang Chen</span><span style="font-size:9.5pt;font-family:Consolas;color:#0d0d0d"><u></u><u></u></span></p>
</div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>