<div dir="ltr">Thanks to both for your answers!<br><br>@<span style="color:rgb(32,33,36);letter-spacing:0.2px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;white-space:nowrap">Min-Yih Hsu<br><br>Thanks for your suggestion, TBH though, the cumbersome part is not creating the .ll files with metadata from PGO. It is interpreting those statistics, which is the last step<br>I described i.e. creating the pass. I mean it's not that time-consuming, but I would assume that a lot of people would have needed loop hotness statistics in the past and</span><div><span style="color:rgb(32,33,36);letter-spacing:0.2px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;white-space:nowrap">there would be a more automatic way.</span></div><div><span style="color:rgb(32,33,36);letter-spacing:0.2px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;white-space:nowrap"><br></span></div><div><span style="color:rgb(32,33,36);letter-spacing:0.2px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;white-space:nowrap">Best,<br>Stefanos</span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Πέμ, 1 Οκτ 2020 στις 8:11 μ.μ., ο/η Min-Yih Hsu <<a href="mailto:minyihh@uci.edu">minyihh@uci.edu</a>> έγραψε:<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 style="overflow-wrap: break-word;"><br><div><br><blockquote type="cite"><div>On Sep 30, 2020, at 5:44 PM, Stefanos Baziotis via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr">Hi everybody,<br><br>I'm trying to get loop hotness data across a suite (e.g. the llvm test-suite). Ideally,<br>this would be a list that for each loop would list how many times it was entered and what<br>was its iteration count (at least the latter). The closest thing I could come up with is:<br>- clang -fprofile-instr-generate (without opts) to get a .profraw<br>- Get the .profdata<br>- Give that back to clang with -fprofile-instr-use and generate .ll<br>- I note that here we get "branch_weights" stats, so if a branch is a back-edge,<br>it basically gives us the iteration count. For example, check the bottom of this file: <a href="https://pastebin.com/ZnQqJdTN" target="_blank">https://pastebin.com/ZnQqJdTN</a> which was created with the procedure above.<br>- Then, create a custom pass that goes through every loop and gathers this "branch_weights" data.<br></div></div></div></blockquote><div>I second on this approach</div><br><blockquote type="cite"><div><div dir="ltr"><div dir="ltr"><br>I feel like this is both not very accurate and overly complicated for something that I<br>guess a lot of people probably have needed to gather in the past. Is there an easier<br>solution?<br></div></div></div></blockquote><div>I don’t think PGO-based approach is very cumbersome. And it’s a lot more accurate than pure static approach. In case you don’t know, LLVM Test Suite has native support to build different stages of PGO program by toggling some cmake variable.</div><div>If I remember correctly, here are the steps:</div><div>1. Set cmake variable TEST_SUITE_PROFILE_GENERATE=ON, TEST_SUITE_IR_PGO=ON</div><div>2. `ninja all` + `llvm-lit -sv .` to build and collect profile data</div><div>3. Modify variables in CMakeCache: TEST_SUITE_PROFILE_GENERATE=OFF, TEST_SUITE_PROFILE_USE=ON</div><div>4. ninja all</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div dir="ltr"><br>Thanks,<br>Stefanos</div></div>
_______________________________________________<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><br></div></blockquote></div><br></div></blockquote></div>