Add --bp-compression-sort-section=<glob>[=<layout_priority>[=<match_priority>]] to let users split input sections into multiple compression groups, run balanced partitioning independently per group, and leave out sections that are poor candidates for BP. This replaces the old coarse --bp-compression-sort with a more explicit, user-controlled one. In ELF, the glob matches input section names (.text.unlikely.cold1). In Mach-O, it matches the concatenated segment+section name (__TEXT__text). layout_priority controls group placement in the final layout. match_priority resolves conflicts when multiple globs match the same section: explicit priority beats positional matching, and among positional specs the last match wins. A CRTP hook getCompressionSubgroupKey() allows backends to further subdivide glob groups into independent BP instances. This allows Mach-O backend to separate cold functions via N_COLD_FUNC in the future. The deprecated --bp-compression-sort option keeps its existing function/data behavior by assigning sections to fixed legacy groups.
113 lines
3.4 KiB
ArmAsm
113 lines
3.4 KiB
ArmAsm
# REQUIRES: aarch64
|
|
|
|
# RUN: rm -rf %t && split-file %s %t
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/a.s -o %t/a.o
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/b.s -o %t/b.o
|
|
|
|
## Wildcard glob: all sections go to a single group
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort-section="*" \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=WILDCARD
|
|
|
|
# WILDCARD: Sections for compression: 7
|
|
# WILDCARD: Compression groups: 1
|
|
# WILDCARD: *: 7 sections
|
|
|
|
## Two globs: sections are grouped by the winning glob
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort-section="__DATA*" \
|
|
# RUN: --bp-compression-sort-section="__TEXT*" \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=TWO-GLOBS
|
|
|
|
## Deprecated --bp-compression-sort=both still works
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort=both \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=LEGACY-BOTH
|
|
|
|
## Deprecated function/data modes still use the legacy buckets.
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort=function \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=LEGACY-FUNCTION
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort=data \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=LEGACY-DATA
|
|
|
|
# TWO-GLOBS: Sections for compression: 7
|
|
# TWO-GLOBS: Compression groups: 2
|
|
# TWO-GLOBS: __DATA*: 6 sections
|
|
# TWO-GLOBS: __TEXT*: 1 sections
|
|
|
|
# LEGACY-BOTH: Sections for compression: 7
|
|
# LEGACY-BOTH: Compression groups: 2
|
|
# LEGACY-BOTH: legacy:function: 1 sections
|
|
# LEGACY-BOTH: legacy:data: 6 sections
|
|
|
|
# LEGACY-FUNCTION: Sections for compression: 1
|
|
# LEGACY-FUNCTION: Compression groups: 1
|
|
# LEGACY-FUNCTION: legacy:function: 1 sections
|
|
|
|
# LEGACY-DATA: Sections for compression: 6
|
|
# LEGACY-DATA: Compression groups: 1
|
|
# LEGACY-DATA: legacy:data: 6 sections
|
|
|
|
## Single glob matching only TEXT
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort-section="__TEXT*" \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=TEXT
|
|
|
|
# TEXT: Sections for compression: 1
|
|
# TEXT: Compression groups: 1
|
|
# TEXT: __TEXT*: 1 sections
|
|
|
|
## Exact section name glob
|
|
# RUN: %lld -arch arm64 -e _main -o %t/a.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort-section="__DATA__custom" \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=DATA
|
|
|
|
# DATA: Sections for compression: 2
|
|
# DATA: Compression groups: 1
|
|
# DATA: __DATA__custom: 2 sections
|
|
|
|
## Match priority: explicit match_priority wins
|
|
# RUN: %lld -arch arm64 -e _main -o %t/match.out %t/a.o %t/b.o \
|
|
# RUN: --bp-compression-sort-section="__DATA*" \
|
|
# RUN: --bp-compression-sort-section="__DATA__custom=0=1" \
|
|
# RUN: --verbose-bp-section-orderer 2>&1 | FileCheck %s --check-prefix=MATCH
|
|
|
|
# MATCH: Compression groups: 2
|
|
# MATCH: __DATA*: 4 sections
|
|
# MATCH: __DATA__custom: 2 sections
|
|
|
|
#--- a.s
|
|
.text
|
|
.globl _main
|
|
_main:
|
|
ret
|
|
|
|
.data
|
|
data_01:
|
|
.ascii "data_01"
|
|
data_02:
|
|
.ascii "data_02"
|
|
data_03:
|
|
.ascii "data_03"
|
|
|
|
.section __DATA,__custom
|
|
custom_06:
|
|
.ascii "custom_06"
|
|
custom_07:
|
|
.ascii "custom_07"
|
|
|
|
.bss
|
|
bss0:
|
|
.zero 10
|
|
|
|
.subsections_via_symbols
|
|
|
|
#--- b.s
|
|
.data
|
|
data_11:
|
|
.ascii "data_11"
|
|
|
|
.subsections_via_symbols
|