[llvm] 5f77720 - [Tests] Add test coverage for prefix selection logic
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 16 17:27:57 PDT 2020
Author: Philip Reames
Date: 2020-03-16T17:27:44-07:00
New Revision: 5f7772004b1a6d7e88860eda2e8a4810c44e1528
URL: https://github.com/llvm/llvm-project/commit/5f7772004b1a6d7e88860eda2e8a4810c44e1528
DIFF: https://github.com/llvm/llvm-project/commit/5f7772004b1a6d7e88860eda2e8a4810c44e1528.diff
LOG: [Tests] Add test coverage for prefix selection logic
Note that I'm not asserting this code is correct; I'm simply adding coverage for what's there already. I'm reasonable sure the logic works for existing relaxable instructions, but I wouldn't be suprised if there were incorrect cases for other instructions. (i.e. is it legal to add prefixes to all instructions?)
Added:
llvm/test/MC/X86/prefix-padding-32.s
llvm/test/MC/X86/prefix-padding-64.s
Modified:
Removed:
################################################################################
diff --git a/llvm/test/MC/X86/prefix-padding-32.s b/llvm/test/MC/X86/prefix-padding-32.s
new file mode 100644
index 000000000000..b975bd5783c0
--- /dev/null
+++ b/llvm/test/MC/X86/prefix-padding-32.s
@@ -0,0 +1,50 @@
+# RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -x86-pad-max-prefix-size=15 | llvm-objdump -d --section=.text - | FileCheck %s
+
+# Check prefix padding generation for all cases on 32 bit x86.
+
+# CHECK: 1: 3e 3e 3e 3e 3e 3e 3e 3e 3e 81 e1 01 00 00 00 andl $1, %ecx
+# CHECK: 10: 3e 3e 3e 3e 3e 3e 3e 3e 3e 81 21 01 00 00 00 andl $1, %ds:(%ecx)
+# CHECK: 1f: 2e 2e 2e 2e 2e 2e 2e 2e 2e 81 21 01 00 00 00 andl $1, %cs:(%ecx)
+# CHECK: 2e: 3e 3e 3e 3e 3e 3e 3e 3e 3e 81 21 01 00 00 00 andl $1, %ds:(%ecx)
+# CHECK: 3d: 26 26 26 26 26 26 26 26 26 81 21 01 00 00 00 andl $1, %es:(%ecx)
+# CHECK: 4c: 64 64 64 64 64 64 64 64 64 81 21 01 00 00 00 andl $1, %fs:(%ecx)
+# CHECK: 5b: 65 65 65 65 65 65 65 65 65 81 21 01 00 00 00 andl $1, %gs:(%ecx)
+# CHECK: 6a: 36 36 36 36 36 36 36 36 36 81 21 01 00 00 00 andl $1, %ss:(%ecx)
+# CHECK: 79: 3e 3e 3e 3e 3e 81 a1 00 00 00 00 01 00 00 00 andl $1, %ds:(%ecx)
+# CHECK: 88: 3e 3e 3e 3e 3e 81 a1 00 00 00 00 01 00 00 00 andl $1, %ds:(%ecx)
+# CHECK: 97: 36 36 36 36 36 36 36 36 81 24 24 01 00 00 00 andl $1, %ss:(%esp)
+# CHECK: a6: 65 65 65 65 65 65 65 65 81 24 24 01 00 00 00 andl $1, %gs:(%esp)
+# CHECK: b5: 36 36 36 36 81 a4 24 00 00 00 00 01 00 00 00 andl $1, %ss:(%esp)
+# CHECK: c4: 36 36 36 36 36 36 36 36 81 65 00 01 00 00 00 andl $1, %ss:(%ebp)
+# CHECK: d3: 65 65 65 65 65 65 65 65 81 65 00 01 00 00 00 andl $1, %gs:(%ebp)
+# CHECK: e2: 36 36 36 36 36 81 a5 00 00 00 00 01 00 00 00 andl $1, %ss:(%ebp)
+ .text
+ .section .text
+ .p2align 8
+bar:
+ int3
+foo:
+ # non-memory
+ andl $foo, %ecx
+ # memory, non-esp/ebp
+ andl $foo, (%ecx)
+ andl $foo, %cs:(%ecx)
+ andl $foo, %ds:(%ecx)
+ andl $foo, %es:(%ecx)
+ andl $foo, %fs:(%ecx)
+ andl $foo, %gs:(%ecx)
+ andl $foo, %ss:(%ecx)
+ andl $foo, data16 (%ecx)
+ andl $foo, data32 (%ecx)
+ # esp w/o segment override
+ andl $foo, (%esp)
+ andl $foo, %gs:(%esp)
+ andl $foo, data32 (%esp)
+ # ebp w/o segment override
+ andl $foo, (%ebp)
+ andl $foo, %gs:(%ebp)
+ andl $foo, data32 (%ebp)
+
+ # Request enough padding to justify padding all of the above
+ .p2align 8
+ int3
diff --git a/llvm/test/MC/X86/prefix-padding-64.s b/llvm/test/MC/X86/prefix-padding-64.s
new file mode 100644
index 000000000000..fcffc772d25b
--- /dev/null
+++ b/llvm/test/MC/X86/prefix-padding-64.s
@@ -0,0 +1,53 @@
+# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=15 | llvm-objdump -d --section=.text - | FileCheck %s
+
+# Check prefix padding generation for all cases on 64 bit x86.
+
+# CHECK: 0: 2e 2e 2e 2e 2e 2e 2e 2e 48 81 e1 00 00 00 00 andq $0, %rcx
+# CHECK: f: 2e 2e 2e 2e 2e 2e 2e 2e 48 81 21 00 00 00 00 andq $0, %cs:(%rcx)
+# CHECK: 1e: 2e 2e 2e 2e 2e 2e 2e 2e 48 81 21 00 00 00 00 andq $0, %cs:(%rcx)
+# CHECK: 2d: 3e 3e 3e 3e 3e 3e 3e 3e 48 81 21 00 00 00 00 andq $0, %ds:(%rcx)
+# CHECK: 3c: 26 26 26 26 26 26 26 26 48 81 21 00 00 00 00 andq $0, %es:(%rcx)
+# CHECK: 4b: 64 64 64 64 64 64 64 64 48 81 21 00 00 00 00 andq $0, %fs:(%rcx)
+# CHECK: 5a: 65 65 65 65 65 65 65 65 48 81 21 00 00 00 00 andq $0, %gs:(%rcx)
+# CHECK: 69: 36 36 36 36 36 36 36 36 48 81 21 00 00 00 00 andq $0, %ss:(%rcx)
+# CHECK: 78: 2e 2e 2e 2e 48 81 a1 00 00 00 00 00 00 00 00 andq $0, %cs:(%rcx)
+# CHECK: 87: 2e 2e 2e 2e 48 81 a1 00 00 00 00 00 00 00 00 andq $0, %cs:(%rcx)
+# CHECK: 96: 2e 2e 2e 2e 2e 2e 2e 48 81 24 24 00 00 00 00 andq $0, %cs:(%rsp)
+# CHECK: a5: 65 65 65 65 65 65 65 48 81 24 24 00 00 00 00 andq $0, %gs:(%rsp)
+# CHECK: b4: 2e 2e 2e 48 81 a4 24 00 00 00 00 00 00 00 00 andq $0, %cs:(%rsp)
+# CHECK: c3: 2e 2e 2e 2e 2e 2e 2e 48 81 65 00 00 00 00 00 andq $0, %cs:(%rbp)
+# CHECK: d2: 65 65 65 65 65 65 65 48 81 65 00 00 00 00 00 andq $0, %gs:(%rbp)
+# CHECK: e1: 2e 2e 2e 2e 48 81 a5 00 00 00 00 00 00 00 00 andq $0, %cs:(%rbp)
+ .text
+ .section .text
+ .p2align 8
+ # non-memory
+ andq $foo, %rcx
+ # memory, non-esp/ebp
+ andq $foo, (%rcx)
+ andq $foo, %cs:(%rcx)
+ andq $foo, %ds:(%rcx)
+ andq $foo, %es:(%rcx)
+ andq $foo, %fs:(%rcx)
+ andq $foo, %gs:(%rcx)
+ andq $foo, %ss:(%rcx)
+ andq $foo, data16 (%rcx)
+ andq $foo, data32 (%rcx)
+ # esp w/o segment override
+ andq $foo, (%rsp)
+ andq $foo, %gs:(%rsp)
+ andq $foo, data32 (%rsp)
+ # ebp w/o segment override
+ andq $foo, (%rbp)
+ andq $foo, %gs:(%rbp)
+ andq $foo, data32 (%rbp)
+
+ # Request enough padding to justify padding all of the above
+ .p2align 8
+ int3
+
+ .section "other"
+bar:
+ .p2align 3
+ int3
+foo:
More information about the llvm-commits
mailing list