1 ;; Keep __profd_foo in a nodeduplicate comdat, despite a comdat of the same name
2 ;; in a previous object file.
6 ; RUN: rm -rf %t && split-file %s %t
7 ; RUN: llvm-as %t/a.ll -o %t/a.bc
8 ; RUN: llvm-as %t/b.ll -o %t/b.bc
9 ; RUN: llvm-as %t/c.ll -o %t/c.bc
11 ; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext --plugin-opt=save-temps \
12 ; RUN: -u foo %t/a.bc --start-lib %t/b.bc --end-lib -o %t/ab
14 ; RUN: FileCheck %s --check-prefix=RESOL_AB < %t/ab.resolution.txt
15 ; RUN: llvm-readelf -x .data %t/ab | FileCheck %s --check-prefix=DATA
17 ; RESOL_AB: -r={{.*}}b.bc,__profc_foo,pl{{$}}
19 ;; .data contains a.bc:data. b.bc:data and c.bc:data are discarded.
20 ; DATA: 0x[[#%x,]] 01000000 00000000 ........
22 ;; __profc_foo from c.bc is non-prevailing and thus discarded.
23 ; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext --plugin-opt=save-temps \
24 ; RUN: -u foo -u c %t/a.bc --start-lib %t/b.bc %t/c.bc --end-lib -o %t/abc
25 ; RUN: FileCheck %s --check-prefix=RESOL_ABC < %t/abc.resolution.txt
26 ; RUN: llvm-readelf -x .data %t/abc | FileCheck %s --check-prefix=DATA
28 ; RESOL_ABC: -r={{.*}}b.bc,__profc_foo,pl{{$}}
29 ; RESOL_ABC: -r={{.*}}c.bc,__profc_foo,l{{$}}
33 ; RUN: rm -rf %t && split-file %s %t
34 ; RUN: opt --module-summary %t/a.ll -o %t/a.bc
35 ; RUN: opt --module-summary %t/b.ll -o %t/b.bc
36 ; RUN: opt --module-summary %t/c.ll -o %t/c.bc
38 ;; gold from binutils>=2.27 discards b.bc:__profc_foo even in the absence of --gc-sections.
39 ; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
40 ; RUN: -u foo %t/a.bc --start-lib %t/b.bc %t/c.bc --end-lib -o %t/abc --gc-sections
41 ; RUN: llvm-readelf -x .data %t/abc | FileCheck %s --check-prefix=DATA
44 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
45 target triple = "x86_64-unknown-linux-gnu"
47 $__profc_foo = comdat nodeduplicate
48 @__profc_foo = private global i64 1, comdat, align 8
49 @__profd_foo = private global ptr @__profc_foo, comdat($__profc_foo), align 8
54 %v = load i64, ptr @__profc_foo
56 store i64 %inc, ptr @__profc_foo
60 define void @_start() {
66 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
67 target triple = "x86_64-unknown-linux-gnu"
69 $__profc_foo = comdat nodeduplicate
70 @__profc_foo = weak hidden global i64 2, comdat, align 8
71 @__profd_foo = private global ptr @__profc_foo, comdat($__profc_foo)
73 define weak i64 @foo() {
74 %v = load i64, ptr @__profc_foo
76 store i64 %inc, ptr @__profc_foo
85 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
86 target triple = "x86_64-unknown-linux-gnu"
88 $__profc_foo = comdat nodeduplicate
89 @__profc_foo = weak hidden global i64 3, comdat, align 8
90 @__profd_foo = private global ptr @__profc_foo, comdat($__profc_foo)
92 define weak i64 @foo() {
93 %v = load i64, ptr @__profc_foo
95 store i64 %inc, ptr @__profc_foo