From 512784fb28c46c818e8714759d4b1e597d58320b Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 17 Feb 2025 10:58:15 +0000 Subject: [PATCH 01/14] [AArch64][Build Attributes] Improve testing (delete previous tests files) This commit deletes previous tests files, following commits adding new test files. --- .../aarch64-build-attributes-asm-all.s | 25 ------- .../aarch64-build-attributes-asm-bti.s | 18 ----- .../aarch64-build-attributes-asm-err-attrs.s | 70 ------------------- ...aarch64-build-attributes-asm-err-headers.s | 61 ---------------- .../aarch64-build-attributes-asm-gcs.s | 18 ----- .../aarch64-build-attributes-asm-none.s | 25 ------- ...ch64-build-attributes-asm-numerical-tags.s | 39 ----------- ...arch64-build-attributes-asm-out-of-order.s | 48 ------------- .../aarch64-build-attributes-asm-pac.s | 18 ----- ...d-attributes-asm-private-subsections-err.s | 28 -------- ...build-attributes-asm-private-subsections.s | 51 -------------- 11 files changed, 401 deletions(-) delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s delete mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s deleted file mode 100644 index acbd0101e13fa..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-all.s +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute Tag_PAuth_Platform, 1 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 1 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_attribute Tag_Feature_PAC, 1 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth -// ELF-NEXT: 0x00000010 61626900 00000101 02012300 00006165 abi.......#...ae -// ELF-NEXT: 0x00000020 6162695f 66656174 7572655f 616e645f abi_feature_and_ -// ELF-NEXT: 0x00000030 62697473 00010000 01010102 01 - - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_PAuth_Platform, 1 -.aeabi_attribute Tag_PAuth_Schema, 1 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 1 -.aeabi_attribute Tag_Feature_PAC, 1 -.aeabi_attribute Tag_Feature_GCS, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s deleted file mode 100644 index 3897fee99c3ee..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-bti.s +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_attribute Tag_Feature_GCS, 0 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu -// ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000001 re_and_bits..... -// ELF-NEXT: 0x00000020 01000200 - - -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 1 -.aeabi_attribute Tag_Feature_PAC, 0 -.aeabi_attribute Tag_Feature_GCS, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s deleted file mode 100644 index ddf8feb9428d2..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-attrs.s +++ /dev/null @@ -1,70 +0,0 @@ -// RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s - -.aeabi_attribute Tag_Feature_BTI, 1 -// ERR: error: no active subsection, build attribute can not be added -// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_Feature_BTI, 1 -// ERR: error: unknown AArch64 build attribute 'Tag_Feature_BTI' for subsection 'aeabi_pauthabi' -// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 - -.aeabi_attribute Tag_PAuth_Platform, 4 -// ERR: error: unknown AArch64 build attributes Value for Tag 'Tag_PAuth_Platform' options are 0|1 -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, 4 - -.aeabi_attribute a, 1 -// ERR: error: unknown AArch64 build attribute 'a' for subsection 'aeabi_pauthabi' -// ERR-NEXT: .aeabi_attribute a, 1 - -.aeabi_attribute Tag_PAuth_Platform, Tag_PAuth_Platform -// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, Tag_PAuth_Platform - -.aeabi_attribute Tag_PAuth_Platform, a -// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, a - -.aeabi_attribute Tag_PAuth_Platform, -// ERR: error: AArch64 build attributes value not found -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, - -.aeabi_attribute Tag_PAuth_Platform -// ERR: error: expected comma -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform - -.aeabi_attribute -// ERR: error: AArch64 build attributes tag not found -// ERR-NEXT: .aeabi_attribute - -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_PAuth_Platform, 1 -// ERR: unknown AArch64 build attribute 'Tag_PAuth_Platform' for subsection 'aeabi_feature_and_bits' - -.aeabi_attribute a, 1 -// ERR: error: unknown AArch64 build attribute 'a' for subsection 'aeabi_feature_and_bits' - -.aeabi_attribute Tag_Feature_BTI, Tag_Feature_BTI -// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) -// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, Tag_Feature_BTI - -.aeabi_attribute Tag_Feature_BTI, a -// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) -// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, a - -.aeabi_attribute Tag_Feature_BTI, -// ERR: error: AArch64 build attributes value not found -// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, - -.aeabi_attribute Tag_Feature_BTI -// ERR: error: expected comma -// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI - -.aeabi_attribute -// ERR: error: AArch64 build attributes tag not found -// ERR-NEXT: .aeabi_attribute - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_PAuth_Platform, 1 some_text -// ERR: error: unexpected token for AArch64 build attributes tag and value attribute directive -// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, 1 some_text diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s deleted file mode 100644 index 9e6dca341e9f8..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-err-headers.s +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s - -.aeabi_subsection aeabi_pauthabi, optional, uleb128 -// ERR: error: aeabi_pauthabi must be marked as required -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, optional, uleb128 - -.aeabi_subsection aeabi_pauthabi, required, ntbs -// ERR: error: aeabi_pauthabi must be marked as ULEB128 -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, ntbs - -.aeabi_subsection aeabi_feature_and_bits, required, uleb128 -// ERR: error: aeabi_feature_and_bits must be marked as optional -// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, required, uleb128 - -.aeabi_subsection aeabi_feature_and_bits, optional, ntbs -// ERR: error: aeabi_feature_and_bits must be marked as ULEB128 -// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, optional, ntbs - -.aeabi_subsection 1, required, uleb128 -// ERR: error: subsection name not found -// ERR-NEXT: .aeabi_subsection 1, required, uleb128 - -.aeabi_subsection , required, uleb128 -// ERR: error: subsection name not found -// ERR-NEXT: .aeabi_subsection , required, uleb128 - -.aeabi_subsection aeabi_pauthabi, a, uleb128 -// ERR: error: unknown AArch64 build attributes optionality, expected required|optional: a -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, a, uleb128 - -.aeabi_subsection aeabi_pauthabi, a, uleb128 -// ERR: error: unknown AArch64 build attributes optionality, expected required|optional: a -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, a, uleb128 - -.aeabi_subsection aeabi_pauthabi, 1, uleb128 -// ERR: error: optionality parameter not found, expected required|optional -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, 1, uleb128 - -.aeabi_subsection aeabi_pauthabi, ,uleb128 -// ERR: error: optionality parameter not found, expected required|optional -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, ,uleb128 - -.aeabi_subsection aeabi_pauthabi,uleb128 -// ERR: error: unknown AArch64 build attributes optionality, expected required|optional: uleb128 -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi,uleb128 - -.aeabi_subsection aeabi_pauthabi uleb128 -// ERR: expected comma -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi uleb128 - -.aeabi_subsection aeabi_pauthabi, required -// ERR: error: expected comma -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required - -.aeabi_subsection aeabi_pauthabi, required, -// ERR: error: type parameter not found, expected uleb128|ntbs -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, - -.aeabi_subsection aeabi_pauthabi, required, a -// ERR: error: unknown AArch64 build attributes type, expected uleb128|ntbs: a -// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, a diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s deleted file mode 100644 index 5cb7e6835e5c1..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-gcs.s +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 0 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu -// ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000000 re_and_bits..... -// ELF-NEXT: 0x00000020 01000201 - - -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 0 -.aeabi_attribute Tag_Feature_PAC, 0 -.aeabi_attribute Tag_Feature_GCS, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s deleted file mode 100644 index a3cbbe270dffe..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-none.s +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute Tag_PAuth_Platform, 0 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 0 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 0 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_attribute Tag_Feature_GCS, 0 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth -// ELF-NEXT: 0x00000010 61626900 00000100 02002300 00006165 abi.......#...ae -// ELF-NEXT: 0x00000020 6162695f 66656174 7572655f 616e645f abi_feature_and_ -// ELF-NEXT: 0x00000030 62697473 00010000 00010002 00 - - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_PAuth_Platform, 0 -.aeabi_attribute Tag_PAuth_Schema, 0 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 0 -.aeabi_attribute Tag_Feature_PAC, 0 -.aeabi_attribute Tag_Feature_GCS, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s deleted file mode 100644 index 047939d2efd6c..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-numerical-tags.s +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM - -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 0, 1 -// ASM: .aeabi_attribute Tag_PAuth_Platform, 1 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 1 -// ASM: .aeabi_attribute 3, 1 -// ASM: .aeabi_attribute 4, 1 -// ASM: .aeabi_attribute 5, 1 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_attribute Tag_Feature_PAC, 1 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 -// ASM: .aeabi_attribute 3, 1 -// ASM: .aeabi_attribute 4, 1 -// ASM: .aeabi_attribute 5, 1 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41210000 00616561 62695f70 61757468 A!...aeabi_pauth -// ELF-NEXT: 0x00000010 61626900 00000001 01010201 03010401 abi............. -// ELF-NEXT: 0x00000020 05012900 00006165 6162695f 66656174 ..)...aeabi_feat -// ELF-NEXT: 0x00000030 7572655f 616e645f 62697473 00010000 ure_and_bits.... -// ELF-NEXT: 0x00000040 01010102 01030104 010501 - - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute 0, 1 -.aeabi_attribute 1, 1 -.aeabi_attribute 2, 1 -.aeabi_attribute 3, 1 -.aeabi_attribute 4, 1 -.aeabi_attribute 5, 1 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute 0, 1 -.aeabi_attribute 1, 1 -.aeabi_attribute 2, 1 -.aeabi_attribute 3, 1 -.aeabi_attribute 4, 1 -.aeabi_attribute 5, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s deleted file mode 100644 index 2d5d42561aa6f..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-out-of-order.s +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 1 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute Tag_PAuth_Schema, 1 -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute Tag_PAuth_Platform, 1 -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_GCS, 1 -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_PAC, 0 -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 7, 1 -// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 7, 0 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 411b0000 00616561 62695f70 61757468 A....aeabi_pauth -// ELF-NEXT: 0x00000010 61626900 00000201 01010700 25000000 abi.........%... -// ELF-NEXT: 0x00000020 61656162 695f6665 61747572 655f616e aeabi_feature_an -// ELF-NEXT: 0x00000030 645f6269 74730001 00000102 01010007 d_bits.......... -// ELF-NEXT: 0x00000040 01 - - -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 1 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_PAuth_Schema, 1 -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute Tag_PAuth_Platform, 1 -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_GCS, 1 -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_PAC, 0 -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute 7, 1 -.aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute 7, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s deleted file mode 100644 index e3191acf31141..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-pac.s +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute Tag_Feature_BTI, 0 -// ASM: .aeabi_attribute Tag_Feature_PAC, 1 -// ASM: .aeabi_attribute Tag_Feature_GCS, 0 - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu -// ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000000 re_and_bits..... -// ELF-NEXT: 0x00000020 01010200 - - -.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute Tag_Feature_BTI, 0 -.aeabi_attribute Tag_Feature_PAC, 1 -.aeabi_attribute Tag_Feature_GCS, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s deleted file mode 100644 index 5884a74f989cc..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections-err.s +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s - -.aeabi_subsection private_subsection, optional, uleb128 - -.aeabi_subsection private_subsection, required, uleb128 -// ERR: error: optionality mismatch! subsection 'private_subsection' already exists with optionality defined as 'optional' and not 'required' -// ERR-NEXT: .aeabi_subsection private_subsection, required, uleb128 - -.aeabi_subsection private_subsection, optional, ntbs -// ERR: error: type mismatch! subsection 'private_subsection' already exists with type defined as 'uleb128' and not 'ntbs' -// ERR-NEXT: .aeabi_subsection private_subsection, optional, ntbs - -.aeabi_subsection private_subsection_1, optional, ntbs -.aeabi_attribute 324, 1 -// ERR: error: active subsection type is NTBS (string), found ULEB128 (unsigned) -// ERR-NEXT: .aeabi_attribute 324, 1 - -.aeabi_subsection foo, optional, uleb128 -.aeabi_subsection bar, optional, uleb128 -.aeabi_subsection foo, required, uleb128 -// ERR: error: optionality mismatch! subsection 'foo' already exists with optionality defined as 'optional' and not 'required' -// ERR-NEXT: .aeabi_subsection foo, required, uleb128 - -.aeabi_subsection goo, optional, ntbs -.aeabi_subsection zar, optional, ntbs -.aeabi_subsection goo, optional, uleb128 -// ERR: error: type mismatch! subsection 'goo' already exists with type defined as 'ntbs' and not 'uleb128' -// ERR-NEXT: .aeabi_subsection goo, optional, uleb128 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s deleted file mode 100644 index 229033a9f6b70..0000000000000 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-private-subsections.s +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF - -// ASM: .aeabi_subsection private_subsection_1, optional, uleb128 -// ASM: .aeabi_attribute 12, 257 -// ASM: .aeabi_subsection private_subsection_2, required, uleb128 -// ASM: .aeabi_attribute 76, 257 -// ASM: .aeabi_subsection private_subsection_3, optional, ntbs -// ASM: .aeabi_attribute 34, hello_llvm -// ASM: .aeabi_subsection private_subsection_4, required, ntbs -// ASM: .aeabi_attribute 777, "hello_llvm" -// ASM: .aeabi_subsection private_subsection_1, optional, uleb128 -// ASM: .aeabi_attribute 876, 257 -// ASM: .aeabi_subsection private_subsection_2, required, uleb128 -// ASM: .aeabi_attribute 876, 257 -// ASM: .aeabi_subsection private_subsection_3, optional, ntbs -// ASM: .aeabi_attribute 876, "hello_llvm" -// ASM: .aeabi_subsection private_subsection_4, required, ntbs -// ASM: .aeabi_attribute 876, hello_llvm - -// ELF: Hex dump of section '.ARM.attributes': -// ELF-NEXT: 0x00000000 41220000 00707269 76617465 5f737562 A"...private_sub -// ELF-NEXT: 0x00000010 73656374 696f6e5f 31000100 0c8102ec section_1....... -// ELF-NEXT: 0x00000020 06810222 00000070 72697661 74655f73 ..."...private_s -// ELF-NEXT: 0x00000030 75627365 6374696f 6e5f3200 00004c81 ubsection_2...L. -// ELF-NEXT: 0x00000040 02ec0681 02360000 00707269 76617465 .....6...private -// ELF-NEXT: 0x00000050 5f737562 73656374 696f6e5f 33000101 _subsection_3... -// ELF-NEXT: 0x00000060 2268656c 6c6f5f6c 6c766d00 ec062268 "hello_llvm..."h -// ELF-NEXT: 0x00000070 656c6c6f 5f6c6c76 6d220037 00000070 ello_llvm".7...p -// ELF-NEXT: 0x00000080 72697661 74655f73 75627365 6374696f rivate_subsectio -// ELF-NEXT: 0x00000090 6e5f3400 00018906 2268656c 6c6f5f6c n_4....."hello_l -// ELF-NEXT: 0x000000a0 6c766d22 00ec0668 656c6c6f 5f6c6c76 lvm"...hello_llv -// ELF-NEXT: 0x000000b0 6d00 m. - - -.aeabi_subsection private_subsection_1, optional, uleb128 -.aeabi_attribute 12, 257 -.aeabi_subsection private_subsection_2, required, uleb128 -.aeabi_attribute 76, 257 -.aeabi_subsection private_subsection_3, optional, ntbs -.aeabi_attribute 34, hello_llvm -.aeabi_subsection private_subsection_4, required, ntbs -.aeabi_attribute 777, "hello_llvm" -.aeabi_subsection private_subsection_1, optional, uleb128 -.aeabi_attribute 876, 257 -.aeabi_subsection private_subsection_2, required, uleb128 -.aeabi_attribute 876, 257 -.aeabi_subsection private_subsection_3, optional, ntbs -.aeabi_attribute 876, "hello_llvm" -.aeabi_subsection private_subsection_4, required, ntbs -.aeabi_attribute 876, hello_llvm From 506aad316c39dc5e196b66c4df892f084a91155c Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 17 Feb 2025 11:00:57 +0000 Subject: [PATCH 02/14] [AArch64][Build Attributes] Standardize parsing error messages Parsing error message should not print the symbol triggering error. (Only point to it with the symbol '^') --- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 335b46b76688f..283c090ac4c1c 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -7870,8 +7870,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { IsOptional = AArch64BuildAttrs::getOptionalID(Optionality); if (AArch64BuildAttrs::OPTIONAL_NOT_FOUND == IsOptional) { Error(Parser.getTok().getLoc(), - AArch64BuildAttrs::getSubsectionOptionalUnknownError() + ": " + - Optionality); + AArch64BuildAttrs::getSubsectionOptionalUnknownError()); return true; } if (SubsectionExists) { @@ -7919,7 +7918,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { Type = AArch64BuildAttrs::getTypeID(Name); if (AArch64BuildAttrs::TYPE_NOT_FOUND == Type) { Error(Parser.getTok().getLoc(), - AArch64BuildAttrs::getSubsectionTypeUnknownError() + ": " + Name); + AArch64BuildAttrs::getSubsectionTypeUnknownError()); return true; } if (SubsectionExists) { From 1fb501d18ce1ed4e9fa6206696ab6b8dcad9a50a Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 17 Feb 2025 11:09:12 +0000 Subject: [PATCH 03/14] [AArch64][Build Attributes] Print Tags as Numbers with Comments Print Tags as numbers followed by comments instead of using string representations. For example: .aeabi_attribute 0, 1 @ Tag_Feature_BTI instead of: .aeabi_attribute Tag_Feature_BTI, 1 This reduces dependencies between compiler and assembler versions. --- .../Target/AArch64/AsmParser/AArch64AsmParser.cpp | 15 ++++++++++++--- .../AArch64/MCTargetDesc/AArch64ELFStreamer.cpp | 8 ++++---- .../AArch64/aarch64-build-attributes-all.ll | 6 +++--- .../AArch64/aarch64-build-attributes-bti.ll | 6 +++--- .../AArch64/aarch64-build-attributes-gcs.ll | 6 +++--- .../AArch64/aarch64-build-attributes-pac.ll | 6 +++--- .../AArch64/aarch64-build-attributes-pauthabi.ll | 4 ++-- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 283c090ac4c1c..58bebdf1f75ce 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -7947,7 +7947,12 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { } } Parser.Lex(); - // Parsing finished, check for trailing tokens. + + // Parsing finished, hereafter only accept comments; otherwise no trailing + // tokens. + if (Parser.getTok().is(llvm::AsmToken::At)) { + Parser.parseStringToEndOfStatement(); + } if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build " "attributes subsection header directive"); @@ -8070,7 +8075,12 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } } Parser.Lex(); - // Parsing finished, check for trailing tokens. + + // Parsing finished, hereafter only accept comments; otherwise no trailing + // tokens. + if (Parser.getTok().is(llvm::AsmToken::At)) { + Parser.parseStringToEndOfStatement(); + } if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build attributes tag and value " @@ -8082,7 +8092,6 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, "", false); } - if ("" != ValueStr) { getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, unsigned(-1), ValueStr, false); diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 6b5c5f36cbd4b..2f6a5144a82b4 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -191,8 +191,8 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { case AArch64BuildAttrs::TAG_FEATURE_BTI: case AArch64BuildAttrs::TAG_FEATURE_GCS: case AArch64BuildAttrs::TAG_FEATURE_PAC: - OS << "\t.aeabi_attribute" << "\t" - << AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag) << ", " << Value; + OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t@ " + << AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag); AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override); break; @@ -210,8 +210,8 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { break; case AArch64BuildAttrs::TAG_PAUTH_PLATFORM: case AArch64BuildAttrs::TAG_PAUTH_SCHEMA: - OS << "\t.aeabi_attribute" << "\t" - << AArch64BuildAttrs::getPauthABITagsStr(Tag) << ", " << Value; + OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t@ " + << AArch64BuildAttrs::getPauthABITagsStr(Tag); AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override); break; diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll index aecc74b2ce46d..9eaed09130f15 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1 +; ASM-NEXT: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 1 @ Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll index 8ec78df13be28..cffb1fb265379 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 0 +; ASM-NEXT: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 0 @ Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll index be528779e8228..3dbba6a7eeace 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1 +; ASM-NEXT: .aeabi_attribute 0, 0 @ Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 1 @ Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll index e3e5933105426..506a821ad9d90 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 0 -; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1 -; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 0 +; ASM-NEXT: .aeabi_attribute 0, 0 @ Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 0 @ Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll index 35ad514c943a5..a7d9585af4379 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll @@ -2,8 +2,8 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -; ASM-NEXT: .aeabi_attribute Tag_PAuth_Platform, 2 -; ASM-NEXT: .aeabi_attribute Tag_PAuth_Schema, 31 +; ASM-NEXT: .aeabi_attribute 1, 2 @ Tag_PAuth_Platform +; ASM-NEXT: .aeabi_attribute 2, 31 @ Tag_PAuth_Schema ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth From 083bd48981bb025cdc4afff7b2adacc2b66ca284 Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 17 Feb 2025 11:16:51 +0000 Subject: [PATCH 04/14] [AArch64][Build Attributes] Fix Parsing of Some Tags and Values - Reject strings for unknown tags. - Allow any value for Tag_PAuth_Platform and Tag_PAuth_Schema. --- .../AArch64/AsmParser/AArch64AsmParser.cpp | 21 +++++--- ...4-build-attributes-asm-aeabi-aeabi-known.s | 43 ++++++++++++++++ ...aarch64-build-attributes-asm-aeabi-mixed.s | 48 ++++++++++++++++++ .../aarch64-build-attributes-asm-non_aeabi.s | 49 +++++++++++++++++++ 4 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi.s diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 58bebdf1f75ce..16e0883fe0584 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -7990,14 +7990,22 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { StringRef TagStr = ""; unsigned Tag; - if (Parser.getTok().is(AsmToken::Identifier)) { + if (Parser.getTok().is(AsmToken::Integer)) { + Tag = getTok().getIntVal(); + } else if (Parser.getTok().is(AsmToken::Identifier)) { TagStr = Parser.getTok().getIdentifier(); switch (ActiveSubsectionID) { default: + // Should not happen assert(0 && "Subsection name error"); break; case AArch64BuildAttrs::VENDOR_UNKNOWN: - // Private subsection, accept any tag. + // Tag was provided as an unrecognized string instead of an unsigned + // integer + Error(Parser.getTok().getLoc(), "unrecognized Tag: '" + TagStr + + "' \nExcept for public subsections, " + "tags have to be an unsigned int."); + return true; break; case AArch64BuildAttrs::AEABI_PAUTHABI: Tag = AArch64BuildAttrs::getPauthABITagsID(TagStr); @@ -8018,8 +8026,6 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } break; } - } else if (Parser.getTok().is(AsmToken::Integer)) { - Tag = getTok().getIntVal(); } else { Error(Parser.getTok().getLoc(), "AArch64 build attributes tag not found"); return true; @@ -8063,10 +8069,9 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { Error(Parser.getTok().getLoc(), "AArch64 build attributes value not found"); return true; } - // Check for possible unaccepted values for known tags (AEABI_PAUTHABI, - // AEABI_FEATURE_AND_BITS) - if (!(ActiveSubsectionID == AArch64BuildAttrs::VENDOR_UNKNOWN) && - TagStr != "") { // TagStr was a recognized string + // Check for possible unaccepted values for known tags + // (AEABI_FEATURE_AND_BITS) + if (ActiveSubsectionID == AArch64BuildAttrs::AEABI_FEATURE_AND_BITS) { if (0 != ValueInt && 1 != ValueInt) { Error(Parser.getTok().getLoc(), "unknown AArch64 build attributes Value for Tag '" + TagStr + diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s new file mode 100644 index 0000000000000..d81ab72678013 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s @@ -0,0 +1,43 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS + +// ELF: Hex dump of section '.ARM.attributes': +// ELF: 0x00000000 411a0000 00616561 62695f70 61757468 A....aeabi_pauth +// ELF: 0x00000010 61626900 00000107 02890623 00000061 abi........#...a +// ELF: 0x00000020 65616269 5f666561 74757265 5f616e64 eabi_feature_and +// ELF: 0x00000030 5f626974 73000100 00010101 0201 _bits......... + + +.aeabi_subsection aeabi_pauthabi, required, uleb128 @ test header comment +.aeabi_attribute Tag_PAuth_Platform, 7 +.aeabi_attribute Tag_PAuth_Schema, 777 +.aeabi_attribute Tag_PAuth_Schema, 777 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 +.aeabi_attribute Tag_Feature_GCS, 1 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute 1, 7 @ Tag_PAuth_Platform +.aeabi_attribute 2, 777 @ Tag_PAuth_Schema +.aeabi_attribute 2, 777 @ Tag_PAuth_Schema +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute 0, 1 @ Tag_Feature_BTI +.aeabi_attribute 1, 1 @ Tag_Feature_PAC +.aeabi_attribute 2, 1 @ Tag_Feature_GCS diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s new file mode 100644 index 0000000000000..0607861795791 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s @@ -0,0 +1,48 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection subsection_a, optional, uleb128 +// ASM: .aeabi_subsection aeabi_subsection, optional, ntbs +// ASM: .aeabi_subsection subsection_b, required, uleb128 +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_subsection aeabi_subsection, optional, ntbs +// ASM: .aeabi_attribute 5, "Value" +// ASM: .aeabi_subsection subsection_b, required, uleb128 +// ASM: .aeabi_attribute 6, 536 +// ASM: .aeabi_subsection subsection_a, optional, uleb128 +// ASM: .aeabi_attribute 7, 11 + +// ELF: Hex dump of section '.ARM.attributes': +// ELF: 0x00000000 41150000 00737562 73656374 696f6e5f A....subsection_ +// ELF: 0x00000010 61000100 070b2000 00006165 6162695f a..... ...aeabi_ +// ELF: 0x00000020 73756273 65637469 6f6e0001 01052256 subsection...."V +// ELF: 0x00000030 616c7565 22001600 00007375 62736563 alue".....subsec +// ELF: 0x00000040 74696f6e 5f620000 00069804 1a000000 tion_b.......... +// ELF: 0x00000050 61656162 695f7061 75746861 62690000 aeabi_pauthabi.. +// ELF: 0x00000060 00010702 89062300 00006165 6162695f ......#...aeabi_ +// ELF: 0x00000070 66656174 7572655f 616e645f 62697473 feature_and_bits +// ELF: 0x00000080 00010000 01010102 01 ......... + + +.aeabi_subsection subsection_a, optional, uleb128 +.aeabi_subsection aeabi_subsection, optional, ntbs +.aeabi_subsection subsection_b, required, uleb128 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 7 +.aeabi_attribute Tag_PAuth_Schema, 777 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 1 +.aeabi_attribute Tag_Feature_GCS, 1 +.aeabi_subsection aeabi_subsection, optional, ntbs +.aeabi_attribute 5, "Value" +.aeabi_subsection subsection_b, required, uleb128 +.aeabi_attribute 6, 536 +.aeabi_subsection subsection_a, optional, uleb128 +.aeabi_attribute 7, 11 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi.s new file mode 100644 index 0000000000000..ef55a3cfc89de --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi.s @@ -0,0 +1,49 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection private_subsection_1, optional, uleb128 +// ASM: .aeabi_attribute 12, 257 +// ASM: .aeabi_subsection aeabi_2, required, uleb128 +// ASM: .aeabi_attribute 76, 257 +// ASM: .aeabi_subsection aeabi_3, optional, ntbs +// ASM: .aeabi_attribute 34, hello_llvm +// ASM: .aeabi_subsection private_subsection_4, required, ntbs +// ASM: .aeabi_attribute 777, "hello_llvm" +// ASM: .aeabi_subsection private_subsection_1, optional, uleb128 +// ASM: .aeabi_attribute 876, 257 +// ASM: .aeabi_subsection aeabi_2, required, uleb128 +// ASM: .aeabi_attribute 876, 257 +// ASM: .aeabi_subsection aeabi_3, optional, ntbs +// ASM: .aeabi_attribute 876, "hello_llvm" +// ASM: .aeabi_subsection private_subsection_4, required, ntbs +// ASM: .aeabi_attribute 876, hello_llvm + +// ELF: Hex dump of section '.ARM.attributes': +// ELF: 0x00000000 41220000 00707269 76617465 5f737562 A"...private_sub +// ELF: 0x00000010 73656374 696f6e5f 31000100 0c8102ec section_1....... +// ELF: 0x00000020 06810215 00000061 65616269 5f320000 .......aeabi_2.. +// ELF: 0x00000030 004c8102 ec068102 29000000 61656162 .L......)...aeab +// ELF: 0x00000040 695f3300 01012268 656c6c6f 5f6c6c76 i_3..."hello_llv +// ELF: 0x00000050 6d00ec06 2268656c 6c6f5f6c 6c766d22 m..."hello_llvm" +// ELF: 0x00000060 00370000 00707269 76617465 5f737562 .7...private_sub +// ELF: 0x00000070 73656374 696f6e5f 34000001 89062268 section_4....."h +// ELF: 0x00000080 656c6c6f 5f6c6c76 6d2200ec 0668656c ello_llvm"...hel +// ELF: 0x00000090 6c6f5f6c 6c766d00 lo_llvm. + + +.aeabi_subsection private_subsection_1, optional, uleb128 +.aeabi_attribute 12, 257 +.aeabi_subsection aeabi_2, required, uleb128 +.aeabi_attribute 76, 257 +.aeabi_subsection aeabi_3, optional, ntbs +.aeabi_attribute 34, hello_llvm +.aeabi_subsection private_subsection_4, required, ntbs +.aeabi_attribute 777, "hello_llvm" +.aeabi_subsection private_subsection_1, optional, uleb128 +.aeabi_attribute 876, 257 +.aeabi_subsection aeabi_2, required, uleb128 +.aeabi_attribute 876, 257 +.aeabi_subsection aeabi_3, optional, ntbs +.aeabi_attribute 876, "hello_llvm" +.aeabi_subsection private_subsection_4, required, ntbs +.aeabi_attribute 876, hello_llvm From a126df16932f76a8914e153c1977c5d01a210c9c Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 17 Feb 2025 11:24:29 +0000 Subject: [PATCH 05/14] [AArch64][Build Attributes] Remove Assertion for Duplicate Values Adding the same value twice is valid, so the assertion has been removed. --- .../Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp index 1ed4a81a97673..01b74e55116f9 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp @@ -222,13 +222,9 @@ void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, "Can not add AArch64 build attribute: An attribute with " "the same tag and a different value already exists"); return; - } else { - // Case Item.IntValue == Value, no need to emit twice - assert(0 && - "AArch64 build attribute: An attribute with the same tag " - "and a same value already exists"); - return; } + // Case Item.IntValue == Value is permited. + return; } } } From e453ae00d311961ac2469054892838fc2a4bd087 Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 17 Feb 2025 11:26:41 +0000 Subject: [PATCH 06/14] [AArch64][Build Attributes] Add test files Add test files --- .../aarch64-build-attributes-asm-aeabi-bti.s | 18 +++++ ...h64-build-attributes-asm-aeabi-err-attrs.s | 69 +++++++++++++++++++ ...4-build-attributes-asm-aeabi-err-headers.s | 64 +++++++++++++++++ .../aarch64-build-attributes-asm-aeabi-gcs.s | 18 +++++ .../aarch64-build-attributes-asm-aeabi-none.s | 25 +++++++ ...uild-attributes-asm-aeabi-numerical-tags.s | 39 +++++++++++ ...-build-attributes-asm-aeabi-out-of-order.s | 48 +++++++++++++ .../aarch64-build-attributes-asm-aeabi-pac.s | 18 +++++ ...rch64-build-attributes-asm-non_aeabi-err.s | 33 +++++++++ 9 files changed, 332 insertions(+) create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-attrs.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-headers.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s create mode 100644 llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi-err.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s new file mode 100644 index 0000000000000..c760cf1558578 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s @@ -0,0 +1,18 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 @ Tag_Feature_GCS + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu +// ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000001 re_and_bits..... +// ELF-NEXT: 0x00000020 01000200 + + +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_attribute Tag_Feature_PAC, 0 +.aeabi_attribute Tag_Feature_GCS, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-attrs.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-attrs.s new file mode 100644 index 0000000000000..d509974f508d0 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-attrs.s @@ -0,0 +1,69 @@ +// RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s + +// Test logic and type mismatch +.aeabi_attribute Tag_Feature_BTI, 1 +// ERR: error: no active subsection, build attribute can not be added +// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +// ERR: error: unknown AArch64 build attribute 'Tag_Feature_BTI' for subsection 'aeabi_pauthabi' +// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, 1 + +.aeabi_attribute a, 1 +// ERR: error: unknown AArch64 build attribute 'a' for subsection 'aeabi_pauthabi' +// ERR-NEXT: .aeabi_attribute a, 1 + +.aeabi_attribute Tag_PAuth_Platform, Tag_PAuth_Platform +// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) +// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, Tag_PAuth_Platform + +.aeabi_attribute Tag_PAuth_Platform, a +// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) +// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, a + + +// Test syntax errors +.aeabi_attribute Tag_PAuth_Platform, +// ERR: error: AArch64 build attributes value not found +// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, + +.aeabi_attribute Tag_PAuth_Platform +// ERR: error: expected comma +// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform + +.aeabi_attribute +// ERR: error: AArch64 build attributes tag not found +// ERR-NEXT: .aeabi_attribute + +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 1 +// ERR: unknown AArch64 build attribute 'Tag_PAuth_Platform' for subsection 'aeabi_feature_and_bits' + +.aeabi_attribute a, 1 +// ERR: error: unknown AArch64 build attribute 'a' for subsection 'aeabi_feature_and_bits' + +.aeabi_attribute Tag_Feature_BTI, Tag_Feature_BTI +// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) +// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, Tag_Feature_BTI + +.aeabi_attribute Tag_Feature_BTI, a +// ERR: error: active subsection type is ULEB128 (unsigned), found NTBS (string) +// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, a + +.aeabi_attribute Tag_Feature_BTI, +// ERR: error: AArch64 build attributes value not found +// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI, + +.aeabi_attribute Tag_Feature_BTI +// ERR: error: expected comma +// ERR-NEXT: .aeabi_attribute Tag_Feature_BTI + +.aeabi_attribute +// ERR: error: AArch64 build attributes tag not found +// ERR-NEXT: .aeabi_attribute + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 1 some_text +// ERR: error: unexpected token for AArch64 build attributes tag and value attribute directive +// ERR-NEXT: .aeabi_attribute Tag_PAuth_Platform, 1 some_text diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-headers.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-headers.s new file mode 100644 index 0000000000000..501958a17bed3 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-headers.s @@ -0,0 +1,64 @@ +// RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s + +// Test syntax errors +.aeabi_subsection 1, required, uleb128 +// ERR: error: subsection name not found +// ERR-NEXT: .aeabi_subsection 1, required, uleb128 + +.aeabi_subsection , required, uleb128 +// ERR: error: subsection name not found +// ERR-NEXT: .aeabi_subsection , required, uleb128 + +.aeabi_subsection aeabi_pauthabi, a, uleb128 +// ERR: error: unknown AArch64 build attributes optionality, expected required|optional +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, a, uleb128 + +.aeabi_subsection aeabi_pauthabi, 1, uleb128 +// ERR: error: optionality parameter not found, expected required|optional +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, 1, uleb128 + +.aeabi_subsection aeabi_pauthabi, ,uleb128 +// ERR: error: optionality parameter not found, expected required|optional +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, ,uleb128 + +.aeabi_subsection aeabi_pauthabi,uleb128 +// ERR: error: unknown AArch64 build attributes optionality, expected required|optional +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi,uleb128 + +.aeabi_subsection aeabi_pauthabi uleb128 +// ERR: expected comma +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi uleb128 + +.aeabi_subsection aeabi_pauthabi, required +// ERR: error: expected comma +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required + +.aeabi_subsection aeabi_pauthabi, required, +// ERR: error: type parameter not found, expected uleb128|ntbs +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, + +.aeabi_subsection aeabi_pauthabi, required, a +// ERR: error: unknown AArch64 build attributes type, expected uleb128|ntbs +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, a + +.aeabi_subsection aeabi_pauthabi, optional, uleb128 +// ERR: error: aeabi_pauthabi must be marked as required +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, optional, uleb128 + + +// Test types mismatch +.aeabi_subsection aeabi_pauthabi, optional, uleb128 +// ERR: error: aeabi_pauthabi must be marked as required +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, optional, uleb128 + +.aeabi_subsection aeabi_pauthabi, required, ntbs +// ERR: error: aeabi_pauthabi must be marked as ULEB128 +// ERR-NEXT: .aeabi_subsection aeabi_pauthabi, required, ntbs + +.aeabi_subsection aeabi_feature_and_bits, required, uleb128 +// ERR: error: aeabi_feature_and_bits must be marked as optional +// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, required, uleb128 + +.aeabi_subsection aeabi_feature_and_bits, optional, ntbs +// ERR: error: aeabi_feature_and_bits must be marked as ULEB128 +// ERR-NEXT: .aeabi_subsection aeabi_feature_and_bits, optional, ntbs diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s new file mode 100644 index 0000000000000..5c5551a2133cd --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s @@ -0,0 +1,18 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 0 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu +// ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000000 re_and_bits..... +// ELF-NEXT: 0x00000020 01000201 + + +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 0 +.aeabi_attribute Tag_Feature_PAC, 0 +.aeabi_attribute Tag_Feature_GCS, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s new file mode 100644 index 0000000000000..e029e43c0934a --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s @@ -0,0 +1,25 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 0 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 0 @ Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 0 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 @ Tag_Feature_GCS + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth +// ELF-NEXT: 0x00000010 61626900 00000100 02002300 00006165 abi.......#...ae +// ELF-NEXT: 0x00000020 6162695f 66656174 7572655f 616e645f abi_feature_and_ +// ELF-NEXT: 0x00000030 62697473 00010000 00010002 00 + + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 0 +.aeabi_attribute Tag_PAuth_Schema, 0 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 0 +.aeabi_attribute Tag_Feature_PAC, 0 +.aeabi_attribute Tag_Feature_GCS, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s new file mode 100644 index 0000000000000..71e28baa7fc73 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s @@ -0,0 +1,39 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM + +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 0, 1 +// ASM: .aeabi_attribute 1, 1 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 1 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 3, 1 +// ASM: .aeabi_attribute 4, 1 +// ASM: .aeabi_attribute 5, 1 +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 3, 1 +// ASM: .aeabi_attribute 4, 1 +// ASM: .aeabi_attribute 5, 1 + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 41210000 00616561 62695f70 61757468 A!...aeabi_pauth +// ELF-NEXT: 0x00000010 61626900 00000001 01010201 03010401 abi............. +// ELF-NEXT: 0x00000020 05012900 00006165 6162695f 66656174 ..)...aeabi_feat +// ELF-NEXT: 0x00000030 7572655f 616e645f 62697473 00010000 ure_and_bits.... +// ELF-NEXT: 0x00000040 01010102 01030104 010501 + + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute 0, 1 +.aeabi_attribute 1, 1 +.aeabi_attribute 2, 1 +.aeabi_attribute 3, 1 +.aeabi_attribute 4, 1 +.aeabi_attribute 5, 1 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute 0, 1 +.aeabi_attribute 1, 1 +.aeabi_attribute 2, 1 +.aeabi_attribute 3, 1 +.aeabi_attribute 4, 1 +.aeabi_attribute 5, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s new file mode 100644 index 0000000000000..197b7cfd52038 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s @@ -0,0 +1,48 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 2, 1 @ Tag_PAuth_Schema +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 1, 1 @ Tag_PAuth_Platform +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 7, 1 +// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 +// ASM: .aeabi_attribute 7, 0 + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 411b0000 00616561 62695f70 61757468 A....aeabi_pauth +// ELF-NEXT: 0x00000010 61626900 00000201 01010700 25000000 abi.........%... +// ELF-NEXT: 0x00000020 61656162 695f6665 61747572 655f616e aeabi_feature_an +// ELF-NEXT: 0x00000030 645f6269 74730001 00000102 01010007 d_bits.......... +// ELF-NEXT: 0x00000040 01 + + +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_BTI, 1 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Schema, 1 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute Tag_PAuth_Platform, 1 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_GCS, 1 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute Tag_Feature_PAC, 0 +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute 7, 1 +.aeabi_subsection aeabi_pauthabi, required, uleb128 +.aeabi_attribute 7, 0 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s new file mode 100644 index 0000000000000..1b86081355ab9 --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s @@ -0,0 +1,18 @@ +// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF + +// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +// ASM: .aeabi_attribute 0, 0 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 @ Tag_Feature_GCS + +// ELF: Hex dump of section '.ARM.attributes': +// ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu +// ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000000 re_and_bits..... +// ELF-NEXT: 0x00000020 01010200 + + +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 +.aeabi_attribute 0, 0 @ Tag_Feature_BTI +.aeabi_attribute 1, 1 @ Tag_Feature_PAC +.aeabi_attribute 2, 0 @ Tag_Feature_GCS diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi-err.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi-err.s new file mode 100644 index 0000000000000..6e28481aeb97b --- /dev/null +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi-err.s @@ -0,0 +1,33 @@ +// RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck --check-prefix=ERR %s + +.aeabi_subsection private_subsection, optional, uleb128 + +.aeabi_subsection private_subsection, required, uleb128 +// ERR: error: optionality mismatch! subsection 'private_subsection' already exists with optionality defined as 'optional' and not 'required' +// ERR-NEXT: .aeabi_subsection private_subsection, required, uleb128 + +.aeabi_subsection private_subsection, optional, ntbs +// ERR: error: type mismatch! subsection 'private_subsection' already exists with type defined as 'uleb128' and not 'ntbs' +// ERR-NEXT: .aeabi_subsection private_subsection, optional, ntbs + +.aeabi_subsection private_subsection_1, optional, ntbs +.aeabi_attribute 324, 1 +// ERR: error: active subsection type is NTBS (string), found ULEB128 (unsigned) +// ERR-NEXT: .aeabi_attribute 324, 1 + +.aeabi_attribute str_not_int, "1" +// ERR: error: unrecognized Tag: 'str_not_int' +// ERR-NEXT: Except for public subsections, tags have to be an unsigned int. +// ERR-NEXT: .aeabi_attribute str_not_int, "1" + +.aeabi_subsection foo, optional, uleb128 +.aeabi_subsection bar, optional, uleb128 +.aeabi_subsection foo, required, uleb128 +// ERR: error: optionality mismatch! subsection 'foo' already exists with optionality defined as 'optional' and not 'required' +// ERR-NEXT: .aeabi_subsection foo, required, uleb128 + +.aeabi_subsection goo, optional, ntbs +.aeabi_subsection zar, optional, ntbs +.aeabi_subsection goo, optional, uleb128 +// ERR: error: type mismatch! subsection 'goo' already exists with type defined as 'ntbs' and not 'uleb128' +// ERR-NEXT: .aeabi_subsection goo, optional, uleb128 From c161c0472bf3e818ee321811db8b51dca89d509f Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Tue, 18 Feb 2025 12:45:24 +0000 Subject: [PATCH 07/14] [AArch64][Build Attributes] Same Tag different Value: override When a new value is provided for an existing tag, override. --- .../MCTargetDesc/AArch64TargetStreamer.cpp | 21 +++++++++++-------- ...aarch64-build-attributes-asm-aeabi-mixed.s | 4 +++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp index 01b74e55116f9..25b0ba8f30f12 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp @@ -15,6 +15,7 @@ #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/ConstantPools.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCELFStreamer.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSubtargetInfo.h" @@ -214,18 +215,20 @@ void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, return; } for (MCELFStreamer::AttributeItem &Item : SubSection.Content) { + // Tag already exists if (Item.Tag == Tag) { - if (!Override) { - if ((unsigned(-1) != Value && Item.IntValue != Value) || - ("" != String && Item.StringValue != String)) { - assert(0 && - "Can not add AArch64 build attribute: An attribute with " - "the same tag and a different value already exists"); - return; - } - // Case Item.IntValue == Value is permited. + // New value for existing tag: update tag + if ((unsigned(-1) != Value && Item.IntValue != Value) || + ("" != String && Item.StringValue != String)) { + Item.Type = unsigned(-1) != Value + ? MCELFStreamer::AttributeItem::NumericAttribute + : MCELFStreamer::AttributeItem::TextAttribute; + Item.IntValue = unsigned(-1) != Value ? Value : unsigned(-1); + Item.StringValue = unsigned(-1) != Value ? "" : String; return; } + // Same value for existing tag: do nothing + return; } } if (unsigned(-1) != Value) diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s index 0607861795791..027def743db6d 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s @@ -7,6 +7,7 @@ // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform // ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 9 @ Tag_PAuth_Platform // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI // ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC @@ -25,7 +26,7 @@ // ELF: 0x00000030 616c7565 22001600 00007375 62736563 alue".....subsec // ELF: 0x00000040 74696f6e 5f620000 00069804 1a000000 tion_b.......... // ELF: 0x00000050 61656162 695f7061 75746861 62690000 aeabi_pauthabi.. -// ELF: 0x00000060 00010702 89062300 00006165 6162695f ......#...aeabi_ +// ELF: 0x00000060 00010902 89062300 00006165 6162695f ......#...aeabi_ // ELF: 0x00000070 66656174 7572655f 616e645f 62697473 feature_and_bits // ELF: 0x00000080 00010000 01010102 01 ......... @@ -36,6 +37,7 @@ .aeabi_subsection aeabi_pauthabi, required, uleb128 .aeabi_attribute Tag_PAuth_Platform, 7 .aeabi_attribute Tag_PAuth_Schema, 777 +.aeabi_attribute Tag_PAuth_Platform, 9 .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 .aeabi_attribute Tag_Feature_BTI, 1 .aeabi_attribute Tag_Feature_PAC, 1 From 9c3f0f769503af334100c274eba5408574c53617 Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Tue, 18 Feb 2025 14:07:00 +0000 Subject: [PATCH 08/14] [AArch64][Build Attributes] Improve Parsing and Formatting AArch64 assembly comments should be '//' Lexer remove comments, no need to handle them when parsing. --- .../AArch64/AsmParser/AArch64AsmParser.cpp | 14 ++----- .../MCTargetDesc/AArch64ELFStreamer.cpp | 4 +- .../AArch64/aarch64-build-attributes-all.ll | 6 +-- .../AArch64/aarch64-build-attributes-bti.ll | 6 +-- .../AArch64/aarch64-build-attributes-gcs.ll | 6 +-- .../AArch64/aarch64-build-attributes-pac.ll | 6 +-- .../aarch64-build-attributes-pauthabi.ll | 4 +- ...4-build-attributes-asm-aeabi-aeabi-known.s | 38 +++++++++---------- .../aarch64-build-attributes-asm-aeabi-bti.s | 6 +-- .../aarch64-build-attributes-asm-aeabi-gcs.s | 6 +-- ...aarch64-build-attributes-asm-aeabi-mixed.s | 12 +++--- .../aarch64-build-attributes-asm-aeabi-none.s | 10 ++--- ...uild-attributes-asm-aeabi-numerical-tags.s | 10 ++--- ...-build-attributes-asm-aeabi-out-of-order.s | 10 ++--- .../aarch64-build-attributes-asm-aeabi-pac.s | 12 +++--- 15 files changed, 72 insertions(+), 78 deletions(-) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 16e0883fe0584..cccd60502abf0 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -7948,11 +7948,8 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { } Parser.Lex(); - // Parsing finished, hereafter only accept comments; otherwise no trailing - // tokens. - if (Parser.getTok().is(llvm::AsmToken::At)) { - Parser.parseStringToEndOfStatement(); - } + // Parsing finished. Check for trailing characters (no need to check for + // comments; they are removed by the lexer). if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build " "attributes subsection header directive"); @@ -8081,11 +8078,8 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } Parser.Lex(); - // Parsing finished, hereafter only accept comments; otherwise no trailing - // tokens. - if (Parser.getTok().is(llvm::AsmToken::At)) { - Parser.parseStringToEndOfStatement(); - } + // Parsing finished. Check for trailing characters (no need to check for + // comments; they are removed by the lexer). if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build attributes tag and value " diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 2f6a5144a82b4..33214c11ccf1a 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -191,7 +191,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { case AArch64BuildAttrs::TAG_FEATURE_BTI: case AArch64BuildAttrs::TAG_FEATURE_GCS: case AArch64BuildAttrs::TAG_FEATURE_PAC: - OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t@ " + OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// " << AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag); AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override); @@ -210,7 +210,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { break; case AArch64BuildAttrs::TAG_PAUTH_PLATFORM: case AArch64BuildAttrs::TAG_PAUTH_SCHEMA: - OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t@ " + OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// " << AArch64BuildAttrs::getPauthABITagsStr(Tag); AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override); diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll index 9eaed09130f15..e2e1e0a384867 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -; ASM-NEXT: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -; ASM-NEXT: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +; ASM-NEXT: .aeabi_attribute 0, 1 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 1 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 1 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll index cffb1fb265379..92ce2abb795d9 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -; ASM-NEXT: .aeabi_attribute 1, 0 @ Tag_Feature_PAC -; ASM-NEXT: .aeabi_attribute 2, 0 @ Tag_Feature_GCS +; ASM-NEXT: .aeabi_attribute 0, 1 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 0 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 0 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll index 3dbba6a7eeace..faa77d657aa2e 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute 0, 0 @ Tag_Feature_BTI -; ASM-NEXT: .aeabi_attribute 1, 0 @ Tag_Feature_PAC -; ASM-NEXT: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +; ASM-NEXT: .aeabi_attribute 0, 0 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 0 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 1 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll index 506a821ad9d90..0358927ad10f5 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll @@ -2,9 +2,9 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -; ASM-NEXT: .aeabi_attribute 0, 0 @ Tag_Feature_BTI -; ASM-NEXT: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -; ASM-NEXT: .aeabi_attribute 2, 0 @ Tag_Feature_GCS +; ASM-NEXT: .aeabi_attribute 0, 0 // Tag_Feature_BTI +; ASM-NEXT: .aeabi_attribute 1, 1 // Tag_Feature_PAC +; ASM-NEXT: .aeabi_attribute 2, 0 // Tag_Feature_GCS ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll index a7d9585af4379..1c2a72524d5de 100644 --- a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll +++ b/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll @@ -2,8 +2,8 @@ ; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF ; ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -; ASM-NEXT: .aeabi_attribute 1, 2 @ Tag_PAuth_Platform -; ASM-NEXT: .aeabi_attribute 2, 31 @ Tag_PAuth_Schema +; ASM-NEXT: .aeabi_attribute 1, 2 // Tag_PAuth_Platform +; ASM-NEXT: .aeabi_attribute 2, 31 // Tag_PAuth_Schema ; ELF: Hex dump of section '.ARM.attributes': ; ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s index d81ab72678013..dca673fa5e149 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s @@ -2,21 +2,21 @@ // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform -// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema -// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform -// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema -// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF: 0x00000000 411a0000 00616561 62695f70 61757468 A....aeabi_pauth @@ -25,7 +25,7 @@ // ELF: 0x00000030 5f626974 73000100 00010101 0201 _bits......... -.aeabi_subsection aeabi_pauthabi, required, uleb128 @ test header comment +.aeabi_subsection aeabi_pauthabi, required, uleb128 // test header comment .aeabi_attribute Tag_PAuth_Platform, 7 .aeabi_attribute Tag_PAuth_Schema, 777 .aeabi_attribute Tag_PAuth_Schema, 777 @@ -34,10 +34,10 @@ .aeabi_attribute Tag_Feature_PAC, 1 .aeabi_attribute Tag_Feature_GCS, 1 .aeabi_subsection aeabi_pauthabi, required, uleb128 -.aeabi_attribute 1, 7 @ Tag_PAuth_Platform -.aeabi_attribute 2, 777 @ Tag_PAuth_Schema -.aeabi_attribute 2, 777 @ Tag_PAuth_Schema +.aeabi_attribute 1, 7 // Tag_PAuth_Platform +.aeabi_attribute 2, 777 // Tag_PAuth_Schema +.aeabi_attribute 2, 777 // Tag_PAuth_Schema .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute 0, 1 @ Tag_Feature_BTI -.aeabi_attribute 1, 1 @ Tag_Feature_PAC -.aeabi_attribute 2, 1 @ Tag_Feature_GCS +.aeabi_attribute 0, 1 // Tag_Feature_BTI +.aeabi_attribute 1, 1 // Tag_Feature_PAC +.aeabi_attribute 2, 1 // Tag_Feature_GCS diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s index c760cf1558578..c6003e07e3eec 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s @@ -2,9 +2,9 @@ // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 0 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s index 5c5551a2133cd..91122fc4b5cf3 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s @@ -2,9 +2,9 @@ // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 0 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s index 027def743db6d..7932517d8e0cf 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s @@ -5,13 +5,13 @@ // ASM: .aeabi_subsection aeabi_subsection, optional, ntbs // ASM: .aeabi_subsection subsection_b, required, uleb128 // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 1, 7 @ Tag_PAuth_Platform -// ASM: .aeabi_attribute 2, 777 @ Tag_PAuth_Schema -// ASM: .aeabi_attribute 1, 9 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 9 // Tag_PAuth_Platform // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ASM: .aeabi_subsection aeabi_subsection, optional, ntbs // ASM: .aeabi_attribute 5, "Value" // ASM: .aeabi_subsection subsection_b, required, uleb128 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s index e029e43c0934a..0b60b8c47d049 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s @@ -2,12 +2,12 @@ // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 1, 0 @ Tag_PAuth_Platform -// ASM: .aeabi_attribute 2, 0 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 0 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 0 // Tag_PAuth_Schema // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 0 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 0 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s index 71e28baa7fc73..25b6a1836bba9 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s @@ -2,15 +2,15 @@ // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_attribute 0, 1 -// ASM: .aeabi_attribute 1, 1 @ Tag_PAuth_Platform -// ASM: .aeabi_attribute 2, 1 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 1, 1 // Tag_PAuth_Platform +// ASM: .aeabi_attribute 2, 1 // Tag_PAuth_Schema // ASM: .aeabi_attribute 3, 1 // ASM: .aeabi_attribute 4, 1 // ASM: .aeabi_attribute 5, 1 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ASM: .aeabi_attribute 3, 1 // ASM: .aeabi_attribute 4, 1 // ASM: .aeabi_attribute 5, 1 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s index 197b7cfd52038..c4192cddb1f2e 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s @@ -3,18 +3,18 @@ // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 1 @ Tag_Feature_BTI +// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 2, 1 @ Tag_PAuth_Schema +// ASM: .aeabi_attribute 2, 1 // Tag_PAuth_Schema // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 -// ASM: .aeabi_attribute 1, 1 @ Tag_PAuth_Platform +// ASM: .aeabi_attribute 1, 1 // Tag_PAuth_Platform // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 2, 1 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 1, 0 @ Tag_Feature_PAC +// ASM: .aeabi_attribute 1, 0 // Tag_Feature_PAC // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_attribute 7, 1 // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s index 1b86081355ab9..228e2be8af88a 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s +++ b/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s @@ -2,9 +2,9 @@ // RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -// ASM: .aeabi_attribute 0, 0 @ Tag_Feature_BTI -// ASM: .aeabi_attribute 1, 1 @ Tag_Feature_PAC -// ASM: .aeabi_attribute 2, 0 @ Tag_Feature_GCS +// ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI +// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC +// ASM: .aeabi_attribute 2, 0 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': // ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu @@ -13,6 +13,6 @@ .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 -.aeabi_attribute 0, 0 @ Tag_Feature_BTI -.aeabi_attribute 1, 1 @ Tag_Feature_PAC -.aeabi_attribute 2, 0 @ Tag_Feature_GCS +.aeabi_attribute 0, 0 // Tag_Feature_BTI +.aeabi_attribute 1, 1 // Tag_Feature_PAC +.aeabi_attribute 2, 0 // Tag_Feature_GCS From 3ae07d14079e80f4e93c7f755ff61e7f28a60faf Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Wed, 19 Feb 2025 11:37:48 +0000 Subject: [PATCH 09/14] [AArch64][Build Attributes] Remove unused 'Override' parameter Since the function accepts assembly that adds a different value for an existing tag, the 'Override' parameter is no longer needed. --- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 10 +++---- .../AArch64/AsmParser/AArch64AsmParser.cpp | 5 ++-- .../MCTargetDesc/AArch64ELFStreamer.cpp | 28 ++++++++----------- .../MCTargetDesc/AArch64TargetStreamer.cpp | 3 +- .../MCTargetDesc/AArch64TargetStreamer.h | 4 +-- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index f1f25b65fc53f..c7de0a6d2ca51 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -482,10 +482,10 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags, AArch64BuildAttrs::SubsectionType::ULEB128); TS->emitAttribute( AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI), - AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "", false); + AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, ""); TS->emitAttribute( AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI), - AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, "", false); + AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, ""); } unsigned BTIValue = (Flags & AArch64BuildAttrs::Feature_BTI_Flag) ? 1 : 0; @@ -499,13 +499,13 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags, AArch64BuildAttrs::SubsectionType::ULEB128); TS->emitAttribute(AArch64BuildAttrs::getVendorName( AArch64BuildAttrs::AEABI_FEATURE_AND_BITS), - AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, "", false); + AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, ""); TS->emitAttribute(AArch64BuildAttrs::getVendorName( AArch64BuildAttrs::AEABI_FEATURE_AND_BITS), - AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, "", false); + AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, ""); TS->emitAttribute(AArch64BuildAttrs::getVendorName( AArch64BuildAttrs::AEABI_FEATURE_AND_BITS), - AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, "", false); + AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, ""); } } diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index cccd60502abf0..59dd2dd3e28f4 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -8088,12 +8088,11 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } if (unsigned(-1) != ValueInt) { - getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, "", - false); + getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, ""); } if ("" != ValueStr) { getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, unsigned(-1), - ValueStr, false); + ValueStr); } return false; } diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 33214c11ccf1a..61c860341ca99 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -151,7 +151,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { } void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, - std::string String, bool Override) override { + std::string String) override { // AArch64 build attributes for assembly attribute form: // .aeabi_attribute tag, value @@ -169,13 +169,12 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { case AArch64BuildAttrs::VENDOR_UNKNOWN: if (unsigned(-1) != Value) { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); } if ("" != String) { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << String; AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), - String, Override); + String); } break; // Note: AEABI_FEATURE_AND_BITS takes only unsigned values @@ -185,16 +184,14 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; // Keep the data structure consistent with the case of ELF emission // (important for llvm-mc asm parsing) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; case AArch64BuildAttrs::TAG_FEATURE_BTI: case AArch64BuildAttrs::TAG_FEATURE_GCS: case AArch64BuildAttrs::TAG_FEATURE_PAC: OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// " << AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag); - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; } break; @@ -205,15 +202,13 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; // Keep the data structure consistent with the case of ELF emission // (important for llvm-mc asm parsing) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; case AArch64BuildAttrs::TAG_PAUTH_PLATFORM: case AArch64BuildAttrs::TAG_PAUTH_SCHEMA: OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// " << AArch64BuildAttrs::getPauthABITagsStr(Tag); - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); break; } break; @@ -426,13 +421,12 @@ void AArch64TargetELFStreamer::emitAtributesSubsection( } void AArch64TargetELFStreamer::emitAttribute(StringRef VendorName, unsigned Tag, - unsigned Value, std::string String, - bool Override) { + unsigned Value, + std::string String) { if (unsigned(-1) != Value) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, ""); if ("" != String) - AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), String, - Override); + AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), String); } void AArch64TargetELFStreamer::emitInst(uint32_t Inst) { diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp index 25b0ba8f30f12..0221ab60352db 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp @@ -194,8 +194,7 @@ AArch64TargetStreamer::getAtributesSubsectionByName(StringRef Name) { } void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, - unsigned Value, std::string String, - bool Override) { + unsigned Value, std::string String) { if (unsigned(-1) == Value && "" == String) { assert(0 && "Arguments error"); diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h index 9183fb4cc5f56..9cbb104c0eb9e 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h @@ -100,7 +100,7 @@ class AArch64TargetStreamer : public MCTargetStreamer { AArch64BuildAttrs::SubsectionOptional IsOptional, AArch64BuildAttrs::SubsectionType ParameterType); virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, - std::string String, bool Override); + std::string String); void activateAtributesSubsection(StringRef VendorName); std::unique_ptr getActiveAtributesSubsection(); @@ -127,7 +127,7 @@ class AArch64TargetELFStreamer : public AArch64TargetStreamer { StringRef VendorName, AArch64BuildAttrs::SubsectionOptional IsOptional, AArch64BuildAttrs::SubsectionType ParameterType) override; void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, - std::string String, bool Override = false) override; + std::string String) override; void emitInst(uint32_t Inst) override; void emitDirectiveVariantPCS(MCSymbol *Symbol) override; void finish() override; From badefe8ff4fd58f7f516ef5a0a07dabbb852dbcf Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Wed, 19 Feb 2025 11:46:20 +0000 Subject: [PATCH 10/14] [AArch64][Build Attributes] Remove redundant comments and unneeded case - Remove redundant comments - Remove default case from a fully covered switch --- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 59dd2dd3e28f4..e46e7b38010a4 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -7948,8 +7948,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { } Parser.Lex(); - // Parsing finished. Check for trailing characters (no need to check for - // comments; they are removed by the lexer). + // Parsing finished, check for trailing tokens. if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build " "attributes subsection header directive"); @@ -7992,10 +7991,6 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } else if (Parser.getTok().is(AsmToken::Identifier)) { TagStr = Parser.getTok().getIdentifier(); switch (ActiveSubsectionID) { - default: - // Should not happen - assert(0 && "Subsection name error"); - break; case AArch64BuildAttrs::VENDOR_UNKNOWN: // Tag was provided as an unrecognized string instead of an unsigned // integer @@ -8078,8 +8073,7 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) { } Parser.Lex(); - // Parsing finished. Check for trailing characters (no need to check for - // comments; they are removed by the lexer). + // Parsing finished. Check for trailing tokens. if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) { Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build attributes tag and value " From 6fdc1eed07d28bd7f869074c15a99a92491bef3c Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Thu, 20 Feb 2025 10:36:18 +0000 Subject: [PATCH 11/14] Remove prefix aarch64 from test files residing in the AArch64 folder --- ...tributes-all.ll => build-attributes-all.ll} | 0 ...tributes-bti.ll => build-attributes-bti.ll} | 0 ...tributes-gcs.ll => build-attributes-gcs.ll} | 0 ...tributes-pac.ll => build-attributes-pac.ll} | 0 ...authabi.ll => build-attributes-pauthabi.ll} | 0 ...> build-attributes-asm-aeabi-aeabi-known.s} | 10 +++++----- ...-bti.s => build-attributes-asm-aeabi-bti.s} | 0 ... => build-attributes-asm-aeabi-err-attrs.s} | 0 ...> build-attributes-asm-aeabi-err-headers.s} | 0 ...-gcs.s => build-attributes-asm-aeabi-gcs.s} | 0 ...ed.s => build-attributes-asm-aeabi-mixed.s} | 18 +++++++++--------- ...one.s => build-attributes-asm-aeabi-none.s} | 0 ...uild-attributes-asm-aeabi-numerical-tags.s} | 0 ... build-attributes-asm-aeabi-out-of-order.s} | 0 ...-pac.s => build-attributes-asm-aeabi-pac.s} | 0 ....s => build-attributes-asm-non_aeabi-err.s} | 0 ...eabi.s => build-attributes-asm-non_aeabi.s} | 0 17 files changed, 14 insertions(+), 14 deletions(-) rename llvm/test/CodeGen/AArch64/{aarch64-build-attributes-all.ll => build-attributes-all.ll} (100%) rename llvm/test/CodeGen/AArch64/{aarch64-build-attributes-bti.ll => build-attributes-bti.ll} (100%) rename llvm/test/CodeGen/AArch64/{aarch64-build-attributes-gcs.ll => build-attributes-gcs.ll} (100%) rename llvm/test/CodeGen/AArch64/{aarch64-build-attributes-pac.ll => build-attributes-pac.ll} (100%) rename llvm/test/CodeGen/AArch64/{aarch64-build-attributes-pauthabi.ll => build-attributes-pauthabi.ll} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-aeabi-known.s => build-attributes-asm-aeabi-aeabi-known.s} (83%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-bti.s => build-attributes-asm-aeabi-bti.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-err-attrs.s => build-attributes-asm-aeabi-err-attrs.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-err-headers.s => build-attributes-asm-aeabi-err-headers.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-gcs.s => build-attributes-asm-aeabi-gcs.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-mixed.s => build-attributes-asm-aeabi-mixed.s} (73%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-none.s => build-attributes-asm-aeabi-none.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-numerical-tags.s => build-attributes-asm-aeabi-numerical-tags.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-out-of-order.s => build-attributes-asm-aeabi-out-of-order.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-aeabi-pac.s => build-attributes-asm-aeabi-pac.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-non_aeabi-err.s => build-attributes-asm-non_aeabi-err.s} (100%) rename llvm/test/MC/AArch64/{aarch64-build-attributes-asm-non_aeabi.s => build-attributes-asm-non_aeabi.s} (100%) diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll b/llvm/test/CodeGen/AArch64/build-attributes-all.ll similarity index 100% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll rename to llvm/test/CodeGen/AArch64/build-attributes-all.ll diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll b/llvm/test/CodeGen/AArch64/build-attributes-bti.ll similarity index 100% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll rename to llvm/test/CodeGen/AArch64/build-attributes-bti.ll diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll b/llvm/test/CodeGen/AArch64/build-attributes-gcs.ll similarity index 100% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll rename to llvm/test/CodeGen/AArch64/build-attributes-gcs.ll diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll b/llvm/test/CodeGen/AArch64/build-attributes-pac.ll similarity index 100% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll rename to llvm/test/CodeGen/AArch64/build-attributes-pac.ll diff --git a/llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll b/llvm/test/CodeGen/AArch64/build-attributes-pauthabi.ll similarity index 100% rename from llvm/test/CodeGen/AArch64/aarch64-build-attributes-pauthabi.ll rename to llvm/test/CodeGen/AArch64/build-attributes-pauthabi.ll diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s similarity index 83% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s index dca673fa5e149..5fc8db404b45e 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-aeabi-known.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s @@ -19,13 +19,13 @@ // ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS // ELF: Hex dump of section '.ARM.attributes': -// ELF: 0x00000000 411a0000 00616561 62695f70 61757468 A....aeabi_pauth -// ELF: 0x00000010 61626900 00000107 02890623 00000061 abi........#...a -// ELF: 0x00000020 65616269 5f666561 74757265 5f616e64 eabi_feature_and -// ELF: 0x00000030 5f626974 73000100 00010101 0201 _bits......... +// ELF-NEXT: 0x00000000 411a0000 00616561 62695f70 61757468 A....aeabi_pauth +// ELF-NEXT: 0x00000010 61626900 00000107 02890623 00000061 abi........#...a +// ELF-NEXT: 0x00000020 65616269 5f666561 74757265 5f616e64 eabi_feature_and +// ELF-NEXT: 0x00000030 5f626974 73000100 00010101 0201 _bits......... -.aeabi_subsection aeabi_pauthabi, required, uleb128 // test header comment +.aeabi_subsection aeabi_pauthabi, required, uleb128 .aeabi_attribute Tag_PAuth_Platform, 7 .aeabi_attribute Tag_PAuth_Schema, 777 .aeabi_attribute Tag_PAuth_Schema, 777 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-bti.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-attrs.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-attrs.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-attrs.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-attrs.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-headers.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-headers.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-err-headers.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-err-headers.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-gcs.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s similarity index 73% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s index 7932517d8e0cf..f4b01182cc11a 100644 --- a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-mixed.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s @@ -20,15 +20,15 @@ // ASM: .aeabi_attribute 7, 11 // ELF: Hex dump of section '.ARM.attributes': -// ELF: 0x00000000 41150000 00737562 73656374 696f6e5f A....subsection_ -// ELF: 0x00000010 61000100 070b2000 00006165 6162695f a..... ...aeabi_ -// ELF: 0x00000020 73756273 65637469 6f6e0001 01052256 subsection...."V -// ELF: 0x00000030 616c7565 22001600 00007375 62736563 alue".....subsec -// ELF: 0x00000040 74696f6e 5f620000 00069804 1a000000 tion_b.......... -// ELF: 0x00000050 61656162 695f7061 75746861 62690000 aeabi_pauthabi.. -// ELF: 0x00000060 00010902 89062300 00006165 6162695f ......#...aeabi_ -// ELF: 0x00000070 66656174 7572655f 616e645f 62697473 feature_and_bits -// ELF: 0x00000080 00010000 01010102 01 ......... +// ELF-NEXT: 0x00000000 41150000 00737562 73656374 696f6e5f A....subsection_ +// ELF-NEXT: 0x00000010 61000100 070b2000 00006165 6162695f a..... ...aeabi_ +// ELF-NEXT: 0x00000020 73756273 65637469 6f6e0001 01052256 subsection...."V +// ELF-NEXT: 0x00000030 616c7565 22001600 00007375 62736563 alue".....subsec +// ELF-NEXT: 0x00000040 74696f6e 5f620000 00069804 1a000000 tion_b.......... +// ELF-NEXT: 0x00000050 61656162 695f7061 75746861 62690000 aeabi_pauthabi.. +// ELF-NEXT: 0x00000060 00010902 89062300 00006165 6162695f ......#...aeabi_ +// ELF-NEXT: 0x00000070 66656174 7572655f 616e645f 62697473 feature_and_bits +// ELF-NEXT: 0x00000080 00010000 01010102 01 ......... .aeabi_subsection subsection_a, optional, uleb128 diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-none.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-none.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-none.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-numerical-tags.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-numerical-tags.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-numerical-tags.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-out-of-order.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-out-of-order.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-out-of-order.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-pac.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-aeabi-pac.s rename to llvm/test/MC/AArch64/build-attributes-asm-aeabi-pac.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi-err.s b/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi-err.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi-err.s rename to llvm/test/MC/AArch64/build-attributes-asm-non_aeabi-err.s diff --git a/llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi.s b/llvm/test/MC/AArch64/build-attributes-asm-non_aeabi.s similarity index 100% rename from llvm/test/MC/AArch64/aarch64-build-attributes-asm-non_aeabi.s rename to llvm/test/MC/AArch64/build-attributes-asm-non_aeabi.s From c1f74f9674d665325f847b2244d8c25e5647400d Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Thu, 20 Feb 2025 13:26:18 +0000 Subject: [PATCH 12/14] For llvm-mc, omit -o - (default) --- llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s | 4 ++-- llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s | 4 ++-- llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s | 4 ++-- llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s index 5fc8db404b45e..ecd7581e2a136 100644 --- a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-aeabi-known.s @@ -1,5 +1,5 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128 // ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform diff --git a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s index c6003e07e3eec..3e97acf5a3de4 100644 --- a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-bti.s @@ -1,5 +1,5 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI diff --git a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s index 91122fc4b5cf3..177d2499e2005 100644 --- a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-gcs.s @@ -1,5 +1,5 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128 // ASM: .aeabi_attribute 0, 0 // Tag_Feature_BTI diff --git a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s index f4b01182cc11a..96bb59b8cd0a5 100644 --- a/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s +++ b/llvm/test/MC/AArch64/build-attributes-asm-aeabi-mixed.s @@ -1,5 +1,5 @@ -// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF +// RUN: llvm-mc -triple=aarch64 %s | FileCheck %s --check-prefix=ASM +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF // ASM: .aeabi_subsection subsection_a, optional, uleb128 // ASM: .aeabi_subsection aeabi_subsection, optional, ntbs From d7517cd8a02f591edfe06fdac8148148e9a753cb Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Thu, 20 Feb 2025 15:09:36 +0000 Subject: [PATCH 13/14] handle unnecessary switch defaults --- .../lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 61c860341ca99..4ed2424d77b90 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -163,9 +163,6 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { unsigned VendorID = AArch64BuildAttrs::getVendorID(VendorName); switch (VendorID) { - default: - assert(0 && "Subsection name error"); - break; case AArch64BuildAttrs::VENDOR_UNKNOWN: if (unsigned(-1) != Value) { OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value; @@ -235,8 +232,8 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { StringRef ParameterStr = getTypeStr(ParameterType); switch (SubsectionID) { - default: { - // Treated as a private subsection + case AArch64BuildAttrs::VENDOR_UNKNOWN: { + // Private subsection break; } case AArch64BuildAttrs::AEABI_PAUTHABI: { From ae375582ad54ab0d49c7e9b516e2f3aff6d29ffe Mon Sep 17 00:00:00 2001 From: Sivan Shani Date: Mon, 24 Feb 2025 17:56:17 +0000 Subject: [PATCH 14/14] Remove unnecessary condition check when tag exists. --- .../MCTargetDesc/AArch64TargetStreamer.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp index 0221ab60352db..028d9196613cb 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp @@ -216,17 +216,11 @@ void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, for (MCELFStreamer::AttributeItem &Item : SubSection.Content) { // Tag already exists if (Item.Tag == Tag) { - // New value for existing tag: update tag - if ((unsigned(-1) != Value && Item.IntValue != Value) || - ("" != String && Item.StringValue != String)) { - Item.Type = unsigned(-1) != Value - ? MCELFStreamer::AttributeItem::NumericAttribute - : MCELFStreamer::AttributeItem::TextAttribute; - Item.IntValue = unsigned(-1) != Value ? Value : unsigned(-1); - Item.StringValue = unsigned(-1) != Value ? "" : String; - return; - } - // Same value for existing tag: do nothing + Item.Type = unsigned(-1) != Value + ? MCELFStreamer::AttributeItem::NumericAttribute + : MCELFStreamer::AttributeItem::TextAttribute; + Item.IntValue = unsigned(-1) != Value ? Value : unsigned(-1); + Item.StringValue = unsigned(-1) != Value ? "" : String; return; } }