[llvm] 6ca2262 - [MC][test] Improve compression.s
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 14:42:18 PST 2022
Author: Fangrui Song
Date: 2022-03-11T14:42:07-08:00
New Revision: 6ca22623c9caeae5a7fe57cf097cce387256c36f
URL: https://github.com/llvm/llvm-project/commit/6ca22623c9caeae5a7fe57cf097cce387256c36f
DIFF: https://github.com/llvm/llvm-project/commit/6ca22623c9caeae5a7fe57cf097cce387256c36f.diff
LOG: [MC][test] Improve compression.s
* Actually test compressed .debug_line for 32-bit
* Test .debug_frame can be compressed
* Test a section not named .debug_* is not compressed
Added:
Modified:
llvm/test/MC/ELF/compression.s
Removed:
################################################################################
diff --git a/llvm/test/MC/ELF/compression.s b/llvm/test/MC/ELF/compression.s
index 9bc5c0ecc699c..a4d3a003a2f2e 100644
--- a/llvm/test/MC/ELF/compression.s
+++ b/llvm/test/MC/ELF/compression.s
@@ -3,18 +3,17 @@
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple x86_64-pc-linux-gnu < %s -o %t
// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-GNU-STYLE %s
// RUN: llvm-dwarfdump -debug-str %t | FileCheck --check-prefix=STR %s
-// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple i386-pc-linux-gnu < %s \
-// RUN: | llvm-readobj --symbols - | FileCheck --check-prefix=386-SYMBOLS-GNU %s
+// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple i386-pc-linux-gnu --defsym I386=1 %s \
+// RUN: | llvm-readelf -s - | FileCheck --check-prefix=386-SYMBOLS-GNU %s
// Check zlib style
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple x86_64-pc-linux-gnu < %s -o %t
// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-ZLIB-STYLE %s
// RUN: llvm-dwarfdump -debug-str %t | FileCheck --check-prefix=STR %s
-// RUN: llvm-readobj --sections %t | FileCheck --check-prefixes=ZLIB-STYLE-FLAGS,ZLIB-STYLE-FLAGS64 %s
+// RUN: llvm-readelf --sections %t | FileCheck --check-prefixes=ZLIB-FLAGS,ZLIB-FLAGS64 %s
-// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple i386-pc-linux-gnu < %s -o %t
-// RUN: llvm-readobj --symbols -S %t \
-// RUN: | FileCheck --check-prefixes=386-SYMBOLS-ZLIB,ZLIB-STYLE-FLAGS,ZLIB-STYLE-FLAGS32 %s
+// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple i386-pc-linux-gnu --defsym I386=1 %s -o %t
+// RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=386-SYMBOLS-ZLIB,ZLIB-FLAGS,ZLIB-FLAGS32 %s
// Don't compress small sections, such as this simple debug_abbrev example
// CHECK-GNU-STYLE: Contents of section .debug_abbrev:
@@ -27,20 +26,12 @@
// Check for the 'ZLIB' file magic at the start of the section only
// CHECK-GNU-STYLE-NEXT: ZLIB
// CHECK-GNU-STYLE-NOT: ZLIB
-// FIXME: Handle compressing alignment fragments to support compressing debug_frame
-// CHECK-GNU-STYLE: Contents of section .debug_frame:
-// CHECK-GNU-STYLE-NOT: ZLIB
-// CHECK-GNU-STYLE: Contents of
+// CHECK-GNU-STYLE: Contents of section
// Decompress one valid dwarf section just to check that this roundtrips,
// we use .zdebug_str section for that
// STR: perfectly compressable data sample *****************************************
-// In x86 32 bit named symbols are used for temporary symbols in merge
-// sections, so make sure we handle symbols inside compressed sections
-// 386-SYMBOLS-GNU: Name: .zdebug_str
-// 386-SYMBOLS-GNU-NOT: }
-// 386-SYMBOLS-GNU: Section: .zdebug_str
// Now check the zlib style output:
@@ -54,28 +45,31 @@
// CHECK-ZLIB-STYLE-NOT: ZLIB
// CHECK-ZLIB-STYLE: Contents of
-// Check that debug_line section was not renamed, so it is
-// zlib-style, not zlib-gnu one. Check that SHF_COMPRESSED was set.
-// ZLIB-STYLE-FLAGS: Section {
-// ZLIB-STYLE-FLAGS: Index:
-// ZLIB-STYLE-FLAGS: Name: .debug_str
-// ZLIB-STYLE-FLAGS-NEXT: Type: SHT_PROGBITS
-// ZLIB-STYLE-FLAGS-NEXT: Flags [
-// ZLIB-STYLE-FLAGS-NEXT: SHF_COMPRESSED
-// ZLIB-STYLE-FLAGS-NEXT: SHF_MERGE
-// ZLIB-STYLE-FLAGS-NEXT: SHF_STRINGS
-// ZLIB-STYLE-FLAGS-NEXT: ]
-// ZLIB-STYLE-FLAGS-NEXT: Address:
-// ZLIB-STYLE-FLAGS-NEXT: Offset:
-// ZLIB-STYLE-FLAGS-NEXT: Size:
-// ZLIB-STYLE-FLAGS-NEXT: Link:
-// ZLIB-STYLE-FLAGS-NEXT: Info:
-// ZLIB-STYLE-FLAGS32-NEXT: AddressAlignment: 4
-// ZLIB-STYLE-FLAGS64-NEXT: AddressAlignment: 8
-
-// 386-SYMBOLS-ZLIB: Name: .debug_str
-// 386-SYMBOLS-ZLIB-NOT: }
-// 386-SYMBOLS-ZLIB: Section: .debug_str
+# ZLIB-FLAGS: .text PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 AX 0 0 4
+# ZLIB-FLAGS: .nonalloc PROGBITS [[#%x,]] [[#%x,]] 000226 00 0 0 1
+
+## Check that the large .debug_line and .debug_frame have the SHF_COMPRESSED
+## flag.
+# ZLIB-FLAGS32: .debug_line PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 4
+# ZLIB-FLAGS32: .debug_abbrev PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
+# ZLIB-FLAGS32: .debug_info PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
+# ZLIB-FLAGS32: .debug_frame PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 4
+
+# ZLIB-FLAGS64: .debug_line PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 8
+# ZLIB-FLAGS64: .debug_abbrev PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
+# ZLIB-FLAGS64: .debug_info PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
+# ZLIB-FLAGS64: .debug_frame PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 8
+
+# 386-SYMBOLS-ZLIB: Symbol table '.symtab'
+# 386-SYMBOLS-ZLIB: .debug_str
+# 386-SYMBOLS-GNU: Symbol table '.symtab'
+# 386-SYMBOLS-GNU: .zdebug_str
+
+## Don't compress a section not named .debug_*.
+ .section .nonalloc,"", at progbits
+.rept 50
+.asciz "aaaaaaaaaa"
+.endr
.section .debug_line,"", at progbits
@@ -101,20 +95,73 @@
foo:
.cfi_startproc
.file 1 "Driver.ii"
+
+.rept 3
+.ifdef I386
+ pushl %ebp
+ .cfi_def_cfa_offset 8
+ .cfi_offset %ebp, -8
+ movl %esp, %ebp
+ .cfi_def_cfa_register %ebp
+ pushl %ebx
+ pushl %edi
+ pushl %esi
+ .cfi_offset %esi, -20
+ .cfi_offset %edi, -16
+ .cfi_offset %ebx, -12
+ .loc 1 1 1 prologue_end
+ popl %esi
+ popl %edi
+ popl %ebx
+ popl %ebp
+ .cfi_def_cfa %esp, 4
+.else
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ pushq %r15
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbx
+ .cfi_offset %rbx, -56
+ .cfi_offset %r12, -48
+ .cfi_offset %r13, -40
+ .cfi_offset %r14, -32
+ .cfi_offset %r15, -24
+ .loc 1 1 1 prologue_end
+ popq %rbx
+ popq %r12
+ popq %r13
+ popq %r14
+ popq %r15
+ popq %rbp
+ .cfi_def_cfa %rsp, 8
+.endif
+.endr
+
# pad out the line table to make sure it's big enough to warrant compression
- .loc 1 2 0
+ .loc 1 2 1
+ nop
+ .loc 1 3 2
+ nop
+ .loc 1 4 1
+ nop
+ .loc 1 5 2
nop
- .loc 1 3 0
+ .loc 1 6 1
nop
- .loc 1 4 0
+ .loc 1 7 2
nop
- .loc 1 5 0
+ .loc 1 8 1
nop
- .loc 1 6 0
+ .loc 1 9 2
nop
- .loc 1 7 0
+ .loc 1 10 1
nop
- .loc 1 8 0
+ .loc 1 11 2
nop
.cfi_endproc
.cfi_sections .debug_frame
More information about the llvm-commits
mailing list