[llvm] e4a9e4e - [AMDGPU] Emit correct kernel descriptor on big-endian hosts
Scott Linder via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 10:30:52 PDT 2020
Author: Scott Linder
Date: 2020-10-06T17:29:38Z
New Revision: e4a9e4ef554a90637c53d4f10326c262df69b76c
URL: https://github.com/llvm/llvm-project/commit/e4a9e4ef554a90637c53d4f10326c262df69b76c
DIFF: https://github.com/llvm/llvm-project/commit/e4a9e4ef554a90637c53d4f10326c262df69b76c.diff
LOG: [AMDGPU] Emit correct kernel descriptor on big-endian hosts
Previously we wrote multi-byte values out as-is from host memory. Use
the `emitIntN` helpers in `MCStreamer` to produce a valid descriptor
irrespective of the host endianness.
Reviewed By: arsenm, rochauha
Differential Revision: https://reviews.llvm.org/D88858
Added:
Modified:
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/test/MC/AMDGPU/hsa-sgpr-init-bug-v3.s
llvm/test/MC/AMDGPU/hsa-v3.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
index 344f22d412e7..9d662eca45a6 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
@@ -656,9 +656,10 @@ void AMDGPUTargetELFStreamer::EmitAmdhsaKernelDescriptor(
KernelCodeSymbol->setVisibility(ELF::STV_PROTECTED);
Streamer.emitLabel(KernelDescriptorSymbol);
- Streamer.emitBytes(StringRef(
- (const char*)&(KernelDescriptor),
- offsetof(amdhsa::kernel_descriptor_t, kernel_code_entry_byte_offset)));
+ Streamer.emitInt32(KernelDescriptor.group_segment_fixed_size);
+ Streamer.emitInt32(KernelDescriptor.private_segment_fixed_size);
+ for (uint8_t Res : KernelDescriptor.reserved0)
+ Streamer.emitInt8(Res);
// FIXME: Remove the use of VK_AMDGPU_REL64 in the expression below. The
// expression being created is:
// (start of kernel code) - (start of kernel descriptor)
@@ -670,11 +671,12 @@ void AMDGPUTargetELFStreamer::EmitAmdhsaKernelDescriptor(
KernelDescriptorSymbol, MCSymbolRefExpr::VK_None, Context),
Context),
sizeof(KernelDescriptor.kernel_code_entry_byte_offset));
- Streamer.emitBytes(StringRef(
- (const char*)&(KernelDescriptor) +
- offsetof(amdhsa::kernel_descriptor_t, kernel_code_entry_byte_offset) +
- sizeof(KernelDescriptor.kernel_code_entry_byte_offset),
- sizeof(KernelDescriptor) -
- offsetof(amdhsa::kernel_descriptor_t, kernel_code_entry_byte_offset) -
- sizeof(KernelDescriptor.kernel_code_entry_byte_offset)));
+ for (uint8_t Res : KernelDescriptor.reserved1)
+ Streamer.emitInt8(Res);
+ Streamer.emitInt32(KernelDescriptor.compute_pgm_rsrc3);
+ Streamer.emitInt32(KernelDescriptor.compute_pgm_rsrc1);
+ Streamer.emitInt32(KernelDescriptor.compute_pgm_rsrc2);
+ Streamer.emitInt16(KernelDescriptor.kernel_code_properties);
+ for (uint8_t Res : KernelDescriptor.reserved2)
+ Streamer.emitInt8(Res);
}
diff --git a/llvm/test/MC/AMDGPU/hsa-sgpr-init-bug-v3.s b/llvm/test/MC/AMDGPU/hsa-sgpr-init-bug-v3.s
index 644d957d59ea..35237c439ef9 100644
--- a/llvm/test/MC/AMDGPU/hsa-sgpr-init-bug-v3.s
+++ b/llvm/test/MC/AMDGPU/hsa-sgpr-init-bug-v3.s
@@ -1,9 +1,6 @@
// RUN: llvm-mc -mattr=+code-object-v3 -triple amdgcn-amd-amdhsa -mcpu=gfx802 -filetype=obj < %s > %t
// RUN: llvm-objdump -s -j .rodata %t | FileCheck --check-prefix=OBJDUMP %s
-// big endian not supported
-// XFAIL: host-byteorder-big-endian
-
// Check that SGPR init bug on gfx803 is corrected by the assembler, setting
// GRANULATED_WAVEFRONT_SGPR_COUNT to 11.
diff --git a/llvm/test/MC/AMDGPU/hsa-v3.s b/llvm/test/MC/AMDGPU/hsa-v3.s
index 3c2ddecefcc1..a995b1be16b6 100644
--- a/llvm/test/MC/AMDGPU/hsa-v3.s
+++ b/llvm/test/MC/AMDGPU/hsa-v3.s
@@ -3,9 +3,6 @@
// RUN: llvm-readelf -sections -symbols -relocations %t | FileCheck --check-prefix=READOBJ %s
// RUN: llvm-objdump -s -j .rodata %t | FileCheck --check-prefix=OBJDUMP %s
-// big endian not supported
-// XFAIL: host-byteorder-big-endian
-
// READOBJ: Section Headers
// READOBJ: .text PROGBITS {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9]+}} AX {{[0-9]+}} {{[0-9]+}} 256
// READOBJ: .rodata PROGBITS {{[0-9a-f]+}} {{[0-9a-f]+}} 000100 {{[0-9]+}} A {{[0-9]+}} {{[0-9]+}} 64
More information about the llvm-commits
mailing list