[PATCH] D49622: ELF: Make sections with KeepUnique bit eligible for ICF.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 12:21:45 PDT 2018


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.

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:

$ cat foo.c
#include <stdio.h>

void f1() {}
void f2() {}

__attribute__((weak)) void* f3() { return f1; }
__attribute__((weak)) void* f4() { return f2; }

int main() {
  printf("%p %p\n", f3(), f4());
}
$ ~/src2/llvm-project2/ra/bin/clang -ffunction-sections -fuse-ld=lld
-Wl,--icf=safe foo.c -O
$ ./a.out
0x2010e0 0x2010e0

Given those two problems I will revert my patch and try to come up with
another one.

Peter

On Mon, Jul 23, 2018 at 5:28 AM Pavel Labath <labath at google.com> wrote:

> On Mon, 23 Jul 2018 at 13:17, ben via Phabricator via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> >
> > bd1976llvm added a comment.
> >
> > Hi Peter,
> >
> > Thanks for your address significance tables work!
> >
> > Specific to this change:
> >
> > I was under the impression that the intention of --keep-unique was to
> prevent *all* folding?
>
> +1
>
> One of the uses of keep-unique that I am aware of is to implement
> various kinds of communication protocols with the debugger. E.g. the
> gdb jit interface
> <
> https://www-zeuthen.desy.de/unix/unixguide/infohtml/gdb/Declarations.html#Declarations
> >
> expects the debugger to place a breakpoint on a function with a
> predefined name. Since that function doesn't do anything when the
> debugger is not present, it is typically empty. If the linker decides
> to merge that function with another hot empty function, it can result
> in the jit breakpoint being hit more times than needed. Since
> processing a breakpoint hit takes a long time, this can make a debug
> session unusable (even if the process under debug doesn't do any kind
> of jitting).
>


-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180723/a0fe3890/attachment.html>


More information about the llvm-commits mailing list