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