From 1379b150991f70a5782e9a143c2ba5308da1161c Mon Sep 17 00:00:00 2001 From: David Green Date: Fri, 20 May 2022 09:31:00 +0100 Subject: [PATCH] [AArch64] Fix the generation of BE Nops Big endian Nops were being generated as d5 03 20 1f fnmadd s21, s30, s0, s0, getting the bytes of the NOP in the wrong order. This switches the bytes to not be dependant on the endianness. Differential Revision: https://reviews.llvm.org/D125980 --- .../AArch64/MCTargetDesc/AArch64AsmBackend.cpp | 2 +- llvm/test/MC/AArch64/align.s | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 llvm/test/MC/AArch64/align.s diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp index c1188d1c139e56..a57656ffb38bbb 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp @@ -471,7 +471,7 @@ bool AArch64AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count, // We are properly aligned, so write NOPs as requested. Count /= 4; for (uint64_t i = 0; i != Count; ++i) - support::endian::write(OS, 0xd503201f, Endian); + OS.write("\x1f\x20\x03\xd5", 4); return true; } diff --git a/llvm/test/MC/AArch64/align.s b/llvm/test/MC/AArch64/align.s new file mode 100644 index 00000000000000..fa9950f9877546 --- /dev/null +++ b/llvm/test/MC/AArch64/align.s @@ -0,0 +1,14 @@ +// RUN: llvm-mc -filetype=obj -triple aarch64-none-eabi %s | llvm-objdump -d - | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple aarch64_be-none-eabi %s | llvm-objdump -d - | FileCheck %s + +// CHECK: 0: 00 00 80 d2 mov x0, #0 +// CHECK: 4: 00 00 80 d2 mov x0, #0 +// CHECK: 8: 1f 20 03 d5 nop +// CHECK: c: 1f 20 03 d5 nop +// CHECK: 10: 00 00 80 d2 mov x0, #0 + + .text + mov x0, #0 + mov x0, #0 + .p2align 4 + mov x0, #0