1; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-sections=labels | FileCheck %s
2
3$_Z4fooTIiET_v = comdat any
4
5define dso_local i32 @_Z3barv() {
6  ret i32 0
7}
8;; Check we add SHF_LINK_ORDER for .llvm_bb_addr_map and link it with the corresponding .text sections.
9; CHECK:		.section .text._Z3barv,"ax",@progbits
10; CHECK-LABEL:	_Z3barv:
11; CHECK-NEXT:	[[BAR_BEGIN:.Lfunc_begin[0-9]+]]:
12; CHECK:		.section .llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text._Z3barv{{$}}
13; CHECK-NEXT:		.quad [[BAR_BEGIN]]
14
15
16define dso_local i32 @_Z3foov() {
17  %1 = call i32 @_Z4fooTIiET_v()
18  ret i32 %1
19}
20; CHECK:		.section .text._Z3foov,"ax",@progbits
21; CHECK-LABEL:	_Z3foov:
22; CHECK-NEXT:	[[FOO_BEGIN:.Lfunc_begin[0-9]+]]:
23; CHECK:		.section  .llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text._Z3foov{{$}}
24; CHECK-NEXT:		.quad [[FOO_BEGIN]]
25
26
27define linkonce_odr dso_local i32 @_Z4fooTIiET_v() comdat {
28  ret i32 0
29}
30;; Check we add .llvm_bb_addr_map section to a COMDAT group with the corresponding .text section if such a COMDAT exists.
31; CHECK:		.section .text._Z4fooTIiET_v,"axG",@progbits,_Z4fooTIiET_v,comdat
32; CHECK-LABEL:	_Z4fooTIiET_v:
33; CHECK-NEXT:	[[FOOCOMDAT_BEGIN:.Lfunc_begin[0-9]+]]:
34; CHECK:		.section .llvm_bb_addr_map,"Go",@llvm_bb_addr_map,_Z4fooTIiET_v,comdat,.text._Z4fooTIiET_v{{$}}
35; CHECK-NEXT:		.quad [[FOOCOMDAT_BEGIN]]
36