summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2020-12-01 09:20:34 -0800
committerRahman Lavaee <rahmanl@google.com>2020-12-01 09:21:00 -0800
commite0bf2349303f6b40e3ddd5377ea08a5c0867ece4 (patch)
treea51faeac294913fdb224142642a12f1cff387524
parent54eab293f523956bdc4b1a98b6cf5abc0bd1ef3f (diff)
downloadllvm-e0bf2349303f6b40e3ddd5377ea08a5c0867ece4.tar.gz
Let .llvm_bb_addr_map section use the same unique id as its associated .text section.
Currently, `llvm_bb_addr_map` sections are generated per section names because we use the `LinkedToSymbol` argument of getELFSection. This will cause the address map tables of functions grouped into the same section when `-function-sections=true -unique-section-names=false` which is not the intended behaviour. This patch lets the unique id of every `.text` section propagate to the associated `.llvm_bb_addr_map` section. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D92113
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp4
-rw-r--r--llvm/test/CodeGen/X86/basic-block-sections-labels.ll9
2 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 75e65e3f10f4..fbc7cf1efcdb 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -1014,7 +1014,9 @@ MCObjectFileInfo::getBBAddrMapSection(const MCSection &TextSec) const {
Flags |= ELF::SHF_GROUP;
}
+ // Use the text section's begin symbol and unique ID to create a separate
+ // .llvm_bb_addr_map section associated with every unique text section.
return Ctx->getELFSection(".llvm_bb_addr_map", ELF::SHT_LLVM_BB_ADDR_MAP,
- Flags, 0, GroupName, MCSection::NonUniqueID,
+ Flags, 0, GroupName, ElfSec.getUniqueID(),
cast<MCSymbolELF>(TextSec.getBeginSymbol()));
}
diff --git a/llvm/test/CodeGen/X86/basic-block-sections-labels.ll b/llvm/test/CodeGen/X86/basic-block-sections-labels.ll
index 026667bc32c7..8a76fef672eb 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-labels.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-labels.ll
@@ -1,5 +1,6 @@
; Check the basic block sections labels option
-; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-sections=labels | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-sections=labels | FileCheck %s --check-prefix=UNIQ
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=false -basic-block-sections=labels | FileCheck %s --check-prefix=NOUNIQ
define void @_Z3bazb(i1 zeroext) personality i32 (...)* @__gxx_personality_v0 {
br i1 %0, label %2, label %7
@@ -28,6 +29,8 @@ declare i32 @_Z3foov() #1
declare i32 @__gxx_personality_v0(...)
+; UNIQ: .section .text._Z3bazb,"ax",@progbits{{$}}
+; NOUNIQ: .section .text,"ax",@progbits,unique,1
; CHECK-LABEL: _Z3bazb:
; CHECK-LABEL: .Lfunc_begin0:
; CHECK-LABEL: .LBB_END0_0:
@@ -39,7 +42,9 @@ declare i32 @__gxx_personality_v0(...)
; CHECK-LABEL: .LBB_END0_3:
; CHECK-LABEL: .Lfunc_end0:
-; CHECK: .section .llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text
+; UNIQ: .section .llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text._Z3bazb{{$}}
+;; Verify that with -unique-section-names=false, the unique id of the text section gets assigned to the llvm_bb_addr_map section.
+; NOUNIQ: .section .llvm_bb_addr_map,"o",@llvm_bb_addr_map,.text,unique,1
; CHECK-NEXT: .quad .Lfunc_begin0
; CHECK-NEXT: .byte 4
; CHECK-NEXT: .uleb128 .Lfunc_begin0-.Lfunc_begin0