Skip to content

[X86] Set .llvmbc and .llvmcmd to exclude sections #151910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/test/CodeGen/thinlto_embed_bitcode.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
; RUN: diff %t-redo.o %t.o

; CHECK-ELF: .text PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 0
; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 E 0
; CHECK-ELF-CMD: .llvmcmd
; CHECK-ELF-NO-CMD-NOT: .llvmcmd

Expand Down
13 changes: 9 additions & 4 deletions llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,12 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
Name == getInstrProfSectionName(IPSK_covdata, Triple::ELF,
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covname, Triple::ELF,
/*AddSegmentInfo=*/false) ||
Name == ".llvmbc" || Name == ".llvmcmd")
/*AddSegmentInfo=*/false))
return SectionKind::getMetadata();

if (Name == ".llvmbc" || Name == ".llvmcmd")
return SectionKind::getExclude();

if (!Name.starts_with(".")) return K;

// Default implementation based on some magic section names.
Expand Down Expand Up @@ -1735,9 +1737,12 @@ MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
Name == getInstrProfSectionName(IPSK_covdata, Triple::COFF,
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covname, Triple::COFF,
/*AddSegmentInfo=*/false) ||
Name == ".llvmbc" || Name == ".llvmcmd")
/*AddSegmentInfo=*/false))
Kind = SectionKind::getMetadata();

if (Name == ".llvmbc" || Name == ".llvmcmd")
Kind = SectionKind::getExclude();

int Selection = 0;
unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
StringRef COMDATSymName = "";
Expand Down
6 changes: 4 additions & 2 deletions llvm/test/CodeGen/X86/embed-bitcode.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
; RUN: llvm-readobj -S %t | FileCheck %s --check-prefix=COFF

; CHECK: .text PROGBITS 0000000000000000 [[#%x,OFF:]] 000000 00 AX 0
; CHECK-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] 000004 00 0
; CHECK-NEXT: .llvmcmd PROGBITS 0000000000000000 [[#%x,OFF:]] 000005 00 0
; CHECK-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] 000004 00 E 0
; CHECK-NEXT: .llvmcmd PROGBITS 0000000000000000 [[#%x,OFF:]] 000005 00 E 0

; COFF: Name: .llvmbc (2E 6C 6C 76 6D 62 63 00)
; COFF: Characteristics [
; COFF-NEXT: IMAGE_SCN_ALIGN_1BYTES
; COFF-NEXT: IMAGE_SCN_LNK_REMOVE
; COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE
; COFF-NEXT: ]
; COFF: Name: .llvmcmd (2E 6C 6C 76 6D 63 6D 64)
; COFF: Characteristics [
; COFF-NEXT: IMAGE_SCN_ALIGN_1BYTES
; COFF-NEXT: IMAGE_SCN_LNK_REMOVE
; COFF-NEXT: IMAGE_SCN_MEM_DISCARDABLE
; COFF-NEXT: ]

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/LTO/X86/embed-bitcode.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-NOOPT

; CHECK-ELF: .text PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 0
; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 E 0

; CHECK-LL: @_start
; CHECK-LL: @foo
Expand Down