Skip to content

Commit 223d2ba

Browse files
committed
[AMDGPU] Remove Code Object V2
Code Object V2 has been deprecated for more than a year now. We can safely remove it from LLVM. - [clang] Remove support for the `-mcode-object-version=2` option. - [lld] Remove/refactor tests that were still using COV2 - [llvm] Update AMDGPUUsage.rst - Code Object V2 docs are left for informational purposes because those code objects may still be supported by the runtime/loaders for a while. - [AMDGPU] Remove COV2 emission capabilities. - [AMDGPU] Remove `MetadataStreamerYamlV2` which was only used by COV2 - [AMDGPU] Update all tests that were still using COV2 - They are either deleted or ported directly to code object v4 (as v3 is also planned to be removed soon).
1 parent ca3ed7b commit 223d2ba

File tree

82 files changed

+705
-6645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+705
-6645
lines changed

clang/include/clang/Basic/TargetOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TargetOptions {
8282
/// code object version times 100.
8383
enum CodeObjectVersionKind {
8484
COV_None,
85-
COV_2 = 200,
85+
COV_2 = 200, // Unsupported.
8686
COV_3 = 300,
8787
COV_4 = 400,
8888
COV_5 = 500,

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,9 +4624,9 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
46244624
def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group<m_Group>,
46254625
HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
46264626
Visibility<[ClangOption, CC1Option]>,
4627-
Values<"none,2,3,4,5">,
4627+
Values<"none,3,4,5">,
46284628
NormalizedValuesScope<"TargetOptions">,
4629-
NormalizedValues<["COV_None", "COV_2", "COV_3", "COV_4", "COV_5"]>,
4629+
NormalizedValues<["COV_None", "COV_3", "COV_4", "COV_5"]>,
46304630
MarshallingInfoEnum<TargetOpts<"CodeObjectVersion">, "COV_4">;
46314631

46324632
defm cumode : SimpleMFlag<"cumode",

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
23232323

23242324
void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
23252325
const llvm::opt::ArgList &Args) {
2326-
const unsigned MinCodeObjVer = 2;
2326+
const unsigned MinCodeObjVer = 3;
23272327
const unsigned MaxCodeObjVer = 5;
23282328

23292329
if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {

clang/test/CodeGenCUDA/amdgpu-code-object-version.cu

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
44
// RUN: -o - %s | FileCheck %s -check-prefix=V4
55

6-
// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
7-
// RUN: -mcode-object-version=2 -o - %s | FileCheck -check-prefix=V2 %s
8-
96
// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
107
// RUN: -mcode-object-version=3 -o - %s | FileCheck -check-prefix=V3 %s
118

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

24-
// V2: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 200}
2521
// V3: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 300}
2622
// V4: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 400}
2723
// V5: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 500}

clang/test/Driver/hip-code-object-version.hip

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
// REQUIRES: amdgpu-registered-target
22

3-
// Check bundle ID for code object v2.
4-
5-
// RUN: not %clang -### --target=x86_64-linux-gnu \
6-
// RUN: -mcode-object-version=2 \
7-
// RUN: --offload-arch=gfx906 --rocm-path=%S/Inputs/rocm \
8-
// RUN: %s 2>&1 | FileCheck -check-prefix=V2 %s
9-
10-
// V2: "-mllvm" "--amdhsa-code-object-version=2"
11-
// V2: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
12-
133
// Check bundle ID for code object v3.
144

155
// RUN: not %clang -### --target=x86_64-linux-gnu \
@@ -61,9 +51,16 @@
6151
// RUN: not %clang -### --target=x86_64-linux-gnu \
6252
// RUN: -mcode-object-version=1 \
6353
// RUN: --offload-arch=gfx906 --rocm-path=%S/Inputs/rocm \
64-
// RUN: %s 2>&1 | FileCheck -check-prefix=INVALID %s
65-
// INVALID: error: invalid integral value '1' in '-mcode-object-version=1'
66-
// INVALID-NOT: error: invalid integral value
54+
// RUN: %s 2>&1 | FileCheck -check-prefix=INVALID_1 %s
55+
// INVALID_1: error: invalid integral value '1' in '-mcode-object-version=1'
56+
// INVALID_1-NOT: error: invalid integral value
57+
58+
// RUN: not %clang -### --target=x86_64-linux-gnu \
59+
// RUN: -mcode-object-version=2 \
60+
// RUN: --offload-arch=gfx906 --rocm-path=%S/Inputs/rocm \
61+
// RUN: %s 2>&1 | FileCheck -check-prefix=INVALID_2 %s
62+
// INVALID_2: error: invalid integral value '2' in '-mcode-object-version=2'
63+
// INVALID_2-NOT: error: invalid integral value
6764

6865
// Check LLVM code object version option --amdhsa-code-object-version
6966
// is passed to -cc1 and -cc1as, and -mcode-object-version is passed

lld/test/ELF/Inputs/amdgpu-kernel-0.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.text
22
.globl kernel_0
33
.align 64
4-
.amdgpu_hsa_kernel kernel_0
54
kernel_0:
65
s_endpgm

lld/test/ELF/Inputs/amdgpu-kernel-1.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.text
22
.globl kernel_1
33
.align 64
4-
.amdgpu_hsa_kernel kernel_1
54
kernel_1:
65
s_endpgm

lld/test/ELF/amdgpu-abi-version-err.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: amdgpu
2-
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 -filetype=obj %s -o %t-0.o
3-
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=2 -filetype=obj %s -o %t-1.o
2+
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=4 -filetype=obj %s -o %t-0.o
3+
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=5 -filetype=obj %s -o %t-1.o
44
# RUN: not ld.lld -shared %t-0.o %t-1.o -o /dev/null 2>&1 | FileCheck %s
55

66
# CHECK: ld.lld: error: incompatible ABI version: {{.*}}-1.o

lld/test/ELF/amdgpu-elf-flags-err.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: amdgpu
2-
# 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
3-
# 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
2+
# 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
3+
# 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
44
# RUN: not ld.lld -shared %t-0.o %t-1.o -o /dev/null 2>&1 | FileCheck %s
55

6-
# CHECK: error: incompatible e_flags: {{.*}}-1.o
6+
# CHECK: error: incompatible mach: {{.*}}-1.o

lld/test/ELF/amdgpu-elf-flags.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: amdgpu
2-
# 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
3-
# 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
2+
# 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
3+
# 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
44
# RUN: ld.lld -shared %t-0.o %t-1.o -o %t.so
55
# RUN: llvm-readobj --file-headers %t.so | FileCheck --check-prefix=FIRSTLINK %s
66

lld/test/ELF/amdgpu-kernels.s

Lines changed: 0 additions & 56 deletions
This file was deleted.

llvm/docs/AMDGPUUsage.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,8 +1705,7 @@ Code Object V2 Note Records
17051705
~~~~~~~~~~~~~~~~~~~~~~~~~~~
17061706

17071707
.. warning::
1708-
Code object V2 is not the default code object version emitted by
1709-
this version of LLVM.
1708+
Code object V2 generation is no longer supported by this version of LLVM.
17101709

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

29762975
.. warning::
2977-
Code object V2 is not the default code object version emitted by this version
2978-
of LLVM.
2976+
Code object V2 generation is no longer supported by this version of LLVM.
29792977

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

1495714955
.. warning::
14958-
Code object V2 is not the default code object version emitted by
14959-
this version of LLVM.
14956+
Code object V2 generation is no longer supported by this version of LLVM.
1496014957

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

1501315010
.. warning::
15014-
Code object V2 is not the default code object version emitted by
15015-
this version of LLVM.
15011+
Code object V2 generation is no longer supported by this version of LLVM.
1501615012

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

1508915085
.. warning::
15090-
Code Object V2 is not the default code object version emitted by
15091-
this version of LLVM.
15086+
Code object V2 generation is no longer supported by this version of LLVM.
1509215087

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

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,35 +121,21 @@ void AMDGPUAsmPrinter::initTargetStreamer(Module &M) {
121121
TM.getTargetTriple().getOS() != Triple::AMDPAL)
122122
return;
123123

124-
if (CodeObjectVersion >= AMDGPU::AMDHSA_COV3)
125-
getTargetStreamer()->EmitDirectiveAMDGCNTarget();
124+
getTargetStreamer()->EmitDirectiveAMDGCNTarget();
126125

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

130129
if (TM.getTargetTriple().getOS() == Triple::AMDPAL)
131130
getTargetStreamer()->getPALMetadata()->readFromIR(M);
132-
133-
if (CodeObjectVersion >= AMDGPU::AMDHSA_COV3)
134-
return;
135-
136-
// HSA emits NT_AMD_HSA_CODE_OBJECT_VERSION for code objects v2.
137-
if (TM.getTargetTriple().getOS() == Triple::AMDHSA)
138-
getTargetStreamer()->EmitDirectiveHSACodeObjectVersion(2, 1);
139-
140-
// HSA and PAL emit NT_AMD_HSA_ISA_VERSION for code objects v2.
141-
IsaVersion Version = getIsaVersion(getGlobalSTI()->getCPU());
142-
getTargetStreamer()->EmitDirectiveHSACodeObjectISAV2(
143-
Version.Major, Version.Minor, Version.Stepping, "AMD", "AMDGPU");
144131
}
145132

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

151-
if (TM.getTargetTriple().getOS() != Triple::AMDHSA ||
152-
CodeObjectVersion == AMDGPU::AMDHSA_COV2)
138+
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
153139
getTargetStreamer()->EmitISAVersion();
154140

155141
// Emit HSA Metadata (NT_AMD_AMDGPU_HSA_METADATA).
@@ -209,7 +195,7 @@ void AMDGPUAsmPrinter::emitFunctionBodyStart() {
209195
if (!MFI.isEntryFunction())
210196
return;
211197

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

229-
if (TM.getTargetTriple().getOS() != Triple::AMDHSA ||
230-
CodeObjectVersion == AMDGPU::AMDHSA_COV2)
215+
if (TM.getTargetTriple().getOS() != Triple::AMDHSA)
231216
return;
232217

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

263248
void AMDGPUAsmPrinter::emitFunctionEntryLabel() {
264-
if (TM.getTargetTriple().getOS() == Triple::AMDHSA &&
265-
CodeObjectVersion >= AMDGPU::AMDHSA_COV3) {
249+
if (TM.getTargetTriple().getOS() == Triple::AMDHSA) {
266250
AsmPrinter::emitFunctionEntryLabel();
267251
return;
268252
}
@@ -337,9 +321,6 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {
337321

338322
if (TM.getTargetTriple().getOS() == Triple::AMDHSA) {
339323
switch (CodeObjectVersion) {
340-
case AMDGPU::AMDHSA_COV2:
341-
HSAMetadataStream.reset(new HSAMD::MetadataStreamerYamlV2());
342-
break;
343324
case AMDGPU::AMDHSA_COV3:
344325
HSAMetadataStream.reset(new HSAMD::MetadataStreamerMsgPackV3());
345326
break;

0 commit comments

Comments
 (0)