<div><div style="line-height:1.6;font-size:14px"><div class="" dir="auto"><span>Hi,</span></div><div class="" dir="auto"><span>I am using sample-based PGO and llvm-profgen recently and found a bug in </span><span class=" backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000">llvm-profgen</span><span>. The bug is </span><span class="grammar-check-ignore">on line</span><span> 529 of </span><span class=" fontcolor " style="color:#f54a45">main</span><span>/llvm/tools/llvm-profgen/ProfiledBinary.cpp (as shown in the figure below). The details are as follows:</span></div><div class="" dir="auto"><br></div><div class="" dir="auto"><span>I encountered </span><span class="grammar-check-ignore">such</span><span> a CallFrame whose Line is 0 and StartLine is non-zero (</span><span class=" backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000">Line and StartLine are both uint32_t</span><span>). This caused LineOffset to exceed</span><span class="grammar-check-ignore"> the</span><span> 16-bit range (checked </span><span class="grammar-check-ignore">by line</span><span> 97 of </span><span class=" fontcolor " style="color:#f54a45">main</span><span>/llvm/lib/ProfileData/SampleProfReader.cpp), and report error (error type shown </span><span class="grammar-check-ignore">on line</span><span> 301 of </span><span class=" fontcolor " style="color:#f54a45">main</span><span>/llvm/lib/ProfileData/SampleProfReader.cpp).</span></div><div class="" dir="auto"><br></div><div class="" dir="auto"><span class=" backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000">I studied the case where CallFrame.Line is equal to 0 in Spec CPU 2017-502.gcc_r. And I found that: if the assembly line related to the CallFrame is mapped to multiple source </span><span class="grammar-check-ignore backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000">line</span><span class=" backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000">, we tried to obtain the CallFrame.Line and get 0. This is because Dwarf information shows 0 for line in this case when the mapped source line can not be determined.</span></div><div class="" dir="auto"><span class="inlineStyleHolder" style="background-color:rgba(0,0,0,0);color:#000000;font-size:14px;font-weight:400">​</span></div><div class="" dir="auto"><span class=" backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000">I wonder</span><span class="grammar-check-ignore backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000"> that</span><span class=" backgroundcolor fontweight  fontsize fontcolor " style="background-color:rgba(0,0,0,0);font-weight:400;font-size:14px;color:#000000"> how to solve this error.</span></div><div class="" dir="auto"><br></div><div class="" dir="auto"><span>​</span><img style="max-width: 100%;" width="516" src="cid:R3LrRZo" class="_3mKtp"><span>​</span><span> </span></div><div class="" dir="auto"><span>Qingqing Xu</span></div></div></div>