Skip to content

Commit afd04f3

Browse files
author
git apple-llvm automerger
committed
Merge commit '952bc48e5b9c' from apple/main into swift/next
2 parents 5c07f7b + 952bc48 commit afd04f3

File tree

135 files changed

+521
-511
lines changed

Some content is hidden

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

135 files changed

+521
-511
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2937,7 +2937,7 @@ AMDGPU
29372937
------
29382938
.. option:: -mcode-object-v3, -mno-code-object-v3
29392939

2940-
Enable code object v3 (AMDGPU only)
2940+
Legacy option to specify code object v3 (AMDGPU only)
29412941

29422942
.. option:: -mcumode, -mno-cumode
29432943

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,10 +2508,11 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, Group<m_wasm_Features_Driver
25082508
Values<"command,reactor">,
25092509
HelpText<"Execution model (WebAssembly only)">;
25102510

2511-
def mcode_object_v3 : Flag<["-"], "mcode-object-v3">, Group<m_amdgpu_Features_Group>,
2512-
HelpText<"Enable code object v3 (AMDGPU only)">;
2513-
def mno_code_object_v3 : Flag<["-"], "mno-code-object-v3">, Group<m_amdgpu_Features_Group>,
2514-
HelpText<"Disable code object v3 (AMDGPU only)">;
2511+
def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group<m_Group>,
2512+
HelpText<"Legacy option to specify code object v3 (AMDGPU only)">;
2513+
def mno_code_object_v3_legacy : Flag<["-"], "mno-code-object-v3">, Group<m_Group>,
2514+
HelpText<"Legacy option to specify code object v2 (AMDGPU only)">;
2515+
25152516
def mxnack : Flag<["-"], "mxnack">, Group<m_amdgpu_Features_Group>,
25162517
HelpText<"Enable XNACK (AMDGPU only)">;
25172518
def mno_xnack : Flag<["-"], "mno-xnack">, Group<m_amdgpu_Features_Group>,

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,19 @@ void AMDGPUToolChain::addClangTargetOptions(
525525
CC1Args.push_back("hidden");
526526
CC1Args.push_back("-fapply-global-visibility-to-externs");
527527
}
528+
529+
if (DriverArgs.hasArg(options::OPT_mcode_object_v3_legacy)) {
530+
getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3" <<
531+
"-mllvm --amdhsa-code-object-version=3";
532+
CC1Args.push_back("-mllvm");
533+
CC1Args.push_back("--amdhsa-code-object-version=3");
534+
}
535+
if (DriverArgs.hasArg(options::OPT_mno_code_object_v3_legacy)) {
536+
getDriver().Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3" <<
537+
"-mllvm --amdhsa-code-object-version=2";
538+
CC1Args.push_back("-mllvm");
539+
CC1Args.push_back("--amdhsa-code-object-version=2");
540+
}
528541
}
529542

530543
StringRef

clang/test/Driver/amdgpu-features.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// RUN: %clang -### -target amdgcn -mcpu=gfx700 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
2-
// CODE-OBJECT-V3: "-target-feature" "+code-object-v3"
1+
// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx700 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
2+
// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=3' instead [-Wdeprecated]
3+
// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
34

4-
// RUN: %clang -### -target amdgcn -mcpu=gfx700 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
5-
// NO-CODE-OBJECT-V3: "-target-feature" "-code-object-v3"
5+
// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx700 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
6+
// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mllvm --amdhsa-code-object-version=2' instead [-Wdeprecated]
7+
// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
68

79
// RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx900:xnack+ %s 2>&1 | FileCheck --check-prefix=XNACK %s
810
// XNACK: "-target-feature" "+xnack"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: amdgpu
22
# 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 -mattr=-code-object-v3 -filetype=obj %s -o %t-1.o
3+
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx900 --amdhsa-code-object-version=2 -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: 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=gfx802 -mattr=-code-object-v3 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
3-
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=-code-object-v3 -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=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
44
# RUN: not ld.lld -shared %t-0.o %t-1.o -o /dev/null 2>&1 | FileCheck %s
55

66
# CHECK: error: incompatible e_flags: {{.*}}-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 -mattr=-code-object-v3 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
3-
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=-code-object-v3 -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=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
44
# RUN: ld.lld -shared %t-0.o %t-1.o -o %t.so
55
# RUN: llvm-readobj --file-headers %t.so | FileCheck %s
66

lld/test/ELF/amdgpu-kernels.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# REQUIRES: amdgpu
2-
# RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri -mattr=-code-object-v3 %s -o %t.o
2+
# RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri --amdhsa-code-object-version=2 %s -o %t.o
33
# RUN: ld.lld -shared %t.o -o %t
44
# RUN: llvm-readobj --sections --symbols -l %t | FileCheck %s
55

lld/test/ELF/lto/amdgcn-oses.ll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88

99
; RUN: llvm-as %t/amdpal.ll -o %t/amdpal.o
1010
; RUN: ld.lld %t/amdpal.o -o %t/amdpal.so
11-
; RUN: llvm-readobj --file-headers %t/amdpal.so | FileCheck %s --check-prefixes=GCN,AMDPAL
11+
; RUN: llvm-readobj --file-headers %t/amdpal.so | FileCheck %s --check-prefixes=GCN,NON-AMDHSA,AMDPAL
1212

1313
; RUN: llvm-as %t/mesa3d.ll -o %t/mesa3d.o
1414
; RUN: ld.lld %t/mesa3d.o -o %t/mesa3d.so
15-
; RUN: llvm-readobj --file-headers %t/mesa3d.so | FileCheck %s --check-prefixes=GCN,MESA3D
15+
; RUN: llvm-readobj --file-headers %t/mesa3d.so | FileCheck %s --check-prefixes=GCN,NON-AMDHSA,MESA3D
1616

1717
; AMDHSA: OS/ABI: AMDGPU_HSA (0x40)
18+
; AMDHSA: ABIVersion: 1
19+
1820
; AMDPAL: OS/ABI: AMDGPU_PAL (0x41)
1921
; MESA3D: OS/ABI: AMDGPU_MESA3D (0x42)
20-
; GCN: ABIVersion: 0
22+
; NON-AMDHSA: ABIVersion: 0
2123

2224
;--- amdhsa.ll
2325
target triple = "amdgcn-amd-amdhsa"

llvm/docs/AMDGPUUsage.rst

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -907,15 +907,16 @@ alignment.
907907

908908
.. _amdgpu-note-records-v2:
909909

910-
Code Object V2 Note Records (-mattr=-code-object-v3)
911-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
910+
Code Object V2 Note Records (--amdhsa-code-object-version=2)
911+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
912912

913913
.. warning:: Code Object V2 is not the default code object version emitted by
914914
this version of LLVM. For a description of the notes generated with the
915915
default configuration (Code Object V3) see :ref:`amdgpu-note-records-v3`.
916916

917917
The AMDGPU backend code object uses the following ELF note record in the
918-
``.note`` section when compiling for Code Object V2 (-mattr=-code-object-v3).
918+
``.note`` section when compiling for Code Object
919+
V2 (--amdhsa-code-object-version=2).
919920

920921
Additional note records may be present, but any which are not documented here
921922
are deprecated and should not be used.
@@ -951,11 +952,12 @@ are deprecated and should not be used.
951952

952953
.. _amdgpu-note-records-v3:
953954

954-
Code Object V3 Note Records (-mattr=+code-object-v3)
955-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
955+
Code Object V3 Note Records (--amdhsa-code-object-version=3)
956+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
956957

957958
The AMDGPU backend code object uses the following ELF note record in the
958-
``.note`` section when compiling for Code Object V3 (-mattr=+code-object-v3).
959+
``.note`` section when compiling for Code Object V3
960+
(--amdhsa-code-object-version=3).
959961

960962
Additional note records may be present, but any which are not documented here
961963
are deprecated and should not be used.
@@ -2072,8 +2074,8 @@ OpenCL runtime records kernel argument information.
20722074

20732075
.. _amdgpu-amdhsa-code-object-metadata-v2:
20742076

2075-
Code Object V2 Metadata (-mattr=-code-object-v3)
2076-
++++++++++++++++++++++++++++++++++++++++++++++++
2077+
Code Object V2 Metadata (--amdhsa-code-object-version=2)
2078+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20772079

20782080
.. warning:: Code Object V2 is not the default code object version emitted by
20792081
this version of LLVM. For a description of the metadata generated with the
@@ -2493,8 +2495,8 @@ non-AMD key names should be prefixed by "*vendor-name*.".
24932495

24942496
.. _amdgpu-amdhsa-code-object-metadata-v3:
24952497

2496-
Code Object V3 Metadata (-mattr=+code-object-v3)
2497-
++++++++++++++++++++++++++++++++++++++++++++++++
2498+
Code Object V3 Metadata (--amdhsa-code-object-version=3)
2499+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24982500

24992501
Code object V3 metadata is specified by the ``NT_AMDGPU_METADATA`` note record
25002502
(see :ref:`amdgpu-note-records-v3`).
@@ -7283,8 +7285,8 @@ For full list of supported instructions, refer to "Vector ALU instructions".
72837285

72847286
.. _amdgpu-amdhsa-assembler-predefined-symbols-v2:
72857287

7286-
Code Object V2 Predefined Symbols (-mattr=-code-object-v3)
7287-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7288+
Code Object V2 Predefined Symbols (--amdhsa-code-object-version=2)
7289+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72887290

72897291
.. warning:: Code Object V2 is not the default code object version emitted by
72907292
this version of LLVM. For a description of the predefined symbols available
@@ -7340,8 +7342,8 @@ one.
73407342

73417343
.. _amdgpu-amdhsa-assembler-directives-v2:
73427344

7343-
Code Object V2 Directives (-mattr=-code-object-v3)
7344-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7345+
Code Object V2 Directives (--amdhsa-code-object-version=2)
7346+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73457347

73467348
.. warning:: Code Object V2 is not the default code object version emitted by
73477349
this version of LLVM. For a description of the directives supported with
@@ -7415,8 +7417,8 @@ comments in lib/Target/AMDGPU/AmdKernelCodeT.h and test/CodeGen/AMDGPU/hsa.s.
74157417

74167418
.. _amdgpu-amdhsa-assembler-example-v2:
74177419

7418-
Code Object V2 Example Source Code (-mattr=-code-object-v3)
7419-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7420+
Code Object V2 Example Source Code (--amdhsa-code-object-version=2)
7421+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74207422

74217423
.. warning:: Code Object V2 is not the default code object version emitted by
74227424
this version of LLVM. For a description of the directives supported with
@@ -7461,8 +7463,8 @@ Here is an example of a minimal assembly source file, defining one HSA kernel:
74617463

74627464
.. _amdgpu-amdhsa-assembler-predefined-symbols-v3:
74637465

7464-
Code Object V3 Predefined Symbols (-mattr=+code-object-v3)
7465-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7466+
Code Object V3 Predefined Symbols (--amdhsa-code-object-version=3)
7467+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74667468

74677469
The AMDGPU assembler defines and updates some symbols automatically. These
74687470
symbols do not affect code generation.
@@ -7523,8 +7525,8 @@ May be set at any time, e.g. manually set to zero at the start of each kernel.
75237525

75247526
.. _amdgpu-amdhsa-assembler-directives-v3:
75257527

7526-
Code Object V3 Directives (-mattr=+code-object-v3)
7527-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7528+
Code Object V3 Directives (--amdhsa-code-object-version=3)
7529+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75287530

75297531
Directives which begin with ``.amdgcn`` are valid for all ``amdgcn``
75307532
architecture processors, and are not OS-specific. Directives which begin with
@@ -7678,8 +7680,8 @@ This directive is terminated by an ``.end_amdgpu_metadata`` directive.
76787680

76797681
.. _amdgpu-amdhsa-assembler-example-v3:
76807682

7681-
Code Object V3 Example Source Code (-mattr=+code-object-v3)
7682-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7683+
Code Object V3 Example Source Code (--amdhsa-code-object-version=3)
7684+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76837685

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

llvm/include/llvm/BinaryFormat/ELF.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@ enum {
360360
ELFOSABI_LAST_ARCH = 255 // Last Architecture-specific OS ABI
361361
};
362362

363+
// AMDGPU OS ABI Version identification.
364+
enum {
365+
// ELFABIVERSION_AMDGPU_HSA_V1 does not exist because OS ABI identification
366+
// was never defined for V1.
367+
ELFABIVERSION_AMDGPU_HSA_V2 = 0,
368+
ELFABIVERSION_AMDGPU_HSA_V3 = 1,
369+
};
370+
363371
#define ELF_RELOC(name, value) name = value,
364372

365373
// X86_64 relocations.

0 commit comments

Comments
 (0)