<div dir="ltr">Okay, it seems reasonable to me for the gold behaviour to be considered a bug, then. So it seems like we'll need different behaviour for --keep-unique and --icf=safe.<div><br></div><div>I was also thinking more about my patch over the weekend and noticed a problem with it: it incorrectly allows ICF on sections with relocations pointing to different keep-unique sections. Here's a reproducer:</div><div><br></div><div><div>$ cat foo.c</div><div>#include <stdio.h></div><div><br></div><div>void f1() {}</div><div>void f2() {}</div><div><br></div><div>__attribute__((weak)) void* f3() { return f1; }</div><div>__attribute__((weak)) void* f4() { return f2; }</div><div><br></div><div>int main() {</div><div>  printf("%p %p\n", f3(), f4());</div><div>}</div></div><div><div>$ ~/src2/llvm-project2/ra/bin/clang -ffunction-sections -fuse-ld=lld -Wl,--icf=safe foo.c -O</div><div>$ ./a.out </div><div>0x2010e0 0x2010e0</div></div><div><br></div><div>Given those two problems I will revert my patch and try to come up with another one.</div><div><br></div><div>Peter</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 23, 2018 at 5:28 AM Pavel Labath <<a href="mailto:labath@google.com" target="_blank">labath@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 23 Jul 2018 at 13:17, ben via Phabricator via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> bd1976llvm added a comment.<br>
><br>
> Hi Peter,<br>
><br>
> Thanks for your address significance tables work!<br>
><br>
> Specific to this change:<br>
><br>
> I was under the impression that the intention of --keep-unique was to prevent *all* folding?<br>
<br>
+1<br>
<br>
One of the uses of keep-unique that I am aware of is to implement<br>
various kinds of communication protocols with the debugger. E.g. the<br>
gdb jit interface<br>
<<a href="https://www-zeuthen.desy.de/unix/unixguide/infohtml/gdb/Declarations.html#Declarations" rel="noreferrer" target="_blank">https://www-zeuthen.desy.de/unix/unixguide/infohtml/gdb/Declarations.html#Declarations</a>><br>
expects the debugger to place a breakpoint on a function with a<br>
predefined name. Since that function doesn't do anything when the<br>
debugger is not present, it is typically empty. If the linker decides<br>
to merge that function with another hot empty function, it can result<br>
in the jit breakpoint being hit more times than needed. Since<br>
processing a breakpoint hit takes a long time, this can make a debug<br>
session unusable (even if the process under debug doesn't do any kind<br>
of jitting).<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_3944002066244525336gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>