<html 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 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@等线";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Cambria;
        panose-1:2 4 5 3 5 4 6 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:宋体;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:DengXian;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=ZH-CN link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'>Hello, Stefanos,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'>Got it. Thanks for the comprehensive answer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'>Sincerely,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'>Yikun Hu<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:DengXian'><o:p> </o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='color:black'>发件人</span></b><b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>: </span></b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>Stefanos Baziotis <stefanos.baziotis@gmail.com><br></span><b><span style='color:black'>日期</span></b><b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>: </span></b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>2021</span><span style='color:black'>年</span><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>6</span><span style='color:black'>月</span><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>28</span><span style='color:black'>日</span><span style='font-family:"Calibri",sans-serif;color:black'> </span><span style='color:black'>星期一</span><span style='font-family:"Calibri",sans-serif;color:black'> </span><span style='color:black'>上午</span><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>10:30<br></span><b><span style='color:black'>收件人</span></b><b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>: </span></b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>Reixiong Hu <reixiongh@gmail.com><br></span><b><span style='color:black'>抄送</span></b><b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>: </span></b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>llvm-dev <llvm-dev@lists.llvm.org><br></span><b><span style='color:black'>主题</span></b><b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>: </span></b><span lang=EN-US style='font-family:"Calibri",sans-serif;color:black'>Re: [llvm-dev] Questions about Profile Guided Optimization (PGO)<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>Hi,<o:p></o:p></span></p><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>It kind of depends on how you define what PGO consists of. But, let's not get stuck on terminology. Basically, if you provide profiling information, then LLVM will take<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>them into account by default. If not, yes, it will use static heuristics. However, that doesn't necessarily mean that it will _estimate frequencies_ because a lot of times the code looks like this:<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>if (there is profiling information) {<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>  use a heuristic which is based on frequencies<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>} else {<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>  use a heuristic based on other things (e.g., the structure of the code)<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>}<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>i.e., the else part is not necessarily "else estimate frequencies and use the same heuristic as if there were"<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>Best,<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>Stefanos<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><div><p class=MsoNormal><span lang=EN-US>Στι</span><span lang=EN-US style='font-family:"Cambria",serif'>ς</span><span lang=EN-US> Δευ, 28 Ιουν 2021 στι</span><span lang=EN-US style='font-family:"Cambria",serif'>ς</span><span lang=EN-US> 4:30 π.μ., ο/η Reixiong Hu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> </span><span lang=EN-US style='font-family:"Cambria",serif'>έ</span><span lang=EN-US>γραψε:<o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Hello, All,<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>I am studying the optimizations adopted by LLVM, and finding PGO, which is said to be a good helper for optimization.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Since that requires to instrument and execute the object program, which may be costly for compilation and sometimes inconvenient for developers to come up with test cases, I wonder whether it is a default option for the compilation (i.e., when -O2 or -O3 is enabled)?<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>If that is the case, how LLVM generates test cases for the profiling if no tests are provided?<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>If PGO is default and there are no test cases, does LLVM estimate the profiling information, such as frequencies of bbs or calls, statically?<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Thanks for your time.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Sincerely,<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Reixiong Hu<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US>_______________________________________________<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" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></span></p></blockquote></div></div></body></html>