[llvm] 96ed1bd - [MC][test] Add some label difference tests

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 20:40:19 PDT 2023


Author: Fangrui Song
Date: 2023-06-15T20:40:14-07:00
New Revision: 96ed1bda29effd169a3c6e5eb64efe34811f27e3

URL: https://github.com/llvm/llvm-project/commit/96ed1bda29effd169a3c6e5eb64efe34811f27e3
DIFF: https://github.com/llvm/llvm-project/commit/96ed1bda29effd169a3c6e5eb64efe34811f27e3.diff

LOG: [MC][test] Add some label difference tests

Added: 
    llvm/test/MC/ELF/RISCV/subsection.s

Modified: 
    llvm/test/MC/AsmParser/assembler-expressions.s

Removed: 
    


################################################################################
diff  --git a/llvm/test/MC/AsmParser/assembler-expressions.s b/llvm/test/MC/AsmParser/assembler-expressions.s
index b70de61c5e4bf..4e3c507c9a475 100644
--- a/llvm/test/MC/AsmParser/assembler-expressions.s
+++ b/llvm/test/MC/AsmParser/assembler-expressions.s
@@ -1,14 +1,23 @@
-# RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2>&1 | FileCheck %s --check-prefix=ASM-ERR
+# RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2>&1 | FileCheck %s --check-prefix=ASM-ERR --implicit-check-not=error:
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -j .data  -s - | FileCheck %s --check-prefix=OBJDATA
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -j .text -s - | FileCheck %s --check-prefix=OBJTEXT
 .data
 
 # OBJDATA: Contents of section .data
-# OBJDATA-NEXT: 0000 aa0506ff
+# OBJDATA-NEXT: 0000 aa01aa05 06ff
+
+foo1:
+# ASM-ERR: :[[#@LINE+1]]:5: error: expected absolute expression
+.if . - foo1 == 0
+    .byte 0xaa
+.else
+    .byte 0x00
+.endif
 
 foo2:
-# ASM-ERR: [[@LINE+1]]:5: error: expected absolute expression
-.if . - foo2 == 0
+    .byte 1
+# ASM-ERR: :[[#@LINE+1]]:5: error: expected absolute expression
+.if foo2 - . == -1
     .byte 0xaa
 .else
     .byte 0x00

diff  --git a/llvm/test/MC/ELF/RISCV/subsection.s b/llvm/test/MC/ELF/RISCV/subsection.s
new file mode 100644
index 0000000000000..144b9cae8aaf8
--- /dev/null
+++ b/llvm/test/MC/ELF/RISCV/subsection.s
@@ -0,0 +1,31 @@
+# RUN: not llvm-mc -filetype=obj -triple=riscv64 -mattr=-relax %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
+# RUN: not llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
+
+a:
+  nop
+b:
+  call foo at plt
+c:
+  nop
+d:
+
+.data
+## Positive subsection numbers
+.subsection c-b
+.subsection d-b
+.subsection c-a
+
+.subsection b-a
+.subsection d-c
+
+## Negative subsection numbers
+# ERR: :[[#@LINE+1]]:14: error: subsection number -8 is not within [0,2147483647]
+.subsection b-c
+# ERR: :[[#@LINE+1]]:14: error: subsection number -12 is not within [0,2147483647]
+.subsection b-d
+# ERR: :[[#@LINE+1]]:14: error: subsection number -12 is not within [0,2147483647]
+.subsection a-c
+# ERR: :[[#@LINE+1]]:14: error: subsection number -4 is not within [0,2147483647]
+.subsection a-b
+# ERR: :[[#@LINE+1]]:14: error: subsection number -4 is not within [0,2147483647]
+.subsection c-d


        


More information about the llvm-commits mailing list