Skip to content

Commit 833d7d7

Browse files
committed
merge main into amd-staging
2 parents 016c242 + 23e6dbf commit 833d7d7

File tree

119 files changed

+2655
-1185
lines changed

Some content is hidden

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

119 files changed

+2655
-1185
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ jobs:
223223
source .venv/bin/activate
224224
python -m pip install psutil
225225
xcrun bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
226+
env:
227+
CC: clang
228+
CXX: clang++
226229
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
227230
if: always() # Upload artifacts even if the build or test suite fails
228231
with:
@@ -241,16 +244,16 @@ jobs:
241244
fail-fast: false
242245
matrix:
243246
include:
244-
- { config: clang-cl-dll, mingw: false }
245-
- { config: clang-cl-static, mingw: false }
246-
- { config: clang-cl-no-vcruntime, mingw: false }
247-
- { config: clang-cl-debug, mingw: false }
248-
- { config: clang-cl-static-crt, mingw: false }
249-
- { config: mingw-dll, mingw: true }
250-
- { config: mingw-static, mingw: true }
251-
- { config: mingw-dll-i686, mingw: true }
252-
- { config: mingw-incomplete-sysroot, mingw: true }
253-
- { config: mingw-static, mingw: true, runner: windows-11-arm }
247+
- { config: clang-cl-dll, mingw: false, cc: clang-cl, cxx: clang-cl }
248+
- { config: clang-cl-static, mingw: false, cc: clang-cl, cxx: clang-cl }
249+
- { config: clang-cl-no-vcruntime, mingw: false, cc: clang-cl, cxx: clang-cl }
250+
- { config: clang-cl-debug, mingw: false, cc: clang-cl, cxx: clang-cl }
251+
- { config: clang-cl-static-crt, mingw: false, cc: clang-cl, cxx: clang-cl }
252+
- { config: mingw-dll, mingw: true, cc: cc, cxx: c++ }
253+
- { config: mingw-dll, mingw: true, cc: i686-w64-mingw32-clang, cxx: i686-w64-mingw32-clang++ }
254+
- { config: mingw-static, mingw: true, cc: cc, cxx: c++ }
255+
- { config: mingw-incomplete-sysroot, mingw: true, cc: cc, cxx: c++ }
256+
- { config: mingw-static, mingw: true, cc: cc, cxx: c++, runner: windows-11-arm }
254257
runs-on: ${{ matrix.runner != '' && matrix.runner || 'windows-2022' }}
255258
steps:
256259
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
@@ -286,5 +289,7 @@ jobs:
286289
run: |
287290
echo "c:\Program Files\LLVM\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
288291
- name: Build and test
289-
run: |
290-
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
292+
run: bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
293+
env:
294+
CC: ${{ matrix.cc }}
295+
CXX: ${{ matrix.cxx }}

.github/workflows/libcxx-check-generated-files.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ jobs:
2222

2323
- name: Check generated files
2424
run: libcxx/utils/ci/run-buildbot check-generated-output
25+
env:
26+
CC: cc
27+
CXX: c++

bolt/docs/BAT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Functions table:
6161

6262
### Functions table
6363
Hot and cold functions tables share the encoding except differences marked below.
64+
6465
Header:
6566
| Entry | Encoding | Description |
6667
| ------ | ----- | ----------- |

clang/docs/HIPSupport.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,54 @@ Example Usage
412412
__host__ __device__ int Four(void) __attribute__((weak, alias("_Z6__Fourv")));
413413
__host__ __device__ float Four(float f) __attribute__((weak, alias("_Z6__Fourf")));
414414

415+
C++17 Class Template Argument Deduction (CTAD) Support
416+
======================================================
417+
418+
Clang supports C++17 Class Template Argument Deduction (CTAD) in both host and
419+
device code for HIP. This allows you to omit template arguments when creating
420+
class template instances, letting the compiler deduce them from constructor
421+
arguments.
422+
423+
.. code-block:: c++
424+
425+
#include <tuple>
426+
427+
__host__ __device__ void func() {
428+
std::tuple<int, int> t = std::tuple(1, 1);
429+
}
430+
431+
In the above example, ``std::tuple(1, 1)`` automatically deduces the type to be
432+
``std::tuple<int, int>``.
433+
434+
Deduction Guides
435+
----------------
436+
437+
User-defined deduction guides are also supported. Since deduction guides are not
438+
executable code and only participate in type deduction, they semantically behave
439+
as ``__host__ __device__``. This ensures they are available for deduction in both
440+
host and device contexts, and CTAD continues to respect any constraints on the
441+
corresponding constructors in the usual C++ way.
442+
443+
.. code-block:: c++
444+
445+
template <typename T>
446+
struct MyType {
447+
T value;
448+
__device__ MyType(T v) : value(v) {}
449+
};
450+
451+
MyType(float) -> MyType<double>;
452+
453+
__device__ void deviceFunc() {
454+
MyType m(1.0f); // Deduces MyType<double>
455+
}
456+
457+
.. note::
458+
459+
Explicit HIP target attributes such as ``__host__`` or ``__device__``
460+
are not allowed on deduction guides. Clang treats all deduction guides
461+
as if they were ``__host__ __device__`` and diagnoses any explicit
462+
target attributes on them as errors.
415463

416464
Host and Device Attributes of Default Destructors
417465
===================================================

clang/docs/ReleaseNotes.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,20 @@ RISC-V Support
897897
CUDA/HIP Language Changes
898898
^^^^^^^^^^^^^^^^^^^^^^^^^
899899

900+
- Clang now supports C++17 Class Template Argument Deduction (CTAD) in CUDA/HIP
901+
device code by treating deduction guides as if they were ``__host__ __device__``.
902+
903+
- Clang avoids ambiguous CTAD in CUDA/HIP by not synthesizing duplicate implicit
904+
deduction guides when ``__host__`` and ``__device__`` constructors differ only
905+
in CUDA target attributes (same signature and constraints).
906+
907+
- Clang diagnoses CUDA/HIP target attributes written on deduction guides as errors,
908+
since deduction guides do not participate in code generation.
909+
910+
- Clang preserves distinct implicit deduction guides for constructors that differ
911+
by constraints, so constraint-based CTAD works in CUDA/HIP device code as in
912+
standard C++.
913+
900914
CUDA Support
901915
^^^^^^^^^^^^
902916

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ Standard C++ Named modules
2828
In order to better understand the compiler's behavior, it is helpful to
2929
understand some terms and definitions for readers who are not familiar with the
3030
C++ feature. This document is not a tutorial on C++; it only introduces
31-
necessary concepts to better understand use of modules in a project.
31+
necessary concepts to better understand use of modules in a project. Other
32+
resources at `Wikipedia <https://en.wikipedia.org/wiki/Modules_(C++)>`_ and
33+
`cppreference <https://en.cppreference.com/w/cpp/language/modules.html>`_ can
34+
provide more background information about modules if needed.
3235

3336
Background and terminology
3437
--------------------------

clang/include/clang/Basic/Attr.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5172,6 +5172,14 @@ def HLSLVkConstantId : InheritableAttr {
51725172
let Documentation = [VkConstantIdDocs];
51735173
}
51745174

5175+
def HLSLVkLocation : HLSLAnnotationAttr {
5176+
let Spellings = [CXX11<"vk", "location">];
5177+
let Args = [IntArgument<"Location">];
5178+
let Subjects = SubjectList<[ParmVar, Field, Function], ErrorDiag>;
5179+
let LangOpts = [HLSL];
5180+
let Documentation = [HLSLVkLocationDocs];
5181+
}
5182+
51755183
def RandomizeLayout : InheritableAttr {
51765184
let Spellings = [GCC<"randomize_layout">];
51775185
let Subjects = SubjectList<[Record]>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8981,6 +8981,18 @@ The descriptor set is optional and defaults to 0 if not provided.
89818981
}];
89828982
}
89838983

8984+
def HLSLVkLocationDocs : Documentation {
8985+
let Category = DocCatVariable;
8986+
let Content = [{
8987+
Attribute used for specifying the location number for the stage input/output
8988+
variables. Allowed on function parameters, function returns, and struct
8989+
fields. This parameter has no effect when used outside of an entrypoint
8990+
parameter/parameter field/return value.
8991+
8992+
This attribute maps to the 'Location' SPIR-V decoration.
8993+
}];
8994+
}
8995+
89848996
def WebAssemblyFuncrefDocs : Documentation {
89858997
let Category = DocCatType;
89868998
let Content = [{

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,6 +2765,9 @@ def err_deduction_guide_name_not_class_template : Error<
27652765
"cannot specify deduction guide for "
27662766
"%select{<error>|function template|variable template|alias template|"
27672767
"template template parameter|concept|dependent template name}0 %1">;
2768+
def err_deduction_guide_target_attr : Error<
2769+
"in CUDA/HIP, target attributes are not allowed on deduction guides; "
2770+
"deduction guides are implicitly enabled for both host and device">;
27682771
def err_deduction_guide_wrong_scope : Error<
27692772
"deduction guide must be declared in the same scope as template %q0">;
27702773
def err_deduction_guide_defines_function : Error<
@@ -13235,6 +13238,12 @@ def err_hlsl_semantic_indexing_not_supported
1323513238
def err_hlsl_init_priority_unsupported : Error<
1323613239
"initializer priorities are not supported in HLSL">;
1323713240
def err_hlsl_semantic_index_overlap : Error<"semantic index overlap %0">;
13241+
def err_hlsl_semantic_unsupported_iotype_for_stage
13242+
: Error<"semantic %0 is unsupported in %2 shaders as %1, requires one of "
13243+
"the following: %3">;
13244+
def err_hlsl_semantic_partial_explicit_indexing
13245+
: Error<"partial explicit stage input location assignment via "
13246+
"vk::location(X) unsupported">;
1323813247

1323913248
def warn_hlsl_user_defined_type_missing_member: Warning<"binding type '%select{t|u|b|s|c}0' only applies to types containing %select{SRV resources|UAV resources|constant buffer resources|sampler state|numeric types}0">, InGroup<LegacyConstantRegisterBinding>;
1324013249
def err_hlsl_binding_type_mismatch: Error<"binding type '%select{t|u|b|s|c}0' only applies to %select{SRV resources|UAV resources|constant buffer resources|sampler state|numeric variables in the global scope}0">;

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4820,6 +4820,37 @@ def CIR_VAEndOp : CIR_Op<"va_end"> {
48204820
}];
48214821
}
48224822

4823+
def CIR_VACopyOp : CIR_Op<"va_copy"> {
4824+
let summary = "Copied a variable argument list";
4825+
let description = [{
4826+
The `cir.copy` operation models the C/C++ va_copy macro.
4827+
The variable argument list passed as the `$src_list` is copied to an
4828+
unitialized `va_list` in the destination operand. The next argument that
4829+
can be extracted from the copied list is the same as the next argument in
4830+
the source list. The copied list must be destroyed with `va_end`.
4831+
4832+
Example:
4833+
4834+
```mlir
4835+
// %args : !cir.ptr<!cir.array<!rec___va_list_tag x 1>>
4836+
%p = cir.cast array_to_ptrdecay %args
4837+
: !cir.ptr<!cir.array<!rec___va_list_tag x 1>>
4838+
-> !cir.ptr<!rec___va_list_tag>
4839+
cir.va_copy %p to %dst
4840+
: (!cir.ptr<!rec___va_list_tag>, !cir.ptr<!rec___va_list_tag>)
4841+
```
4842+
}];
4843+
4844+
let arguments = (ins
4845+
CIR_PointerType:$dst_list,
4846+
CIR_PointerType:$src_list
4847+
);
4848+
4849+
let assemblyFormat = [{
4850+
$src_list `to` $dst_list attr-dict `:` type(operands)
4851+
}];
4852+
}
4853+
48234854
def CIR_VAArgOp : CIR_Op<"va_arg"> {
48244855
let summary = "Fetches next variadic element as a given type";
48254856
let description = [{

0 commit comments

Comments
 (0)