Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMDGPU] Remove Code Object V2 #65715

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class TargetOptions {
/// code object version times 100.
enum CodeObjectVersionKind {
COV_None,
COV_2 = 200,
COV_2 = 200, // Unsupported.
COV_3 = 300,
COV_4 = 400,
COV_5 = 500,
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -4624,9 +4624,9 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group<m_Group>,
HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
Visibility<[ClangOption, CC1Option]>,
Values<"none,2,3,4,5">,
Values<"none,3,4,5">,
NormalizedValuesScope<"TargetOptions">,
NormalizedValues<["COV_None", "COV_2", "COV_3", "COV_4", "COV_5"]>,
NormalizedValues<["COV_None", "COV_3", "COV_4", "COV_5"]>,
MarshallingInfoEnum<TargetOpts<"CodeObjectVersion">, "COV_4">;

defm cumode : SimpleMFlag<"cumode",
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@ getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {

void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
const llvm::opt::ArgList &Args) {
const unsigned MinCodeObjVer = 2;
const unsigned MinCodeObjVer = 3;
const unsigned MaxCodeObjVer = 5;

if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
Expand Down
4 changes: 0 additions & 4 deletions clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
// RUN: -o - %s | FileCheck %s -check-prefix=V4

// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
// RUN: -mcode-object-version=2 -o - %s | FileCheck -check-prefix=V2 %s

// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
// RUN: -mcode-object-version=3 -o - %s | FileCheck -check-prefix=V3 %s

Expand All @@ -21,7 +18,6 @@
// RUN: not %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
// RUN: -mcode-object-version=4.1 -o - %s 2>&1| FileCheck %s -check-prefix=INV

// V2: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 200}
// V3: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 300}
// V4: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 400}
// V5: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 500}
Expand Down
23 changes: 10 additions & 13 deletions clang/test/Driver/hip-code-object-version.hip
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
// REQUIRES: amdgpu-registered-target

// Check bundle ID for code object v2.

// RUN: not %clang -### --target=x86_64-linux-gnu \
// RUN: -mcode-object-version=2 \
// RUN: --offload-arch=gfx906 --rocm-path=%S/Inputs/rocm \
// RUN: %s 2>&1 | FileCheck -check-prefix=V2 %s

// V2: "-mllvm" "--amdhsa-code-object-version=2"
// V2: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"

// Check bundle ID for code object v3.

// RUN: not %clang -### --target=x86_64-linux-gnu \
Expand Down Expand Up @@ -61,9 +51,16 @@
// RUN: not %clang -### --target=x86_64-linux-gnu \
// RUN: -mcode-object-version=1 \
// RUN: --offload-arch=gfx906 --rocm-path=%S/Inputs/rocm \
// RUN: %s 2>&1 | FileCheck -check-prefix=INVALID %s
// INVALID: error: invalid integral value '1' in '-mcode-object-version=1'
// INVALID-NOT: error: invalid integral value
// RUN: %s 2>&1 | FileCheck -check-prefix=INVALID_1 %s
// INVALID_1: error: invalid integral value '1' in '-mcode-object-version=1'
// INVALID_1-NOT: error: invalid integral value

// RUN: not %clang -### --target=x86_64-linux-gnu \
// RUN: -mcode-object-version=2 \
// RUN: --offload-arch=gfx906 --rocm-path=%S/Inputs/rocm \
// RUN: %s 2>&1 | FileCheck -check-prefix=INVALID_2 %s
// INVALID_2: error: invalid integral value '2' in '-mcode-object-version=2'
// INVALID_2-NOT: error: invalid integral value

// Check LLVM code object version option --amdhsa-code-object-version
// is passed to -cc1 and -cc1as, and -mcode-object-version is passed
Expand Down
1 change: 0 additions & 1 deletion lld/test/ELF/Inputs/amdgpu-kernel-0.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.text
.globl kernel_0
.align 64
.amdgpu_hsa_kernel kernel_0
kernel_0:
s_endpgm
1 change: 0 additions & 1 deletion lld/test/ELF/Inputs/amdgpu-kernel-1.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.text
.globl kernel_1
.align 64
.amdgpu_hsa_kernel kernel_1
kernel_1:
s_endpgm
4 changes: 2 additions & 2 deletions lld/test/ELF/amdgpu-abi-version-err.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: amdgpu
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=obj %s -o %t-0.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=2 -filetype=obj %s -o %t-1.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=4 -filetype=obj %s -o %t-0.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=5 -filetype=obj %s -o %t-1.o
# RUN: not ld.lld -shared %t-0.o %t-1.o -o /dev/null 2>&1 | FileCheck %s

# CHECK: ld.lld: error: incompatible ABI version: {{.*}}-1.o
Expand Down
6 changes: 3 additions & 3 deletions lld/test/ELF/amdgpu-elf-flags-err.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: amdgpu
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx802 --amdhsa-code-object-version=2 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 --amdhsa-code-object-version=2 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx802 --amdhsa-code-object-version=4 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 --amdhsa-code-object-version=4 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
# RUN: not ld.lld -shared %t-0.o %t-1.o -o /dev/null 2>&1 | FileCheck %s

# CHECK: error: incompatible e_flags: {{.*}}-1.o
# CHECK: error: incompatible mach: {{.*}}-1.o
4 changes: 2 additions & 2 deletions lld/test/ELF/amdgpu-elf-flags.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: amdgpu
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 --amdhsa-code-object-version=2 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 --amdhsa-code-object-version=2 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 --amdhsa-code-object-version=4 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 --amdhsa-code-object-version=4 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
# RUN: ld.lld -shared %t-0.o %t-1.o -o %t.so
# RUN: llvm-readobj --file-headers %t.so | FileCheck --check-prefix=FIRSTLINK %s

Expand Down
56 changes: 0 additions & 56 deletions lld/test/ELF/amdgpu-kernels.s

This file was deleted.

15 changes: 5 additions & 10 deletions llvm/docs/AMDGPUUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,7 @@ Code Object V2 Note Records
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. warning::
Code object V2 is not the default code object version emitted by
this version of LLVM.
Code object V2 generation is no longer supported by this version of LLVM.

The AMDGPU backend code object uses the following ELF note record in the
``.note`` section when compiling for code object V2.
Expand Down Expand Up @@ -2974,8 +2973,7 @@ Code Object V2 Metadata
+++++++++++++++++++++++

.. warning::
Code object V2 is not the default code object version emitted by this version
of LLVM.
Code object V2 generation is no longer supported by this version of LLVM.

Code object V2 metadata is specified by the ``NT_AMD_HSA_METADATA`` note record
(see :ref:`amdgpu-note-records-v2`).
Expand Down Expand Up @@ -14955,8 +14953,7 @@ Code Object V2 Predefined Symbols
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. warning::
Code object V2 is not the default code object version emitted by
this version of LLVM.
Code object V2 generation is no longer supported by this version of LLVM.

The AMDGPU assembler defines and updates some symbols automatically. These
symbols do not affect code generation.
Expand Down Expand Up @@ -15011,8 +15008,7 @@ Code Object V2 Directives
~~~~~~~~~~~~~~~~~~~~~~~~~

.. warning::
Code object V2 is not the default code object version emitted by
this version of LLVM.
Code object V2 generation is no longer supported by this version of LLVM.

AMDGPU ABI defines auxiliary data in output code object. In assembly source,
one can specify them with assembler directives.
Expand Down Expand Up @@ -15087,8 +15083,7 @@ Code Object V2 Example Source Code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. warning::
Code Object V2 is not the default code object version emitted by
this version of LLVM.
Code object V2 generation is no longer supported by this version of LLVM.

Here is an example of a minimal assembly source file, defining one HSA kernel:

Expand Down
29 changes: 5 additions & 24 deletions llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,35 +121,21 @@ void AMDGPUAsmPrinter::initTargetStreamer(Module &M) {
TM.getTargetTriple().getOS() != Triple::AMDPAL)
return;

if (CodeObjectVersion >= AMDGPU::AMDHSA_COV3)
getTargetStreamer()->EmitDirectiveAMDGCNTarget();
getTargetStreamer()->EmitDirectiveAMDGCNTarget();

if (TM.getTargetTriple().getOS() == Triple::AMDHSA)
HSAMetadataStream->begin(M, *getTargetStreamer()->getTargetID());

if (TM.getTargetTriple().getOS() == Triple::AMDPAL)
getTargetStreamer()->getPALMetadata()->readFromIR(M);

if (CodeObjectVersion >= AMDGPU::AMDHSA_COV3)
return;

// HSA emits NT_AMD_HSA_CODE_OBJECT_VERSION for code objects v2.
if (TM.getTargetTriple().getOS() == Triple::AMDHSA)
getTargetStreamer()->EmitDirectiveHSACodeObjectVersion(2, 1);

// HSA and PAL emit NT_AMD_HSA_ISA_VERSION for code objects v2.
IsaVersion Version = getIsaVersion(getGlobalSTI()->getCPU());
getTargetStreamer()->EmitDirectiveHSACodeObjectISAV2(
Version.Major, Version.Minor, Version.Stepping, "AMD", "AMDGPU");
}

void AMDGPUAsmPrinter::emitEndOfAsmFile(Module &M) {
// Init target streamer if it has not yet happened
if (!IsTargetStreamerInitialized)
initTargetStreamer(M);

if (TM.getTargetTriple().getOS() != Triple::AMDHSA ||
CodeObjectVersion == AMDGPU::AMDHSA_COV2)
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
getTargetStreamer()->EmitISAVersion();

// Emit HSA Metadata (NT_AMD_AMDGPU_HSA_METADATA).
Expand Down Expand Up @@ -209,7 +195,7 @@ void AMDGPUAsmPrinter::emitFunctionBodyStart() {
if (!MFI.isEntryFunction())
return;

if ((STM.isMesaKernel(F) || CodeObjectVersion == AMDGPU::AMDHSA_COV2) &&
if (STM.isMesaKernel(F) &&
(F.getCallingConv() == CallingConv::AMDGPU_KERNEL ||
F.getCallingConv() == CallingConv::SPIR_KERNEL)) {
amd_kernel_code_t KernelCode;
Expand All @@ -226,8 +212,7 @@ void AMDGPUAsmPrinter::emitFunctionBodyEnd() {
if (!MFI.isEntryFunction())
return;

if (TM.getTargetTriple().getOS() != Triple::AMDHSA ||
CodeObjectVersion == AMDGPU::AMDHSA_COV2)
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
return;

auto &Streamer = getTargetStreamer()->getStreamer();
Expand Down Expand Up @@ -261,8 +246,7 @@ void AMDGPUAsmPrinter::emitFunctionBodyEnd() {
}

void AMDGPUAsmPrinter::emitFunctionEntryLabel() {
if (TM.getTargetTriple().getOS() == Triple::AMDHSA &&
CodeObjectVersion >= AMDGPU::AMDHSA_COV3) {
if (TM.getTargetTriple().getOS() == Triple::AMDHSA) {
AsmPrinter::emitFunctionEntryLabel();
return;
}
Expand Down Expand Up @@ -337,9 +321,6 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {

if (TM.getTargetTriple().getOS() == Triple::AMDHSA) {
switch (CodeObjectVersion) {
case AMDGPU::AMDHSA_COV2:
HSAMetadataStream.reset(new HSAMD::MetadataStreamerYamlV2());
break;
case AMDGPU::AMDHSA_COV3:
HSAMetadataStream.reset(new HSAMD::MetadataStreamerMsgPackV3());
break;
Expand Down
Loading