[llvm-branch-commits] [lld] 34e70d7 - Append ".__part." to every basic block section symbol.

Sriraman Tallam via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 23 11:40:31 PST 2020


Author: Sriraman Tallam
Date: 2020-12-23T11:35:44-08:00
New Revision: 34e70d722dfd0e73d460802e8d43d3a885d24784

URL: https://github.com/llvm/llvm-project/commit/34e70d722dfd0e73d460802e8d43d3a885d24784
DIFF: https://github.com/llvm/llvm-project/commit/34e70d722dfd0e73d460802e8d43d3a885d24784.diff

LOG: Append ".__part." to every basic block section symbol.

Every basic block section symbol created by -fbasic-block-sections will contain
".__part." to know that this symbol corresponds to a basic block fragment of
the function.

This patch solves two problems:

a) Like D89617, we want function symbols with suffixes to be properly qualified
   so that external tools like profile aggregators know exactly what this
   symbol corresponds to.
b) The current basic block naming just adds a ".N" to the symbol name where N is
   some integer. This collides with how clang creates __cxx_global_var_init.N.
   clang creates these symbol names to call constructor functions and basic
   block symbol naming should not use the same style.

Fixed all the test cases and added an extra test for __cxx_global_var_init
breakage.

Differential Revision: https://reviews.llvm.org/D93082

Added: 
    llvm/test/CodeGen/X86/basic-block-sections_2.ll

Modified: 
    clang/test/CodeGen/basic-block-sections.c
    lld/test/ELF/lto/basic-block-sections.ll
    llvm/lib/CodeGen/MachineBasicBlock.cpp
    llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.ll
    llvm/test/CodeGen/X86/basic-block-sections-clusters-branches.ll
    llvm/test/CodeGen/X86/basic-block-sections-clusters-eh.ll
    llvm/test/CodeGen/X86/basic-block-sections-clusters.ll
    llvm/test/CodeGen/X86/basic-block-sections-directjumps.ll
    llvm/test/CodeGen/X86/basic-block-sections-eh.ll
    llvm/test/CodeGen/X86/basic-block-sections-list.ll
    llvm/test/CodeGen/X86/basic-block-sections-listbb.ll
    llvm/test/CodeGen/X86/basic-block-sections-mir-parse.mir
    llvm/test/CodeGen/X86/basic-block-sections-unreachable.ll
    llvm/test/CodeGen/X86/basic-block-sections.ll
    llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll
    llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll
    llvm/test/CodeGen/X86/gcc_except_table_bb_sections.ll
    llvm/test/DebugInfo/X86/basic-block-sections_1.ll

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGen/basic-block-sections.c b/clang/test/CodeGen/basic-block-sections.c
index 805539f06f08..70cdeeebb0d3 100644
--- a/clang/test/CodeGen/basic-block-sections.c
+++ b/clang/test/CodeGen/basic-block-sections.c
@@ -31,14 +31,14 @@ int another(int a) {
 // BB_WORLD: .section .text.world,"ax", at progbits{{$}}
 // BB_WORLD: world:
 // BB_WORLD: .section .text.world,"ax", at progbits,unique
-// BB_WORLD: world.1:
+// BB_WORLD: world.__part.1:
 // BB_WORLD: .section .text.another,"ax", at progbits
 // BB_ALL: .section .text.another,"ax", at progbits,unique
-// BB_ALL: another.1:
+// BB_ALL: another.__part.1:
 // BB_LIST-NOT: .section .text.another,"ax", at progbits,unique
 // BB_LIST: another:
-// BB_LIST-NOT: another.1:
+// BB_LIST-NOT: another.__part.1:
 //
-// UNIQUE: .section .text.world.world.1,
-// UNIQUE: .section .text.another.another.1,
+// UNIQUE: .section .text.world.world.__part.1,
+// UNIQUE: .section .text.another.another.__part.1,
 // ERROR: error:  unable to load basic block sections function list: '{{[Nn]}}o such file or directory'

diff  --git a/lld/test/ELF/lto/basic-block-sections.ll b/lld/test/ELF/lto/basic-block-sections.ll
index 1f932ac50a87..35b638ac488a 100644
--- a/lld/test/ELF/lto/basic-block-sections.ll
+++ b/lld/test/ELF/lto/basic-block-sections.ll
@@ -11,12 +11,12 @@
 ; SECNAMES: Name: .text.foo {{.*}}
 
 ; SECNAMES-FULL: Name: .text.foo {{.*}}
-; SECNAMES-FULL: Name: .text.foo.foo.1 {{.*}}
-; SECNAMES-FULL: Name: .text.foo.foo.2 {{.*}}
+; SECNAMES-FULL: Name: .text.foo.foo.__part.1 {{.*}}
+; SECNAMES-FULL: Name: .text.foo.foo.__part.2 {{.*}}
 
 ; SYMS: foo
-; SYMS: foo.1
-; SYMS: foo.2
+; SYMS: foo.__part.1
+; SYMS: foo.__part.2
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"

diff  --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 0278999a8f72..14a270f994b4 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -71,7 +71,10 @@ MCSymbol *MachineBasicBlock::getSymbol() const {
       } else if (SectionID == MBBSectionID::ExceptionSectionID) {
         Suffix += ".eh";
       } else {
-        Suffix += "." + std::to_string(SectionID.Number);
+        // For symbols that represent basic block sections, we add ".__part." to
+        // allow tools like symbolizers to know that this represents a part of
+        // the original function.
+        Suffix = (Suffix + Twine(".__part.") + Twine(SectionID.Number)).str();
       }
       CachedMCSymbol = Ctx.getOrCreateSymbol(MF->getName() + Suffix);
     } else {

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.ll b/llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.ll
index aaae1cf2a942..4957916ddc99 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.ll
@@ -18,7 +18,7 @@ bb1:                                                ; preds = %entry
   ret void
 ; CHECK:         .section .text,"ax", at progbits,unique,1
 ; CHECK-NEXT:  .Ltmp0:
-; CHECK-NEXT:  foo.1
+; CHECK-NEXT:  foo.__part.1
 ; CHECK-NEXT:    callq   bar
 ;
 
@@ -27,7 +27,7 @@ bb2:                                                ; preds = %entry
   ret void
 ; CHECK:         .section .text,"ax", at progbits,unique,2
 ; CHECK-NEXT:  .Ltmp1:
-; CHECK-NEXT:  foo.2
+; CHECK-NEXT:  foo.__part.2
 ; CHECK-NEXT:    callq   baz
 }
 

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-clusters-branches.ll b/llvm/test/CodeGen/X86/basic-block-sections-clusters-branches.ll
index 914ebd0cff7a..1cf8ac17ea21 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-clusters-branches.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-clusters-branches.ll
@@ -43,23 +43,23 @@ declare i32 @baz() #1
 
 ; LINUX-SECTIONS1:	   	.section	.text.foo,"ax", at progbits
 ; LINUX-SECTIONS1-LABEL:	foo:
-; LINUX-SECTIONS1:		jne foo.1
+; LINUX-SECTIONS1:		jne foo.__part.1
 ; LINUX-SECTIONS1-NOT:		{{jne|je|jmp}}
 ; LINUX-SECTIONS1-LABEL:	# %bb.2:
 ; LINUX-SECTIONS1:		jmp foo.cold
 ; LINUX-SECTIONS1:		.section        .text.foo,"ax", at progbits,unique,1
-; LINUX-SECTIONS1-LABEL:	foo.1:
+; LINUX-SECTIONS1-LABEL:	foo.__part.1:
 ; LINUX-SECTIONS1:		jmp foo.cold
 ; LINUX-SECTIONS1:		.section        .text.split.foo,"ax", at progbits
 ; LINUX-SECTIONS1-LABEL:	foo.cold:
 
 ; LINUX-SECTIONS2:		.section        .text.foo,"ax", at progbits
 ; LINUX-SECTIONS2-LABEL:	foo:
-; LINUX-SECTIONS2:		jne foo.0
+; LINUX-SECTIONS2:		jne foo.__part.0
 ; LINUX-SECTIONS2-NOT:		{{jne|je|jmp}}
 ; LINUX-SECTIONS2-LABEL:	# %bb.2:
 ; LINUX-SECTIONS2:		jmp .LBB0_3
 ; LINUX-SECTIONS2:		.section        .text.foo,"ax", at progbits,unique,1
-; LINUX-SECTIONS2:		foo.0:
+; LINUX-SECTIONS2:		foo.__part.0:
 ; LINUX-SECTIONS2-NOT:		{{jne|je|jmp}}
 ; LINUX-SECTIONS2:		.LBB0_3:

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-clusters-eh.ll b/llvm/test/CodeGen/X86/basic-block-sections-clusters-eh.ll
index 4e80c72f1103..fe53b1290a1b 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-clusters-eh.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-clusters-eh.ll
@@ -60,7 +60,7 @@ declare i32 @__gxx_personality_v0(...)
 ; LINUX-SECTIONS1-NOT: 		.section
 ; LINUX-SECTIONS1-LABEL:	.LBB0_6:
 ; LINUX-SECTIONS1: 		.section	.text.main,"ax", at progbits,unique,1
-; LINUX-SECTIONS1-LABEL:	main.0:
+; LINUX-SECTIONS1-LABEL:	main.__part.0:
 ; LINUX-SECTIONS1:		.section	.text.eh.main,"ax", at progbits
 ; LINUX-SECTIONS1-LABEL: 	main.eh:
 ; LINUX-SECTIONS1-NOT: 		.section
@@ -79,7 +79,7 @@ declare i32 @__gxx_personality_v0(...)
 ; LINUX-SECTIONS2-NOT: 		.section
 ; LINUX-SECTIONS2-LABEL:	.LBB0_6:
 ; LINUX-SECTIONS2: 		.section	.text.main,"ax", at progbits,unique,1
-; LINUX-SECTIONS2-LABEL: 	main.0:
+; LINUX-SECTIONS2-LABEL: 	main.__part.0:
 ; LINUX-SECTIONS2-NOT: 		.section
 ; LINUX-SECTIONS2-LABEL:	.LBB0_2:
 ; LINUX-SECTIONS2-NOT: 		.section

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-clusters.ll b/llvm/test/CodeGen/X86/basic-block-sections-clusters.ll
index ce0e7589c096..c133653f9a03 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-clusters.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-clusters.ll
@@ -46,9 +46,9 @@ declare i32 @baz() #1
 ; LINUX-SECTIONS1-LABEL:	# %bb.2:
 ; LINUX-SECTIONS1-NOT:  	.LBB_END0_{{0-9}}+
 ; LINUX-SECTIONS1:		.section        .text.foo,"ax", at progbits,unique,1
-; LINUX-SECTIONS1-LABEL:	foo.1:
+; LINUX-SECTIONS1-LABEL:	foo.__part.1:
 ; LINUX-SECTIONS1-LABEL:	.LBB_END0_1:
-; LINUX-SECTIONS1-NEXT:        .size   foo.1, .LBB_END0_1-foo.1
+; LINUX-SECTIONS1-NEXT:        .size   foo.__part.1, .LBB_END0_1-foo.__part.1
 ; LINUX-SECTIONS1-NOT:  	.section
 ; LINUX-SECTIONS1:		.section        .text.split.foo,"ax", at progbits
 ; LINUX-SECTIONS1-LABEL:	foo.cold:
@@ -66,12 +66,12 @@ declare i32 @baz() #1
 ; LINUX-SECTIONS2-LABEL:	# %bb.2:
 ; LINUX-SECTIONS2-NOT:  	.LBB_END0_{{0-9}}+
 ; LINUX-SECTIONS2:		.section        .text.foo,"ax", at progbits,unique,1
-; LINUX-SECTIONS2-NEXT:		foo.0:
+; LINUX-SECTIONS2-NEXT:		foo.__part.0:
 ; LINUX-SECTIONS2-NOT:  	.LBB_END0_{{0-9}}+
 ; LINUX-SECTIONS2-NOT:  	.section
 ; LINUX-SECTIONS2-LABEL:	.LBB0_3:
 ; LINUX-SECTIONS2-LABEL:	.LBB_END0_3:
-; LINUX-SECTIONS2-NEXT:        .size   foo.0, .LBB_END0_3-foo.0
+; LINUX-SECTIONS2-NEXT:        .size   foo.__part.0, .LBB_END0_3-foo.__part.0
 ; LINUX-SECTIONS2:		.section        .text.foo,"ax", at progbits
 ; LINUX-SECTIONS2-NOT:  	.LBB_END0_{{0-9}}+
 ; LINUX-SECTIONS2-LABEL:	.Lfunc_end0:

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-directjumps.ll b/llvm/test/CodeGen/X86/basic-block-sections-directjumps.ll
index 99a64ef13031..4acaffff11d8 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-directjumps.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-directjumps.ll
@@ -29,10 +29,10 @@ declare i32 @_Z3foov() #1
 
 ; LINUX-SECTIONS: .section        .text._Z3bazb,"ax", at progbits
 ; LINUX-SECTIONS: _Z3bazb:
-; LINUX-SECTIONS: jmp _Z3bazb.1
-; LINUX-SECTIONS: .section        .text._Z3bazb._Z3bazb.1,"ax", at progbits
-; LINUX-SECTIONS: _Z3bazb.1:
-; LINUX-SECTIONS: jmp _Z3bazb.2
-; LINUX-SECTIONS: .section        .text._Z3bazb._Z3bazb.2,"ax", at progbits
-; LINUX-SECTIONS: _Z3bazb.2:
-; LINUX-SECTIONS: jmp _Z3bazb.3
+; LINUX-SECTIONS: jmp _Z3bazb.__part.1
+; LINUX-SECTIONS: .section        .text._Z3bazb._Z3bazb.__part.1,"ax", at progbits
+; LINUX-SECTIONS: _Z3bazb.__part.1:
+; LINUX-SECTIONS: jmp _Z3bazb.__part.2
+; LINUX-SECTIONS: .section        .text._Z3bazb._Z3bazb.__part.2,"ax", at progbits
+; LINUX-SECTIONS: _Z3bazb.__part.2:
+; LINUX-SECTIONS: jmp _Z3bazb.__part.3

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-eh.ll b/llvm/test/CodeGen/X86/basic-block-sections-eh.ll
index f12e0fd386a0..743ffa3ad336 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-eh.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-eh.ll
@@ -80,6 +80,6 @@ declare void @__cxa_end_catch()
 
 ;LINUX-SECTIONS: .section	.text._Z3foob,"ax", at progbits
 ;LINUX-SECTIONS: _Z3foob:
-;LINUX-SECTIONS: .section       .text._Z3foob._Z3foob.{{[0-9]+}},"ax", at progbits
-;LINUX-SECTIONS-LABEL: _Z3foob.{{[0-9]+}}:
+;LINUX-SECTIONS: .section       .text._Z3foob._Z3foob.__part.{{[0-9]+}},"ax", at progbits
+;LINUX-SECTIONS-LABEL: _Z3foob.__part.{{[0-9]+}}:
 ;LINUX-SECTIONS:        calll   __cxa_begin_catch

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-list.ll b/llvm/test/CodeGen/X86/basic-block-sections-list.ll
index 7c48628f73a8..8d788ffb1234 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-list.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-list.ll
@@ -59,14 +59,14 @@ define i32 @_Z3zipb(i1 zeroext %0) nounwind {
 
 ; LINUX-SECTIONS: .section        .text._Z3foob,"ax", at progbits
 ; LINUX-SECTIONS: _Z3foob:
-; LINUX-SECTIONS: .section        .text._Z3foob._Z3foob.1,"ax", at progbits
-; LINUX-SECTIONS: _Z3foob.1:
-; LINUX-SECTIONS: .section        .text._Z3foob._Z3foob.2,"ax", at progbits
-; LINUX-SECTIONS: _Z3foob.2:
-; LINUX-SECTIONS: .section        .text._Z3foob._Z3foob.3,"ax", at progbits
-; LINUX-SECTIONS: _Z3foob.3:
+; LINUX-SECTIONS: .section        .text._Z3foob._Z3foob.__part.1,"ax", at progbits
+; LINUX-SECTIONS: _Z3foob.__part.1:
+; LINUX-SECTIONS: .section        .text._Z3foob._Z3foob.__part.2,"ax", at progbits
+; LINUX-SECTIONS: _Z3foob.__part.2:
+; LINUX-SECTIONS: .section        .text._Z3foob._Z3foob.__part.3,"ax", at progbits
+; LINUX-SECTIONS: _Z3foob.__part.3:
 
 ; LINUX-SECTIONS: .section        .text._Z3zipb,"ax", at progbits
 ; LINUX-SECTIONS: _Z3zipb:
-; LINUX-SECTIONS-NOT: .section        .text._Z3zipb._Z3zipb.{{[0-9]+}},"ax", at progbits
-; LINUX-SECTIONS-NOT: _Z3zipb.{{[0-9]+}}:
+; LINUX-SECTIONS-NOT: .section        .text._Z3zipb._Z3zipb.__part.{{[0-9]+}},"ax", at progbits
+; LINUX-SECTIONS-NOT: _Z3zipb.__part.{{[0-9]+}}:

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-listbb.ll b/llvm/test/CodeGen/X86/basic-block-sections-listbb.ll
index 53bf56e67fe5..fd6522236987 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-listbb.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-listbb.ll
@@ -33,10 +33,10 @@ declare i32 @_Z3foov() #1
 ; LINUX-SECTIONS: .section        .text._Z3bazb,"ax", at progbits
 ; LINUX-SECTIONS: _Z3bazb:
 ; Check that the basic block with id 1 doesn't get a section.
-; LINUX-SECTIONS-NOT: .section        .text._Z3bazb._Z3bazb.{{[0-9]+}},"ax", at progbits
+; LINUX-SECTIONS-NOT: .section        .text._Z3bazb._Z3bazb.__part.{{[0-9]+}},"ax", at progbits
 ; LINUX-SECTIONS-LABEL: # %bb.1:
 ; LINUX-SECTIONS-NEXT:        callq   _Z3barv
-; LINUX-SECTIONS: .section        .text._Z3bazb.[[SECTION_LABEL:_Z3bazb.[0-9]+]],"ax", at progbits
+; LINUX-SECTIONS: .section        .text._Z3bazb.[[SECTION_LABEL:_Z3bazb.__part.[0-9]+]],"ax", at progbits
 ; LINUX-SECTIONS-NEXT: [[SECTION_LABEL]]:
 ; LINUX-SECTIONS-NEXT:        callq   _Z3foov
 ; LINUX-SECTIONS: .LBB_END0_2:

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-mir-parse.mir b/llvm/test/CodeGen/X86/basic-block-sections-mir-parse.mir
index a4219fa1509d..6a2cee05ec88 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-mir-parse.mir
+++ b/llvm/test/CodeGen/X86/basic-block-sections-mir-parse.mir
@@ -124,8 +124,8 @@ body:             |
 
 # CHECK: _Z3foob:
 # CHECK: .section	.text,"ax", at progbits,unique
-# CHECK: _Z3foob.1:
+# CHECK: _Z3foob.__part.1:
 # CHECK: .section	.text,"ax", at progbits,unique
-# CHECK: _Z3foob.2:
+# CHECK: _Z3foob.__part.2:
 # CHECK: .section	.text,"ax", at progbits,unique
-# CHECK: _Z3foob.3:
+# CHECK: _Z3foob.__part.3:

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-unreachable.ll b/llvm/test/CodeGen/X86/basic-block-sections-unreachable.ll
index 6501d7ba44ec..8c77070a0278 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-unreachable.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-unreachable.ll
@@ -14,5 +14,5 @@ default:
   unreachable
 ; CHECK-NOSECTIONS:     # %bb.2:     # %default
 ; CHECK-SECTIONS:       .section .text,"ax", at progbits,unique,2
-; CHECK-SECTIONS-NEXT:  foo.2:       # %default
+; CHECK-SECTIONS-NEXT:  foo.__part.2:       # %default
 }

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections.ll b/llvm/test/CodeGen/X86/basic-block-sections.ll
index 81bb5d5b4c91..7b93076eb434 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections.ll
@@ -28,11 +28,11 @@ declare i32 @_Z3foov() #1
 
 ; LINUX-SECTIONS: .section        .text._Z3bazb,"ax", at progbits
 ; LINUX-SECTIONS: _Z3bazb:
-; LINUX-SECTIONS: .section        .text._Z3bazb._Z3bazb.1,"ax", at progbits
-; LINUX-SECTIONS: _Z3bazb.1:
+; LINUX-SECTIONS: .section        .text._Z3bazb.[[SECTION_LABEL_1:_Z3bazb.__part.[0-9]+]],"ax", at progbits
+; LINUX-SECTIONS: [[SECTION_LABEL_1]]:
 ; LINUX-SECTIONS: .LBB_END0_1:
-; LINUX-SECTIONS-NEXT: .size   _Z3bazb.1, .LBB_END0_1-_Z3bazb.1
-; LINUX-SECTIONS: .section        .text._Z3bazb._Z3bazb.2,"ax", at progbits
-; LINUX-SECTIONS: _Z3bazb.2:
+; LINUX-SECTIONS-NEXT: .size  [[SECTION_LABEL_1]], .LBB_END0_1-[[SECTION_LABEL_1]]
+; LINUX-SECTIONS: .section        .text._Z3bazb.[[SECTION_LABEL_2:_Z3bazb.__part.[0-9]+]],"ax", at progbits
+; LINUX-SECTIONS: [[SECTION_LABEL_2]]:
 ; LINUX-SECTIONS: .LBB_END0_2:
-; LINUX-SECTIONS-NEXT: .size   _Z3bazb.2, .LBB_END0_2-_Z3bazb.2
+; LINUX-SECTIONS-NEXT: .size   [[SECTION_LABEL_2]], .LBB_END0_2-[[SECTION_LABEL_2]]

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections_2.ll b/llvm/test/CodeGen/X86/basic-block-sections_2.ll
new file mode 100644
index 000000000000..66c4c5afe729
--- /dev/null
+++ b/llvm/test/CodeGen/X86/basic-block-sections_2.ll
@@ -0,0 +1,61 @@
+; Check that the basic block sections suffix naming does not conflict with __cxx_global_var_init.N naming.
+; How to  generate this file:
+;; class A {
+;;  public:
+;;    A(bool a) { }
+;; };
+;;
+;; extern bool bar(int);
+;; A g_a(bar(5) ? bar(3) : false), g_b(true);
+;;
+;; $ clang -O1 -emit-llvm -S
+;;
+; __cxx_global_var_init has multiple basic blocks which will produce many sections.
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s
+
+; CHECK-LABEL: __cxx_global_var_init:
+; CHECK-LABEL: __cxx_global_var_init.__part.1:
+; CHECK-LABEL: __cxx_global_var_init.1:
+
+%class.A = type { i8 }
+
+$_ZN1AC2Eb = comdat any
+
+ at g_a = dso_local global %class.A zeroinitializer, align 1
+ at g_b = dso_local global %class.A zeroinitializer, align 1
+ at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_symcollision.cc, i8* null }]
+
+define internal fastcc void @__cxx_global_var_init() unnamed_addr section ".text.startup" {
+entry:
+  %call = call zeroext i1 @_Z3bari(i32 5)
+  br i1 %call, label %cond.true, label %cond.end
+
+cond.true:                                        ; preds = %entry
+  %call1 = call zeroext i1 @_Z3bari(i32 3)
+  br label %cond.end
+
+cond.end:                                         ; preds = %entry, %cond.true
+  %cond = phi i1 [ %call1, %cond.true ], [ false, %entry ]
+  call void @_ZN1AC2Eb(%class.A* nonnull @g_a, i1 zeroext %cond)
+  ret void
+}
+
+declare dso_local zeroext i1 @_Z3bari(i32) local_unnamed_addr
+
+define linkonce_odr dso_local void @_ZN1AC2Eb(%class.A* %this, i1 zeroext %a) unnamed_addr comdat align 2 {
+entry:
+  ret void
+}
+
+define internal fastcc void @__cxx_global_var_init.1() unnamed_addr  section ".text.startup" {
+entry:
+  call void @_ZN1AC2Eb(%class.A* nonnull @g_b, i1 zeroext true)
+  ret void
+}
+
+define internal void @_GLOBAL__sub_I_symcollision.cc()  section ".text.startup" {
+entry:
+  call fastcc void @__cxx_global_var_init()
+  call fastcc void @__cxx_global_var_init.1()
+  ret void
+}

diff  --git a/llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll b/llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll
index a5a6d697451f..6010c629c010 100644
--- a/llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll
+++ b/llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll
@@ -16,13 +16,13 @@
 ; SECTIONS_CFI: .cfi_def_cfa_register %rbp
 ; SECTIONS_CFI: .cfi_endproc
 
-; SECTIONS_CFI: _Z2f3b.1:
+; SECTIONS_CFI: _Z2f3b.__part.1:
 ; SECTIONS_CFI-NEXT: .cfi_startproc
 ; SECTIONS_CFI-NEXT: .cfi_def_cfa %rbp, 16
 ; SECTIONS_CFI-NEXT: .cfi_offset %rbp, -16
 ; SECTIONS_CFI: .cfi_endproc
 
-; SECTIONS_CFI: _Z2f3b.2:
+; SECTIONS_CFI: _Z2f3b.__part.2:
 ; SECTIONS_CFI-NEXT: .cfi_startproc
 ; SECTIONS_CFI-NEXT: .cfi_def_cfa %rbp, 16
 ; SECTIONS_CFI-NEXT: .cfi_offset %rbp, -16
@@ -35,12 +35,12 @@
 ; SECTIONS_NOFP_CFI: .cfi_def_cfa_offset 16
 ; SECTIONS_NOFP_CFI: .cfi_endproc
 
-; SECTIONS_NOFP_CFI: _Z2f3b.1:
+; SECTIONS_NOFP_CFI: _Z2f3b.__part.1:
 ; SECTIONS_NOFP_CFI-NEXT: .cfi_startproc
 ; SECTIONS_NOFP_CFI-NEXT: .cfi_def_cfa %rsp, 16
 ; SECTIONS_NOFP_CFI: .cfi_endproc
 
-; SECTIONS_NOFP_CFI: _Z2f3b.2:
+; SECTIONS_NOFP_CFI: _Z2f3b.__part.2:
 ; SECTIONS_NOFP_CFI-NEXT: .cfi_startproc
 ; SECTIONS_NOFP_CFI-NEXT: .cfi_def_cfa %rsp, 16
 ; SECTIONS_NOFP_CFI: .cfi_endproc

diff  --git a/llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll b/llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll
index d87ead0e864c..2b207e8ae9ef 100644
--- a/llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll
+++ b/llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll
@@ -10,7 +10,7 @@
 ; SECTIONS_CFI-NEXT: .cfi_offset [[RD:%r.+]], -32
 ; SECTIONS_CFI-NEXT: .cfi_offset [[RE:%r.+]], -24
 
-; SECTIONS_CFI:      _Z3foob.1:
+; SECTIONS_CFI:      _Z3foob.__part.1:
 ; SECTIONS_CFI:      .cfi_offset %rbp, -16
 ; SECTIONS_CFI:      .cfi_offset [[RA]], -56
 ; SECTIONS_CFI-NEXT: .cfi_offset [[RB]], -48
@@ -18,7 +18,7 @@
 ; SECTIONS_CFI-NEXT: .cfi_offset [[RD]], -32
 ; SECTIONS_CFI-NEXT: .cfi_offset [[RE]], -24
 
-; SECTIONS_CFI:      _Z3foob.2:
+; SECTIONS_CFI:      _Z3foob.__part.2:
 ; SECTIONS_CFI:      .cfi_offset %rbp, -16
 ; SECTIONS_CFI:      .cfi_offset [[RA]], -56
 ; SECTIONS_CFI-NEXT: .cfi_offset [[RB]], -48

diff  --git a/llvm/test/CodeGen/X86/gcc_except_table_bb_sections.ll b/llvm/test/CodeGen/X86/gcc_except_table_bb_sections.ll
index ce0cc55b54e3..e0aae5be7c39 100644
--- a/llvm/test/CodeGen/X86/gcc_except_table_bb_sections.ll
+++ b/llvm/test/CodeGen/X86/gcc_except_table_bb_sections.ll
@@ -27,7 +27,7 @@ define i32 @main() uwtable optsize ssp personality i8* bitcast (i32 (...)* @__gx
 
 ; CHECK-NOT:            .cfi_lsda
 
-; CHECK-LABEL:        main.1:
+; CHECK-LABEL:        main.__part.1:
 ; CHECK-NEXT:           .cfi_startproc
 
 ; CHECK-NON-PIC-NEXT:   .cfi_personality 3, __gxx_personality_v0
@@ -38,7 +38,7 @@ define i32 @main() uwtable optsize ssp personality i8* bitcast (i32 (...)* @__gx
 
 ; CHECK-NOT:            .cfi_lsda
 
-; CHECK-LABEL:        main.2:
+; CHECK-LABEL:        main.__part.2:
 ; CHECK-NEXT:           .cfi_startproc
 
 ; CHECK-NON-PIC-NEXT:   .cfi_personality 3, __gxx_personality_v0
@@ -82,12 +82,12 @@ declare i32 @__gxx_personality_v0(...)
 
 ;; Verify @LPStart encoding for NON-PIC mode.
 ; CHECK-NON-PIC-NEXT:   .byte	0                       # @LPStart Encoding = absptr
-; CHECK-NON-PIC-NEXT:   .quad	main.2
+; CHECK-NON-PIC-NEXT:   .quad	main.__part.2
 
 ;; Verify @LPStart encoding for PIC mode.
 ; CHECK-PIC-NEXT:       .byte	16                      # @LPStart Encoding = pcrel
 ; CHECK-PIC-NEXT:     [[DOT:\.Ltmp[0-9]+]]:
-; CHECK-PIC-NEXT:       .quad	main.2-[[DOT]]
+; CHECK-PIC-NEXT:       .quad	main.__part.2-[[DOT]]
 
 ;; Verify @TType encoding for NON-PIC mode.
 ; CHECK-NON-PIC-NEXT:   .byte	3                       # @TType Encoding = udata4
@@ -102,17 +102,17 @@ declare i32 @__gxx_personality_v0(...)
 ; CHECK-NEXT:         .Lcst_begin0:
 ; CHECK-NEXT:           .uleb128 .Ltmp0-.Lfunc_begin0   # >> Call Site 1 <<
 ; CHECK-NEXT:           .uleb128 .Ltmp1-.Ltmp0          #   Call between .Ltmp0 and .Ltmp1
-; CHECK-NEXT:           .uleb128 .Ltmp2-main.2          #     jumps to .Ltmp2
+; CHECK-NEXT:           .uleb128 .Ltmp2-main.__part.2          #     jumps to .Ltmp2
 ; CHECK-NEXT:           .byte	3                       #   On action: 2
 ; CHECK-NEXT:           .p2align	2
 ; CHECK-NEXT:         .Lexception1:
 
 ; CHECK-NON-PIC-NEXT:   .byte	0                       # @LPStart Encoding = absptr
-; CHECK-NON-PIC-NEXT:   .quad	main.2
+; CHECK-NON-PIC-NEXT:   .quad	main.__part.2
 
 ; CHECK-PIC-NEXT:       .byte	16                      # @LPStart Encoding = pcrel
 ; CHECK-PIC-NEXT:     [[DOT:\.Ltmp[0-9]+]]:
-; CHECK-PIC-NEXT:       .quad	main.2-[[DOT]]
+; CHECK-PIC-NEXT:       .quad	main.__part.2-[[DOT]]
 
 ; CHECK-NON-PIC-NEXT:   .byte	3                       # @TType Encoding = udata4
 
@@ -127,11 +127,11 @@ declare i32 @__gxx_personality_v0(...)
 ; CHECK-NEXT:         .Lexception2:
 
 ; CHECK-NON-PIC-NEXT:   .byte	0                       # @LPStart Encoding = absptr
-; CHECK-NON-PIC-NEXT:   .quad	main.2
+; CHECK-NON-PIC-NEXT:   .quad	main.__part.2
 
 ; CHECK-PIC-NEXT:       .byte	16                      # @LPStart Encoding = pcrel
 ; CHECK-PIC-NEXT:     [[DOT:\.Ltmp[0-9]+]]:
-; CHECK-PIC-NEXT:       .quad	main.2-[[DOT]]
+; CHECK-PIC-NEXT:       .quad	main.__part.2-[[DOT]]
 
 ; CHECK-NON-PIC-NEXT:   .byte	3                       # @TType Encoding = udata4
 
@@ -142,8 +142,8 @@ declare i32 @__gxx_personality_v0(...)
 ; CHECK-NEXT:           .byte	1                       # Call site Encoding = uleb128
 ; CHECK-NEXT:           .uleb128 .Laction_table_base0-.Lcst_begin2
 ; CHECK-NEXT:         .Lcst_begin2:
-; CHECK-NEXT:           .uleb128 main.2-main.2          # >> Call Site 2 <<
-; CHECK-NEXT:           .uleb128 .LBB_END0_2-main.2     #   Call between main.2 and .LBB_END0_2
+; CHECK-NEXT:           .uleb128 main.__part.2-main.__part.2          # >> Call Site 2 <<
+; CHECK-NEXT:           .uleb128 .LBB_END0_2-main.__part.2     #   Call between main.__part.2 and .LBB_END0_2
 ; CHECK-NEXT:           .byte	0                       #     has no landing pad
 ; CHECK-NEXT:           .byte	0                       #   On action: cleanup
 ; CHECK-NEXT:         .Laction_table_base0:

diff  --git a/llvm/test/DebugInfo/X86/basic-block-sections_1.ll b/llvm/test/DebugInfo/X86/basic-block-sections_1.ll
index 98728d5e8605..959ba6728f4e 100644
--- a/llvm/test/DebugInfo/X86/basic-block-sections_1.ll
+++ b/llvm/test/DebugInfo/X86/basic-block-sections_1.ll
@@ -16,33 +16,33 @@
 ; NO-SECTIONS: DW_AT_high_pc [DW_FORM_data4] ({{.*}})
 ; BB-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
 ; BB-SECTIONS-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
-; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.1"
-; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.2"
-; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.3"
+; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.__part.1"
+; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.__part.2"
+; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.__part.3"
 ; BB-SECTIONS-NEXT: [{{.*}}) ".text"
 ; BB-SECTIONS-ASM: _Z3fooi:
 ; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
 ; BB-SECTIONS-ASM-NEXT: .loc 1 2 9 prologue_end
 ; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
 ; BB-SECTIONS-ASM-NEXT: .loc 1 2 7 is_stmt
-; BB-SECTIONS-ASM: _Z3fooi.1:
+; BB-SECTIONS-ASM: _Z3fooi.__part.1:
 ; BB-SECTIONS-ASM: .LBB_END0_{{[0-9]+}}:
-; BB-SECTIONS-ASM: .size	_Z3fooi.1, .LBB_END0_{{[0-9]+}}-_Z3fooi.1
-; BB-SECTIONS-ASM: _Z3fooi.2:
+; BB-SECTIONS-ASM: .size	_Z3fooi.__part.1, .LBB_END0_{{[0-9]+}}-_Z3fooi.__part.1
+; BB-SECTIONS-ASM: _Z3fooi.__part.2:
 ; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
 ; BB-SECTIONS-ASM-NEXT: .LBB_END0_{{[0-9]+}}:
-; BB-SECTIONS-ASM: .size	_Z3fooi.2, .LBB_END0_{{[0-9]+}}-_Z3fooi.2
-; BB-SECTIONS-ASM: _Z3fooi.3:
+; BB-SECTIONS-ASM: .size	_Z3fooi.__part.2, .LBB_END0_{{[0-9]+}}-_Z3fooi.__part.2
+; BB-SECTIONS-ASM: _Z3fooi.__part.3:
 ; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
 ; BB-SECTIONS-ASM-NEXT: .LBB_END0_{{[0-9]+}}:
-; BB-SECTIONS-ASM: .size	_Z3fooi.3, .LBB_END0_{{[0-9]+}}-_Z3fooi.3
+; BB-SECTIONS-ASM: .size	_Z3fooi.__part.3, .LBB_END0_{{[0-9]+}}-_Z3fooi.__part.3
 ; BB-SECTIONS-ASM: .Lfunc_end0:
 ; BB-SECTIONS-ASM: .Ldebug_ranges0:
-; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.1
+; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.__part.1
 ; BB-SECTIONS-ASM-NEXT:	.quad	.LBB_END0_{{[0-9]+}}
-; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.2
+; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.__part.2
 ; BB-SECTIONS-ASM-NEXT:	.quad	.LBB_END0_{{[0-9]+}}
-; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.3
+; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.__part.3
 ; BB-SECTIONS-ASM-NEXT:	.quad	.LBB_END0_{{[0-9]+}}
 ; BB-SECTIONS-ASM-NEXT:	.quad	.Lfunc_begin0
 ; BB-SECTIONS-ASM-NEXT:	.quad	.Lfunc_end0


        


More information about the llvm-branch-commits mailing list