<div dir="ltr"><div>I've done some work to enable --gc-sections to work with instr profiling in <a href="https://reviews.llvm.org/D64045">https://reviews.llvm.org/D64045</a>, but I still need to write more tests before that change is ready to land.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 2, 2019 at 4:03 PM Xinliang David Li via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</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">That sounds like a good idea. Or when VP is disabled, avoid recording the function addresses.<div><br></div><div>David</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 2, 2019 at 2:53 PM Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@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">Could we use !associated metadata and SHF_LINK_ORDER to make instr profiling work with gc-sections, as has been done for ASan global metadata?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 2, 2019 at 2:35 PM Pirama Arumuga Nainar via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</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"><div>I encountered an issue when enabling code coverage for Android and would like to confirm my findings and ask for suggestions.</div><div><br></div><div>Here is my finding:</div><div><br></div><div>When -fprofile-instr-generate, an llvm_prf_data section gets created that has entries for each function in the TU. One of the entries is FunctionAddr which holds the address of the function. Underneath, it is a relocation so it gets patched with the runtime, in-memory address of the function. The whole llvm_prf_data section, or at least the FunctionAddr entry, is used only when value profiling is enabled.</div><div><br></div><div>Value profiling is disabled by default and can be enabled with `-mllvm -enable-value-profiling`.</div><div><br></div><div>My problem is below:</div><div><br></div><div>The FunctionAddr entries create references to all functions in the TU. This causes an issue with -ffunction-sections and -Wl,--gc-sections (which Android uses by default). The reference to functions causes the linker to retain all of these functions.</div><div><br></div><div>This causes build errors when enabling code coverage for Android because the build rules are written assuming --gc-sections is passed to the linker and do not specify all necessary libraries to ensure proper linking of the discarded sections.</div><div><br></div><div>Question:</div><div><br></div><div>I'm considering setting FunctionAddr to 0 if value profiling is disabled (or omitting llvm_prf_data altogether if it exists solely for value profiling). Does that sound reasonable?<br></div><div><br></div><div>Thanks,</div><div>-Pirama</div><div></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" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></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" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>