aboutsummaryrefslogtreecommitdiff
path: root/bolt/test
diff options
context:
space:
mode:
authorMaksim Panchenko <maks@fb.com>2024-06-11 10:52:51 -0700
committerGitHub <noreply@github.com>2024-06-11 10:52:51 -0700
commit540893e43fb7a5e08deec0d951fd3c1d957f8f89 (patch)
tree3fa22fc18db248a4eed05b1385146a04893b8f30 /bolt/test
parent56f668c12b1a26e103aafe5ac37930b1895c938b (diff)
downloadllvm-540893e43fb7a5e08deec0d951fd3c1d957f8f89.zip
llvm-540893e43fb7a5e08deec0d951fd3c1d957f8f89.tar.gz
llvm-540893e43fb7a5e08deec0d951fd3c1d957f8f89.tar.bz2
[BOLT] Add auto parsing for Linux kernel .altinstructions (#95068)
.altinstructions section contains a list of structures where fields can have different sizes while other fields could be present or not depending on the kernel version. Add automatic detection of such variations and use it by default. The user can still overwrite the automatic detection with `--alt-inst-has-padlen` and `--alt-inst-feature-size` options.
Diffstat (limited to 'bolt/test')
-rw-r--r--bolt/test/X86/linux-alt-instruction.s20
1 files changed, 13 insertions, 7 deletions
diff --git a/bolt/test/X86/linux-alt-instruction.s b/bolt/test/X86/linux-alt-instruction.s
index 2cdf315..66cd33a 100644
--- a/bolt/test/X86/linux-alt-instruction.s
+++ b/bolt/test/X86/linux-alt-instruction.s
@@ -12,24 +12,30 @@
## Older kernels used to have padlen field in alt_instr. Check compatibility.
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --defsym PADLEN=1 \
-# RUN: %s -o %t.o
-# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
+# RUN: %s -o %t.padlen.o
+# RUN: %clang %cflags -nostdlib %t.padlen.o -o %t.padlen.exe \
# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
-# RUN: llvm-bolt %t.exe --print-normalized --alt-inst-has-padlen -o %t.out \
+# RUN: llvm-bolt %t.padlen.exe --print-normalized --alt-inst-has-padlen -o %t.padlen.out \
# RUN: | FileCheck %s
## Check with a larger size of "feature" field in alt_instr.
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
-# RUN: --defsym FEATURE_SIZE_4=1 %s -o %t.o
-# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
+# RUN: --defsym FEATURE_SIZE_4=1 %s -o %t.fs4.o
+# RUN: %clang %cflags -nostdlib %t.fs4.o -o %t.fs4.exe \
# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
-# RUN: llvm-bolt %t.exe --print-normalized --alt-inst-feature-size=4 -o %t.out \
+# RUN: llvm-bolt %t.fs4.exe --print-normalized --alt-inst-feature-size=4 -o %t.fs4.out \
# RUN: | FileCheck %s
## Check that out-of-bounds read is handled properly.
-# RUN: not llvm-bolt %t.exe --print-normalized --alt-inst-feature-size=2 -o %t.out
+# RUN: not llvm-bolt %t.fs4.exe --alt-inst-feature-size=2 -o %t.fs4.out
+
+## Check that BOLT automatically detects structure fields in .altinstructions.
+
+# RUN: llvm-bolt %t.exe --print-normalized -o %t.out | FileCheck %s
+# RUN: llvm-bolt %t.exe --print-normalized -o %t.padlen.out | FileCheck %s
+# RUN: llvm-bolt %t.exe --print-normalized -o %t.fs4.out | FileCheck %s
# CHECK: BOLT-INFO: Linux kernel binary detected
# CHECK: BOLT-INFO: parsed 2 alternative instruction entries