1 ;; Test comdat functions.
2 ; RUN: opt < %s -mtriple=x86_64-linux -passes=pgo-instr-gen,instrprof -S | FileCheck %s --check-prefixes=ELF
3 ; RUN: opt < %s -mtriple=x86_64-windows -passes=pgo-instr-gen,instrprof -S | FileCheck %s --check-prefixes=COFF
5 $linkonceodr = comdat any
10 ;; profc/profd have hash suffixes. This definition doesn't have value profiling,
11 ;; so definitions with the same name in other modules must have the same CFG and
12 ;; cannot have value profiling, either. profd can be made private for ELF.
13 ; ELF: @__profc_linkonceodr.[[#]] = linkonce_odr hidden global {{.*}} comdat, align 8
14 ; ELF: @__profd_linkonceodr.[[#]] = private global {{.*}} comdat($__profc_linkonceodr.[[#]]), align 8
15 ; COFF: @__profc_linkonceodr.[[#]] = linkonce_odr hidden global {{.*}} comdat, align 8
16 ; COFF: @__profd_linkonceodr.[[#]] = linkonce_odr hidden global {{.*}} comdat, align 8
17 define linkonce_odr void @linkonceodr() comdat {
21 ;; weakodr in a comdat is not renamed. There is no guarantee that definitions in
22 ;; other modules don't have value profiling. profd should be conservatively
23 ;; non-private to prevent a caller from referencing a non-prevailing profd,
24 ;; causing a linker error.
25 ; ELF: @__profc_weakodr = weak_odr hidden global {{.*}} comdat, align 8
26 ; ELF: @__profd_weakodr = weak_odr hidden global {{.*}} comdat($__profc_weakodr), align 8
27 ; COFF: @__profc_weakodr = weak_odr hidden global {{.*}} comdat, align 8
28 ; COFF: @__profd_weakodr = weak_odr hidden global {{.*}} comdat, align 8
29 define weak_odr void @weakodr() comdat {
33 ;; weak in a comdat is not renamed. There is no guarantee that definitions in
34 ;; other modules don't have value profiling. profd should be conservatively
35 ;; non-private to prevent a caller from referencing a non-prevailing profd,
36 ;; causing a linker error.
37 ; ELF: @__profc_weak = weak hidden global {{.*}} comdat, align 8
38 ; ELF: @__profd_weak = weak hidden global {{.*}} comdat($__profc_weak), align 8
39 ; COFF: @__profc_weak = weak hidden global {{.*}} comdat, align 8
40 ; COFF: @__profd_weak = weak hidden global {{.*}} comdat, align 8
41 define weak void @weak() comdat {
45 ;; profc/profd have hash suffixes. This definition doesn't have value profiling,
46 ;; so definitions with the same name in other modules must have the same CFG and
47 ;; cannot have value profiling, either. profd can be made private for ELF.
48 ; ELF: @__profc_linkonce.[[#]] = linkonce hidden global {{.*}} comdat, align 8
49 ; ELF: @__profd_linkonce.[[#]] = private global {{.*}} comdat($__profc_linkonce.[[#]]), align 8
50 ; COFF: @__profc_linkonce.[[#]] = linkonce hidden global {{.*}} comdat, align 8
51 ; COFF: @__profd_linkonce.[[#]] = linkonce hidden global {{.*}} comdat, align 8
52 define linkonce void @linkonce() comdat {
56 ; Check that comdat aliases are hidden for all linkage types
57 ; ELF: @linkonceodr.local = linkonce_odr hidden alias void (), ptr @linkonceodr
58 ; ELF: @weakodr.local = weak_odr hidden alias void (), ptr @weakodr
59 ; ELF: @weak.local = weak hidden alias void (), ptr @weak
60 ; ELF: @linkonce.local = linkonce hidden alias void (), ptr @linkonce