diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -612,19 +612,16 @@ Name = getSectionPrefixForGlobal(Kind); } - bool HasPrefix = false; if (const auto *F = dyn_cast(GO)) { if (Optional Prefix = F->getSectionPrefix()) { raw_svector_ostream(Name) << '.' << *Prefix; - HasPrefix = true; } } if (UniqueSectionName) { Name.push_back('.'); TM.getNameWithPrefix(Name, GO, Mang, /*MayAlwaysUsePrivate*/true); - } else if (HasPrefix) - Name.push_back('.'); + } return Name; } diff --git a/llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll b/llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll --- a/llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll +++ b/llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll @@ -7,7 +7,7 @@ entry: ret i32 1 } -; CHECK: .section .text.hot.,"ax",@progbits +; CHECK: .section .text.hot,"ax",@progbits ; CHECK: .globl hot1 ; Function Attrs: cold norecurse nounwind readnone uwtable @@ -15,7 +15,7 @@ entry: ret i32 1 } -; CHECK: .section .text.unlikely.,"ax",@progbits +; CHECK: .section .text.unlikely,"ax",@progbits ; CHECK: .globl cold1 ; Function Attrs: cold inlinehint noinline norecurse nounwind optsize readnone uwtable @@ -23,7 +23,7 @@ entry: ret i32 1 } -; CHECK: .section .text.hot.,"ax",@progbits +; CHECK: .section .text.hot,"ax",@progbits ; CHECK: .globl hot2 define dso_local i32 @normal() { @@ -38,7 +38,7 @@ entry: ret i32 1 } -; CHECK: .section .text.hot.,"ax",@progbits +; CHECK: .section .text.hot,"ax",@progbits ; CHECK: .globl hot3 ; Function Attrs: cold noinline norecurse nounwind optsize readnone uwtable @@ -46,7 +46,7 @@ entry: ret i32 1 } -; CHECK: .section .text.unlikely.,"ax",@progbits +; CHECK: .section .text.unlikely,"ax",@progbits ; CHECK: .globl cold2 ; Function Attrs: hot noinline norecurse nounwind readnone uwtable @@ -54,7 +54,7 @@ entry: ret i32 1 } -; CHECK: .section .text.hot.,"ax",@progbits +; CHECK: .section .text.hot,"ax",@progbits ; CHECK: .globl hot4 attributes #0 = { inlinehint norecurse nounwind readnone uwtable } diff --git a/llvm/test/CodeGen/X86/text-section-prefix.ll b/llvm/test/CodeGen/X86/text-section-prefix.ll --- a/llvm/test/CodeGen/X86/text-section-prefix.ll +++ b/llvm/test/CodeGen/X86/text-section-prefix.ll @@ -6,7 +6,7 @@ define void @foo1(i1 zeroext %0) nounwind !section_prefix !0 { ;; CHECK hot section name ; ELF: .section .text.hot.foo1,"ax",@progbits -; ELF-NOUNIQ: .section .text.hot.,"ax",@progbits,unique,1 +; ELF-NOUNIQ: .section .text.hot,"ax",@progbits,unique,1 ; COFF-MSVC: .section .text$hot,"xr",one_only,foo1 ; COFF-GNU: .section .text$hot$foo1,"xr",one_only,foo1 ret void @@ -15,7 +15,7 @@ define void @foo2(i1 zeroext %0) nounwind !section_prefix !1 { ;; CHECK unlikely section name ; ELF: .section .text.unlikely.foo2,"ax",@progbits -; ELF-NOUNIQ: .section .text.unlikely.,"ax",@progbits,unique,2 +; ELF-NOUNIQ: .section .text.unlikely,"ax",@progbits,unique,2 ; COFF-MSVC: .section .text$unlikely,"xr",one_only,foo2 ; COFF-GNU: .section .text$unlikely$foo2,"xr",one_only,foo2 ret void diff --git a/llvm/test/MC/AsmParser/function_hot_attr.ll b/llvm/test/MC/AsmParser/function_hot_attr.ll --- a/llvm/test/MC/AsmParser/function_hot_attr.ll +++ b/llvm/test/MC/AsmParser/function_hot_attr.ll @@ -7,7 +7,7 @@ entry: ret i32 1 } -; CHECK: .section .text.hot.,"ax",@progbits +; CHECK: .section .text.hot,"ax",@progbits ; CHECK: .globl hot4 attributes #0 = { hot noinline norecurse nounwind readnone uwtable } diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/section.ll b/llvm/test/Transforms/CodeGenPrepare/X86/section.ll --- a/llvm/test/Transforms/CodeGenPrepare/X86/section.ll +++ b/llvm/test/Transforms/CodeGenPrepare/X86/section.ll @@ -7,7 +7,7 @@ ; This tests that hot/cold functions get correct section prefix assigned ; CHECK: hot_func1{{.*}}!section_prefix ![[HOT_ID:[0-9]+]] -; ASM1: .section .text.hot.,"ax",@progbits +; ASM1: .section .text.hot,"ax",@progbits ; ASM2: .section .text.hot.hot_func1,"ax",@progbits ; The entry is hot define void @hot_func1() !prof !15 { @@ -44,7 +44,7 @@ ; not call site VP metadata (which can exist on value profiled memcpy, ; or possibly left behind after static analysis based devirtualization). ; CHECK: cold_func1{{.*}}!section_prefix ![[COLD_ID:[0-9]+]] -; ASM1: .section .text.unlikely.,"ax",@progbits +; ASM1: .section .text.unlikely,"ax",@progbits ; ASM2: .section .text.unlikely.cold_func1,"ax",@progbits define void @cold_func1() !prof !16 { call void @hot_func1(), !prof !17