[clang] [AMDGPU] Remove Code Object V2 (PR #65715)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 00:33:38 PDT 2023


llvmbot wrote:

@llvm/pr-subscribers-lld-elf

<details>
<summary>Changes</summary>

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).
--

Patch is 447.05 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/65715.diff

82 Files Affected:

- (modified) clang/include/clang/Basic/TargetOptions.h (+1-1) 
- (modified) clang/include/clang/Driver/Options.td (+2-2) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1) 
- (modified) clang/test/CodeGenCUDA/amdgpu-code-object-version.cu (-4) 
- (modified) clang/test/Driver/hip-code-object-version.hip (+10-13) 
- (modified) lld/test/ELF/Inputs/amdgpu-kernel-0.s (-1) 
- (modified) lld/test/ELF/Inputs/amdgpu-kernel-1.s (-1) 
- (modified) lld/test/ELF/amdgpu-abi-version-err.s (+2-2) 
- (modified) lld/test/ELF/amdgpu-elf-flags-err.s (+3-3) 
- (modified) lld/test/ELF/amdgpu-elf-flags.s (+2-2) 
- (removed) lld/test/ELF/amdgpu-kernels.s (-56) 
- (modified) llvm/docs/AMDGPUUsage.rst (+5-10) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp (+5-24) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp (-429) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h (-76) 
- (modified) llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp (+17-31) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+2-5) 
- (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp (+5-65) 
- (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h (+2-7) 
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.dispatch.id.ll (+2-4) 
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.dispatch.ptr.ll (+2-2) 
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.kernarg.segment.ptr.ll (+27-23) 
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.queue.ptr.ll (+2-2) 
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.workgroup.id.ll (+47-49) 
- (modified) llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.workitem.id.ll (+19-19) 
- (modified) llvm/test/CodeGen/AMDGPU/addrspacecast.ll (+28-20) 
- (modified) llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll (+15-19) 
- (modified) llvm/test/CodeGen/AMDGPU/attr-amdgpu-flat-work-group-size.ll (+10-12) 
- (modified) llvm/test/CodeGen/AMDGPU/call-graph-register-usage.ll (+4-14) 
- (modified) llvm/test/CodeGen/AMDGPU/callee-special-input-vgprs.ll (+19-10) 
- (modified) llvm/test/CodeGen/AMDGPU/control-flow-fastregalloc.ll (+5-4) 
- (modified) llvm/test/CodeGen/AMDGPU/flat-for-global-subtarget-feature.ll (+9-10) 
- (modified) llvm/test/CodeGen/AMDGPU/flat-scratch-reg.ll (+16-40) 
- (modified) llvm/test/CodeGen/AMDGPU/gfx902-without-xnack.ll (+2-3) 
- (modified) llvm/test/CodeGen/AMDGPU/hsa-default-device.ll (+2-2) 
- (modified) llvm/test/CodeGen/AMDGPU/hsa-fp-mode.ll (+28-28) 
- (modified) llvm/test/CodeGen/AMDGPU/hsa-func.ll (+11-11) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg-v2.ll (-35) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg.ll (-31) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-enqueue-kernel.ll (-92) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-from-llvm-ir-full.ll (-1931) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-hidden-args.ll (-313) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-images.ll (-95) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-invalid-ocl-version-1.ll (-11) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-invalid-ocl-version-2-v3.ll (-14) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-invalid-ocl-version-2.ll (-12) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-invalid-ocl-version-3.ll (-12) 
- (removed) llvm/test/CodeGen/AMDGPU/hsa-metadata-kernel-code-props.ll (-173) 
- (modified) llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll (+52-53) 
- (modified) llvm/test/CodeGen/AMDGPU/hsa.ll (+68-34) 
- (modified) llvm/test/CodeGen/AMDGPU/indirect-call.ll (+5-277) 
- (modified) llvm/test/CodeGen/AMDGPU/kernel-argument-dag-lowering.ll (+24-20) 
- (modified) llvm/test/CodeGen/AMDGPU/lds-alignment.ll (+15-28) 
- (modified) llvm/test/CodeGen/AMDGPU/lds-size.ll (+3-3) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.id.ll (+2-3) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll (+3-3) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.implicitarg.ptr.ll (+50-128) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.kernarg.segment.ptr.ll (+35-28) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.queue.ptr.ll (+2-2) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.workgroup.id.ll (+47-49) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.workitem.id.ll (+17-19) 
- (modified) llvm/test/CodeGen/AMDGPU/nop-data.ll (+2-2) 
- (removed) llvm/test/CodeGen/AMDGPU/private-element-size.ll (-252) 
- (modified) llvm/test/CodeGen/AMDGPU/promote-alloca-no-opts.ll (+3-3) 
- (modified) llvm/test/CodeGen/AMDGPU/promote-alloca-padding-size-estimate.ll (+4-4) 
- (removed) llvm/test/CodeGen/AMDGPU/tid-code-object-v2-backwards-compatibility.ll (-12) 
- (modified) llvm/test/CodeGen/AMDGPU/trap-abis.ll (-991) 
- (modified) llvm/test/CodeGen/AMDGPU/trap.ll (+3-5) 
- (modified) llvm/test/MC/AMDGPU/hsa-exp.s (+49-103) 
- (removed) llvm/test/MC/AMDGPU/hsa-gfx10.s (-284) 
- (removed) llvm/test/MC/AMDGPU/hsa-metadata-kernel-args.s (-70) 
- (removed) llvm/test/MC/AMDGPU/hsa-metadata-kernel-attrs.s (-32) 
- (removed) llvm/test/MC/AMDGPU/hsa-metadata-kernel-code-props.s (-34) 
- (removed) llvm/test/MC/AMDGPU/hsa-metadata-kernel-debug-props.s (-28) 
- (removed) llvm/test/MC/AMDGPU/hsa-metadata-unknown-key.s (-42) 
- (removed) llvm/test/MC/AMDGPU/hsa-text.s (-28) 
- (removed) llvm/test/MC/AMDGPU/hsa-wave-size.s (-65) 
- (removed) llvm/test/MC/AMDGPU/hsa.s (-274) 
- (removed) llvm/test/MC/AMDGPU/hsa_code_object_isa_args.s (-31) 
- (modified) llvm/test/MC/AMDGPU/isa-version-hsa.s (+8-8) 
- (modified) llvm/test/MC/AMDGPU/isa-version-pal.s (+4-3) 
- (modified) llvm/test/MC/AMDGPU/isa-version-unk.s (+4-3) 


<pre>
diff --git a/clang/include/clang/Basic/TargetOptions.h b/clang/include/clang/Basic/TargetOptions.h
index b192c856384b9ad..0dc324ff9ed43d9 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -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,
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index a5f5ca29053b43b..f68a8143737befd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4618,9 +4618,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",
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1db05b47e11ba6a..6041ef4aeb673ef 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -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)) {
diff --git a/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu b/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
index 16505b34c4a6e09..0ddd63faf46f28f 100644
--- a/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
@@ -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
 
@@ -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}
diff --git a/clang/test/Driver/hip-code-object-version.hip b/clang/test/Driver/hip-code-object-version.hip
index dc55ee1c2d42b4b..33559b6576e7d30 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -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 \
@@ -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
diff --git a/lld/test/ELF/Inputs/amdgpu-kernel-0.s b/lld/test/ELF/Inputs/amdgpu-kernel-0.s
index 1567c3fda10f9dd..c38270b49f7ea6b 100644
--- a/lld/test/ELF/Inputs/amdgpu-kernel-0.s
+++ b/lld/test/ELF/Inputs/amdgpu-kernel-0.s
@@ -1,6 +1,5 @@
 .text
 .globl kernel_0
 .align 64
-.amdgpu_hsa_kernel kernel_0
 kernel_0:
   s_endpgm
diff --git a/lld/test/ELF/Inputs/amdgpu-kernel-1.s b/lld/test/ELF/Inputs/amdgpu-kernel-1.s
index 7fb520bfbe32519..c61d11ff77d1cad 100644
--- a/lld/test/ELF/Inputs/amdgpu-kernel-1.s
+++ b/lld/test/ELF/Inputs/amdgpu-kernel-1.s
@@ -1,6 +1,5 @@
 .text
 .globl kernel_1
 .align 64
-.amdgpu_hsa_kernel kernel_1
 kernel_1:
   s_endpgm
diff --git a/lld/test/ELF/amdgpu-abi-version-err.s b/lld/test/ELF/amdgpu-abi-version-err.s
index e46352f260f5090..d7ce1d5e485aff5 100644
--- a/lld/test/ELF/amdgpu-abi-version-err.s
+++ b/lld/test/ELF/amdgpu-abi-version-err.s
@@ -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
diff --git a/lld/test/ELF/amdgpu-elf-flags-err.s b/lld/test/ELF/amdgpu-elf-flags-err.s
index 7d42fa2aa50d04d..8dfa4854abe25d4 100644
--- a/lld/test/ELF/amdgpu-elf-flags-err.s
+++ b/lld/test/ELF/amdgpu-elf-flags-err.s
@@ -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
diff --git a/lld/test/ELF/amdgpu-elf-flags.s b/lld/test/ELF/amdgpu-elf-flags.s
index b99e373bd7ce726..41d69af8e0b2004 100644
--- a/lld/test/ELF/amdgpu-elf-flags.s
+++ b/lld/test/ELF/amdgpu-elf-flags.s
@@ -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
 
diff --git a/lld/test/ELF/amdgpu-kernels.s b/lld/test/ELF/amdgpu-kernels.s
deleted file mode 100644
index b6ca85f6d218f3d..000000000000000
--- a/lld/test/ELF/amdgpu-kernels.s
+++ /dev/null
@@ -1,56 +0,0 @@
-# REQUIRES: amdgpu
-# RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri --amdhsa-code-object-version=2 %s -o %t.o
-# RUN: ld.lld -shared %t.o -o %t
-# RUN: llvm-readobj --sections --symbols -l %t | FileCheck %s
-
-.hsa_code_object_version 1,0
-.hsa_code_object_isa 7,0,0,"AMD","AMDGPU"
-
-.text
-.globl kernel0
-.align 256
-.amdgpu_hsa_kernel kernel0
-kernel0:
-  s_endpgm
-.Lfunc_end0:
-  .size kernel0, .Lfunc_end0-kernel0
-
-.globl kernel1
-.align 256
-.amdgpu_hsa_kernel kernel1
-kernel1:
-  s_endpgm
-  s_endpgm
-.Lfunc_end1:
-  .size kernel1, .Lfunc_end1-kernel1
-
-
-# CHECK: Section {
-# CHECK: Name: .text
-# CHECK: Type: SHT_PROGBITS
-# CHECK: Flags [ (0x6)
-# CHECK: SHF_ALLOC (0x2)
-# CHECK: SHF_EXECINSTR (0x4)
-# CHECK: ]
-# CHECK: }
-
-# CHECK: ProgramHeader {
-# CHECK:   Type: PT_LOAD
-
-# CHECK: Symbol {
-# CHECK: Name: kernel0
-# CHECK: Value:
-# CHECK: Size: 4
-# CHECK: Binding: Global
-# CHECK: Type: AMDGPU_HSA_KERNEL
-# CHECK: Section: .text
-# CHECK: }
-
-# CHECK: Symbol {
-# CHECK: Name: kernel1
-# CHECK: Value:
-# CHECK: Size: 8
-# CHECK: Binding: Global
-# CHECK: Type: AMDGPU_HSA_KERNEL
-# CHECK: Section: .text
-# CHECK: }
diff --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index f733c514ffbee47..8022816d7e616d3 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -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.
@@ -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`).
@@ -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.
@@ -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.
@@ -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:
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 70045e2d313eeda..6bc523d9789d065 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -121,26 +121,13 @@ 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) {
@@ -148,8 +135,7 @@ void AMDGPUAsmPrinter::emitEndOfAsmFile(Module &M) {
   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).
@@ -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;
@@ -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();
@@ -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;
   }
@@ -337,9 +321,6 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {
 
   if (TM.getTa...
<truncated>
</pre>

</details>

https://github.com/llvm/llvm-project/pull/65715


More information about the cfe-commits mailing list