<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Muhui,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If the function does exist in the binary, it is entirely possible (I think) to have no instruction specifically associated
 with the function definition's source line, even though other instructions are associated with other lines in the function.  I (or someone) would need to look at a specific example before being able to say one way or the other if that is what you are running
 into.</span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">==============</span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I don't understand what "<span style="background:white">no instruction specifically associated with the function definition's source line,</span>"  this sentence mean. Could you
 please explain more? If you are interested, I am glad to give you a specific example. Please tell me whether you need it.</span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I tried a simple example like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">int f(int a, int b)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> return a + b;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">In the IR, it looks like the function definition is given as being on line 1 (the "int f" part), however in the DWARF line table the first instruction is associated
 with line 2 (the opening brace).  That's what I meant by "no instruction specifically associated with the function definition's source line"; even though the function is defined (according to C/C++) on line 1, there are no instructions for that line; the first
 instruction of the function is instead associated with the line where the scope starts.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I see that there is a different attribute in the IR metadata, called scopeLine, which is 2.  That might be what you want.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Have you considered building a static array of function addresses?  If you used weak references it would not interfere
 with optimizing away entire functions, which I mentioned above.  Or would that be too intrusive into your use case?  Apologies if this suggestion has come up before.</span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">==============</span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">To be honest, No.  Since I am using llvm IR to do the code analysis. Function start address is just a part of the whole evaluation. I would prefer to combine all the tools into
 one tool with llvm IR and dwarf debug information. Thus, I may not evaluate the  function addresses with a static table. Thank you very much</span><span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hmm. I am curious what sort of analysis would be done within the IR, while still depending on the address of the functions in the
 final object file.  The IR is long gone by the time the compiler is emitting the final instruction stream.</span></a><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hope this helps,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--paulr<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
</div>
</body>
</html>