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
4
5$linkonceodr = comdat any
6$weakodr = comdat any
7
8;; profc/profd have hash suffixes. This definition doesn't have value profiling,
9;; so definitions with the same name in other modules must have the same CFG and
10;; cannot have value profiling, either. profd can be made private for ELF.
11; ELF:   @__profc_linkonceodr.[[#]] = linkonce_odr hidden global {{.*}} comdat, align 8
12; ELF:   @__profd_linkonceodr.[[#]] = private global {{.*}} comdat($__profc_linkonceodr.[[#]]), align 8
13; COFF:  @__profc_linkonceodr.[[#]] = linkonce_odr hidden global {{.*}} comdat, align 8
14; COFF:  @__profd_linkonceodr.[[#]] = linkonce_odr hidden global {{.*}} comdat, align 8
15define linkonce_odr void @linkonceodr() comdat {
16  ret void
17}
18
19;; weakodr in a comdat is not renamed. There is no guarantee that definitions in
20;; other modules don't have value profiling. profd should be conservatively
21;; non-private to prevent a caller from referencing a non-prevailing profd,
22;; causing a linker error.
23; ELF:   @__profc_weakodr = weak_odr hidden global {{.*}} comdat, align 8
24; ELF:   @__profd_weakodr = weak_odr hidden global {{.*}} comdat($__profc_weakodr), align 8
25; COFF:  @__profc_weakodr = weak_odr hidden global {{.*}} comdat, align 8
26; COFF:  @__profd_weakodr = weak_odr hidden global {{.*}} comdat, align 8
27define weak_odr void @weakodr() comdat {
28  ret void
29}
30