<div dir="ltr">We mainly use this for iOS, simulator should work and it should work for ObjectiveC and Swift.<div>I don't think we need <b>-fprofile-instr-generate.</b></div><div><b><br></b></div><div>We are experimenting with a new instrumentation: <a href="https://lists.llvm.org/pipermail/llvm-dev/2021-June/151086.html" target="_blank">https://lists.llvm.org/pipermail/llvm-dev/2021-June/151086.html</a> in case you are interested.</div><div>+ Ellis<br></div><div><br></div><div>Manman</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 24, 2021 at 3:12 AM Jack Chen <<a href="mailto:jacklcc@google.com" target="_blank">jacklcc@google.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 dir="ltr">Thank you Manman!<div><br></div><div>I did try the feature with a C file and it worked well. I called __llvm_profile_set_filename() and __llvm_orderfile_dump() in the C file, built it with the flags, and ran the binary on Linux. After running, a profraw.order file was generated with correct contents.</div><div><br></div><div>However, I wasn't able to make it work for my iOS app - the profraw.order file is indeed generated, but it doesn't contain valid contents.</div><div><br></div><div>The major differences between them are: (1) the iOS app is written in objective c and swift, as opposed to C and (2)  The iOS app was run on iOS simulator, and the profraw.order data was collected on iOS simulator, as opposed to on linux. </div><div><br></div><div>I wonder if you know what could be wrong? Maybe this feature isn't supported by objective c and swift, or perhaps it doesn't work on the iOS platform?</div><div><br></div><div>Thanks again! Really appreciate your help!</div><div><br></div><div>Regards,</div><div>Jack</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 24, 2021 at 5:48 AM Manman Ren <<a href="mailto:manman.ren@gmail.com" target="_blank">manman.ren@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 dir="ltr"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">I don't think I wrote a doc on this. 'compiler-rt/test/profile/instrprof-order-file.test' shows how to use it, build the app with -forder-file-instrumentation and -mllvm -orderfile-write-mapping, then run the app, use the mapping file to decode the profile.</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">The profile should be in default.profraw.order. But you can change its name via:</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">- Writes to the file with the last name given to \a *</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">- __llvm_profile_set_filename(),</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">- or if it hasn't been called, the \c LLVM_PROFILE_FILE environment variable,</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">- or if that's not set, the last name set to INSTR_PROF_PROFILE_NAME_VAR,</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">- or if that's not set,  \c "default.profraw".</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">Hope this helps!</span><br style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px">Manman</span><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 23, 2021 at 2:45 PM Manman Ren <<a href="mailto:mren@fb.com" target="_blank">mren@fb.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 lang="EN-US">
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<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" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">Manman Ren <<a href="mailto:mren@fb.com" target="_blank">mren@fb.com</a>><br>
<b>Date: </b>Thursday, September 23, 2021 at 2:20 PM<br>
<b>To: </b>Jack Chen <<a href="mailto:jacklcc@google.com" target="_blank">jacklcc@google.com</a>>, <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>Re: How to use -forder-file-instrumentation to generate order file for iOS Apps?<u></u><u></u></span></p>
</div>
<p class="MsoNormal">I don't think I wrote a doc on this. 'compiler-rt/test/profile/instrprof-order-file.test' shows how to use it, build the app with -forder-file-instrumentation and -mllvm -orderfile-write-mapping, then run the app, use the mapping file to
 decode the profile.<br>
<br>
The profile should be in default.profraw.order. But you can change its name via:<br>
<br>
- Writes to the file with the last name given to \a *<br>
- __llvm_profile_set_filename(),<br>
- or if it hasn't been called, the \c LLVM_PROFILE_FILE environment variable,<br>
- or if that's not set, the last name set to INSTR_PROF_PROFILE_NAME_VAR,<br>
- or if that's not set,  \c "default.profraw".<br>
<br>
Hope this helps!<br>
Manman<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<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" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">Jack Chen <<a href="mailto:jacklcc@google.com" target="_blank">jacklcc@google.com</a>><br>
<b>Date: </b>Thursday, September 23, 2021 at 1:05 AM<br>
<b>To: </b><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Cc: </b>Manman Ren <<a href="mailto:mren@fb.com" target="_blank">mren@fb.com</a>><br>
<b>Subject: </b>How to use -forder-file-instrumentation to generate order file for iOS Apps?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal">Hello llvm developers,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I wonder how to use the flag <b>-forder-file-instrumentation</b> for iOS Apps written in objective-C and swift?<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I enabled the flags<b> -forder-file-instrumentation -mllvm -orderfile-write-mapping</b> <b>-fprofile-instr-generate
</b>when building my iOS App, which is written in objective-C and swift. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">After running the App on the iOS simulator on my macbook, a profraw.order file is generated in the simulator's folder. However, the file doesn't contain the correct contents. It contains too few bytes, also most data blobs are 32 bits (I
 believe the right format is 64-bits MD5), and many of them are duplicated. FWIW, here are the first few bytes:<u></u><u></u></p>
</div>
</div>
<div>
<pre style="white-space:pre-wrap"><span style="color:black">00000000: 70aa cb11 0100 0000 f8ac cb11 0100 0000  p...............<u></u><u></u></span></pre>
<pre><span style="color:black">00000010: 90ab cb11 0100 0000 58aa cb11 0100 0000  ........X.......<u></u><u></u></span></pre>
<pre><span style="color:black">00000020: ffff ffff 0000 0000 0000 0000 0000 0000  ................<u></u><u></u></span></pre>
<pre><span style="color:black">00000030: 0000 0000 0000 0000 ffff ffff 0000 0000  ................<u></u><u></u></span></pre>
<pre><span style="color:black">00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................<u></u><u></u></span></pre>
<pre><span style="color:black">00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................<u></u><u></u></span></pre>
<pre><span style="color:black">00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................<u></u><u></u></span></pre>
<pre><span style="color:black">00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................<u></u><u></u></span></pre>
<pre><span style="color:black">00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................<u></u><u></u></span></pre>
</div>
<div>
<p class="MsoNormal">I wonder if the feature <b>-forder-file-instrumentation </b>is supported for iOS Apps that are written in objective-C and swift?  <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">If yes, then I wonder what's the proper steps to use it?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thank you very much for your time.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Jack<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>

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