Skip to content

Commit 7a87abb

Browse files
authored
Merge pull request #218 from AMD-Lightning-Internal/upstream_merge_202501201507
merge main into amd-staging
2 parents 4dda048 + f1f3eac commit 7a87abb

File tree

292 files changed

+21519
-9896
lines changed

Some content is hidden

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

292 files changed

+21519
-9896
lines changed

.github/workflows/build-ci-container.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,22 @@ jobs:
3636
tag=`date +%s`
3737
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
3838
echo "container-name=$container_name" >> $GITHUB_OUTPUT
39+
echo "container-name-agent=$container_name-agent" >> $GITHUB_OUTPUT
3940
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
41+
echo "container-name-agent-tag=$container_name-agent:$tag" >> $GITHUB_OUTPUT
4042
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
4143
- name: Build container
4244
working-directory: ./.github/workflows/containers/github-action-ci/
4345
run: |
44-
podman build -t ${{ steps.vars.outputs.container-name-tag }} .
46+
podman build --target ci-container -t ${{ steps.vars.outputs.container-name-tag }} .
47+
podman build --target ci-container-agent -t ${{ steps.vars.outputs.container-name-agent-tag }} .
4548
4649
# Save the container so we have it in case the push fails. This also
4750
# allows us to separate the push step into a different job so we can
4851
# maintain minimal permissions while building the container.
4952
- name: Save container image
5053
run: |
51-
podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
54+
podman save ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name-agent-tag }} > ${{ steps.vars.outputs.container-filename }}
5255
5356
- name: Upload container image
5457
uses: actions/upload-artifact@v4
@@ -86,3 +89,7 @@ jobs:
8689
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
8790
podman push ${{ needs.build-ci-container.outputs.container-name-tag }}
8891
podman push ${{ needs.build-ci-container.outputs.container-name }}:latest
92+
93+
podman tag ${{ needs.build-ci-container.outpus.container-name-agent-tag }} ${{ needs.build-ci-container.outputs.container-name-agent }}:latest
94+
podman push ${{ needs.build-ci-container.outputs.container-name-agent-tag }}
95+
podman push ${{ needs.build-ci-container.outputs.container-name-agent }}:latest

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ RUN apt-get update && \
1313
ninja-build \
1414
python3 \
1515
git \
16-
curl
16+
curl \
17+
zlib1g-dev
1718

1819
RUN curl -O -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && tar -xf llvmorg-$LLVM_VERSION.tar.gz
1920

@@ -38,7 +39,7 @@ RUN cmake -B ./build -G Ninja ./llvm \
3839

3940
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution
4041

41-
FROM base
42+
FROM base as ci-container
4243

4344
COPY --from=stage1-toolchain $LLVM_SYSROOT $LLVM_SYSROOT
4445

@@ -91,4 +92,15 @@ RUN adduser gha sudo
9192
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
9293

9394
USER gha
95+
WORKDIR /home/gha
96+
97+
FROM ci-container as ci-container-agent
98+
99+
ENV GITHUB_RUNNER_VERSION=2.321.0
100+
101+
RUN mkdir actions-runner && \
102+
cd actions-runner && \
103+
curl -O -L https://github.com/actions/runner/releases/download/v$GITHUB_RUNNER_VERSION/actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz && \
104+
tar xzf ./actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz && \
105+
rm ./actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz
94106

clang/docs/LanguageExtensions.rst

Lines changed: 108 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,114 @@ __datasizeof
434434
``__datasizeof`` behaves like ``sizeof``, except that it returns the size of the
435435
type ignoring tail padding.
436436

437+
_BitInt, _ExtInt
438+
----------------
439+
440+
Clang supports the C23 ``_BitInt(N)`` feature as an extension in older C modes
441+
and in C++. This type was previously implemented in Clang with the same
442+
semantics, but spelled ``_ExtInt(N)``. This spelling has been deprecated in
443+
favor of the standard type.
444+
445+
Note: the ABI for ``_BitInt(N)`` is still in the process of being stabilized,
446+
so this type should not yet be used in interfaces that require ABI stability.
447+
448+
C keywords supported in all language modes
449+
------------------------------------------
450+
451+
Clang supports ``_Alignas``, ``_Alignof``, ``_Atomic``, ``_Complex``,
452+
``_Generic``, ``_Imaginary``, ``_Noreturn``, ``_Static_assert``,
453+
``_Thread_local``, and ``_Float16`` in all language modes with the C semantics.
454+
455+
__alignof, __alignof__
456+
----------------------
457+
458+
``__alignof`` and ``__alignof__`` return, in contrast to ``_Alignof`` and
459+
``alignof``, the preferred alignment of a type. This may be larger than the
460+
required alignment for improved performance.
461+
462+
__extension__
463+
-------------
464+
465+
``__extension__`` suppresses extension diagnostics in the statement it is
466+
prepended to.
467+
468+
__auto_type
469+
-----------
470+
471+
``__auto_type`` behaves the same as ``auto`` in C++11 but is available in all
472+
language modes.
473+
474+
__imag, __imag__
475+
----------------
476+
477+
``__imag`` and ``__imag__`` can be used to get the imaginary part of a complex
478+
value.
479+
480+
__real, __real__
481+
----------------
482+
483+
``__real`` and ``__real__`` can be used to get the real part of a complex value.
484+
485+
__asm, __asm__
486+
--------------
487+
488+
``__asm`` and ``__asm__`` are alternate spellings for ``asm``, but available in
489+
all language modes.
490+
491+
__complex, __complex__
492+
----------------------
493+
494+
``__complex`` and ``__complex__`` are alternate spellings for ``_Complex``.
495+
496+
__const, __const__, __volatile, __volatile__, __restrict, __restrict__
497+
----------------------------------------------------------------------
498+
499+
These are alternate spellings for their non-underscore counterparts, but are
500+
available in all langauge modes.
501+
502+
__decltype
503+
----------
504+
505+
``__decltype`` is an alternate spelling for ``decltype``, but is also available
506+
in C++ modes before C++11.
507+
508+
__inline, __inline__
509+
--------------------
510+
511+
``__inline`` and ``__inline__`` are alternate spellings for ``inline``, but are
512+
available in all language modes.
513+
514+
__nullptr
515+
---------
516+
517+
``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in
518+
C++ modes prior to C++11. Note that it's currently not availbale in C despite
519+
C23 having support for ``nullptr``.
520+
521+
__signed, __signed__
522+
--------------------
523+
524+
``__signed`` and ``__signed__`` are alternate spellings for ``signed``.
525+
``__unsigned`` and ``__unsigned__`` are **not** supported.
526+
527+
__typeof, __typeof__, __typeof_unqual, __typeof_unqual__
528+
--------------------------------------------------------
529+
530+
``__typeof`` and ``__typeof__`` are alternate spellings for ``typeof``, but are
531+
available in all langauge modes. These spellings result in the operand,
532+
retaining all qualifiers.
533+
534+
``__typeof_unqual`` and ``__typeof_unqual__`` are alternate spellings for the
535+
C23 ``typeof_unqual`` type specifier, but are available in all language modes.
536+
These spellings result in the type of the operand, stripping all qualifiers.
537+
538+
__char16_t, __char32_t
539+
----------------------
540+
541+
``__char16_t`` and ``__char32_t`` are alternate spellings for ``char16_t`` and
542+
``char32_t`` respectively, but are also available in C++ modes before C++11.
543+
They are only supported in C++. ``__char8_t`` is not available.
544+
437545
..
438546
FIXME: This should list all the keyword extensions
439547
@@ -5785,17 +5893,6 @@ Examples are:
57855893
# 60 "" 2 // return to "main.c"
57865894
# 1 "/usr/ancient/header.h" 1 4 // Enter an implicit extern "C" header
57875895
5788-
Extended Integer Types
5789-
======================
5790-
5791-
Clang supports the C23 ``_BitInt(N)`` feature as an extension in older C modes
5792-
and in C++. This type was previously implemented in Clang with the same
5793-
semantics, but spelled ``_ExtInt(N)``. This spelling has been deprecated in
5794-
favor of the standard type.
5795-
5796-
Note: the ABI for ``_BitInt(N)`` is still in the process of being stabilized,
5797-
so this type should not yet be used in interfaces that require ABI stability.
5798-
57995896
Intrinsics Support within Constant Expressions
58005897
==============================================
58015898

clang/include/clang/Basic/AttrDocs.td

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ def InitPriorityDocs : Documentation {
121121
In C++, the order in which global variables are initialized across translation
122122
units is unspecified, unlike the ordering within a single translation unit. The
123123
``init_priority`` attribute allows you to specify a relative ordering for the
124-
initialization of objects declared at namespace scope in C++. The priority is
125-
given as an integer constant expression between 101 and 65535 (inclusive).
126-
Priorities outside of that range are reserved for use by the implementation. A
127-
lower value indicates a higher priority of initialization. Note that only the
128-
relative ordering of values is important. For example:
124+
initialization of objects declared at namespace scope in C++ within a single
125+
linked image on supported platforms. The priority is given as an integer constant
126+
expression between 101 and 65535 (inclusive). Priorities outside of that range are
127+
reserved for use by the implementation. A lower value indicates a higher priority
128+
of initialization. Note that only the relative ordering of values is important.
129+
For example:
129130

130131
.. code-block:: c++
131132

@@ -136,10 +137,16 @@ relative ordering of values is important. For example:
136137
``Obj2`` will be initialized *before* ``Obj1`` despite the usual order of
137138
initialization being the opposite.
138139

140+
Note that this attribute does not control the initialization order of objects
141+
across final linked image boundaries like shared objects and executables.
142+
139143
On Windows, ``init_seg(compiler)`` is represented with a priority of 200 and
140144
``init_seg(library)`` is represented with a priority of 400. ``init_seg(user)``
141145
uses the default 65535 priority.
142146

147+
On MachO platforms, this attribute also does not control the order of initialization
148+
across translation units, where it only affects the order within a single TU.
149+
143150
This attribute is only supported for C++ and Objective-C++ and is ignored in
144151
other language modes. Currently, this attribute is not implemented on z/OS.
145152
}];

clang/include/clang/Basic/BuiltinsSystemZ.def

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ TARGET_BUILTIN(__builtin_s390_vstrszf, "V16UcV4UiV4UiV16Uci*", "nc", "vector-enh
286286
TARGET_BUILTIN(__builtin_s390_vlbrh, "V8UsV8Us", "nc", "vector")
287287
TARGET_BUILTIN(__builtin_s390_vlbrf, "V4UiV4Ui", "nc", "vector")
288288
TARGET_BUILTIN(__builtin_s390_vlbrg, "V2ULLiV2ULLi", "nc", "vector")
289+
TARGET_BUILTIN(__builtin_s390_vlbrq, "ULLLiULLLi", "nc", "vector")
289290

290291
// NNP-assist facility intrinsics.
291292
TARGET_BUILTIN(__builtin_s390_vclfnhs, "V4fV8UsIi", "nc", "nnp-assist")
@@ -294,5 +295,44 @@ TARGET_BUILTIN(__builtin_s390_vcrnfs, "V8UsV4fV4fIi", "nc", "nnp-assist")
294295
TARGET_BUILTIN(__builtin_s390_vcfn, "V8UsV8UsIi", "nc", "nnp-assist")
295296
TARGET_BUILTIN(__builtin_s390_vcnf, "V8UsV8UsIi", "nc", "nnp-assist")
296297

298+
// Miscellaneous instruction extensions facility 4 intrinsics.
299+
TARGET_BUILTIN(__builtin_s390_bdepg, "ULiULiULi", "nc", "miscellaneous-extensions-4")
300+
TARGET_BUILTIN(__builtin_s390_bextg, "ULiULiULi", "nc", "miscellaneous-extensions-4")
301+
302+
// Vector-enhancements facility 3 intrinsics.
303+
TARGET_BUILTIN(__builtin_s390_vgemb, "V16UcV8Us", "nc", "vector-enhancements-3")
304+
TARGET_BUILTIN(__builtin_s390_vgemh, "V8UsV16Uc", "nc", "vector-enhancements-3")
305+
TARGET_BUILTIN(__builtin_s390_vgemf, "V4UiV16Uc", "nc", "vector-enhancements-3")
306+
TARGET_BUILTIN(__builtin_s390_vgemg, "V2ULLiV16Uc", "nc", "vector-enhancements-3")
307+
TARGET_BUILTIN(__builtin_s390_vgemq, "ULLLiV16Uc", "nc", "vector-enhancements-3")
308+
TARGET_BUILTIN(__builtin_s390_vuplg, "SLLLiV2SLLi", "nc", "vector-enhancements-3")
309+
TARGET_BUILTIN(__builtin_s390_vupllg, "ULLLiV2ULLi", "nc", "vector-enhancements-3")
310+
TARGET_BUILTIN(__builtin_s390_vuphg, "SLLLiV2SLLi", "nc", "vector-enhancements-3")
311+
TARGET_BUILTIN(__builtin_s390_vuplhg, "ULLLiV2ULLi", "nc", "vector-enhancements-3")
312+
TARGET_BUILTIN(__builtin_s390_vavgq, "SLLLiSLLLiSLLLi", "nc", "vector-enhancements-3")
313+
TARGET_BUILTIN(__builtin_s390_vavglq, "ULLLiULLLiULLLi", "nc", "vector-enhancements-3")
314+
TARGET_BUILTIN(__builtin_s390_veval, "V16UcV16UcV16UcV16UcIi", "nc", "vector-enhancements-3")
315+
TARGET_BUILTIN(__builtin_s390_vmahg, "V2SLLiV2SLLiV2SLLiV2SLLi", "nc", "vector-enhancements-3")
316+
TARGET_BUILTIN(__builtin_s390_vmahq, "SLLLiSLLLiSLLLiSLLLi", "nc", "vector-enhancements-3")
317+
TARGET_BUILTIN(__builtin_s390_vmalhg, "V2ULLiV2ULLiV2ULLiV2ULLi", "nc", "vector-enhancements-3")
318+
TARGET_BUILTIN(__builtin_s390_vmalhq, "ULLLiULLLiULLLiULLLi", "nc", "vector-enhancements-3")
319+
TARGET_BUILTIN(__builtin_s390_vmaeg, "SLLLiV2SLLiV2SLLiSLLLi", "nc", "vector-enhancements-3")
320+
TARGET_BUILTIN(__builtin_s390_vmaleg, "ULLLiV2ULLiV2ULLiULLLi", "nc", "vector-enhancements-3")
321+
TARGET_BUILTIN(__builtin_s390_vmaog, "SLLLiV2SLLiV2SLLiSLLLi", "nc", "vector-enhancements-3")
322+
TARGET_BUILTIN(__builtin_s390_vmalog, "ULLLiV2ULLiV2ULLiULLLi", "nc", "vector-enhancements-3")
323+
TARGET_BUILTIN(__builtin_s390_vmhg, "V2SLLiV2SLLiV2SLLi", "nc", "vector-enhancements-3")
324+
TARGET_BUILTIN(__builtin_s390_vmhq, "SLLLiSLLLiSLLLi", "nc", "vector-enhancements-3")
325+
TARGET_BUILTIN(__builtin_s390_vmlhg, "V2ULLiV2ULLiV2ULLi", "nc", "vector-enhancements-3")
326+
TARGET_BUILTIN(__builtin_s390_vmlhq, "ULLLiULLLiULLLi", "nc", "vector-enhancements-3")
327+
TARGET_BUILTIN(__builtin_s390_vmeg, "SLLLiV2SLLiV2SLLi", "nc", "vector-enhancements-3")
328+
TARGET_BUILTIN(__builtin_s390_vmleg, "ULLLiV2ULLiV2ULLi", "nc", "vector-enhancements-3")
329+
TARGET_BUILTIN(__builtin_s390_vmog, "SLLLiV2SLLiV2SLLi", "nc", "vector-enhancements-3")
330+
TARGET_BUILTIN(__builtin_s390_vmlog, "ULLLiV2ULLiV2ULLi", "nc", "vector-enhancements-3")
331+
TARGET_BUILTIN(__builtin_s390_vceqqs, "SLLLiULLLiULLLii*", "nc", "vector-enhancements-3")
332+
TARGET_BUILTIN(__builtin_s390_vchqs, "SLLLiSLLLiSLLLii*", "nc", "vector-enhancements-3")
333+
TARGET_BUILTIN(__builtin_s390_vchlqs, "SLLLiULLLiULLLii*", "nc", "vector-enhancements-3")
334+
TARGET_BUILTIN(__builtin_s390_vclzq, "ULLLiULLLi", "nc", "vector-enhancements-3")
335+
TARGET_BUILTIN(__builtin_s390_vctzq, "ULLLiULLLi", "nc", "vector-enhancements-3")
336+
297337
#undef BUILTIN
298338
#undef TARGET_BUILTIN

clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ void emit(Program &P, std::vector<std::byte> &Code, const IntegralAP<true> &Val,
332332
emitSerialized(Code, Val, Success);
333333
}
334334

335+
template <>
336+
void emit(Program &P, std::vector<std::byte> &Code, const FixedPoint &Val,
337+
bool &Success) {
338+
emitSerialized(Code, Val, Success);
339+
}
340+
335341
template <typename... Tys>
336342
bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &...Args,
337343
const SourceInfo &SI) {

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ inline IntegralAP<true> ReadArg<IntegralAP<true>>(Program &P, CodePtr &OpPC) {
6262
return I;
6363
}
6464

65+
template <> inline FixedPoint ReadArg<FixedPoint>(Program &P, CodePtr &OpPC) {
66+
FixedPoint I = FixedPoint::deserialize(*OpPC);
67+
OpPC += align(I.bytesToSerialize());
68+
return I;
69+
}
70+
6571
LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
6672

6773
LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {

clang/lib/AST/ByteCode/FixedPoint.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,32 @@ class FixedPoint final {
9191
return ComparisonCategoryResult::Greater;
9292
}
9393

94+
size_t bytesToSerialize() const {
95+
return sizeof(uint32_t) + (V.getValue().getBitWidth() / CHAR_BIT);
96+
}
97+
98+
void serialize(std::byte *Buff) const {
99+
// Semantics followed by APInt.
100+
uint32_t SemI = V.getSemantics().toOpaqueInt();
101+
std::memcpy(Buff, &SemI, sizeof(SemI));
102+
103+
llvm::APInt API = V.getValue();
104+
llvm::StoreIntToMemory(API, (uint8_t *)(Buff + sizeof(SemI)),
105+
bitWidth() / 8);
106+
}
107+
108+
static FixedPoint deserialize(const std::byte *Buff) {
109+
auto Sem = llvm::FixedPointSemantics::getFromOpaqueInt(
110+
*reinterpret_cast<const uint32_t *>(Buff));
111+
unsigned BitWidth = Sem.getWidth();
112+
APInt I(BitWidth, 0ull, !Sem.isSigned());
113+
llvm::LoadIntFromMemory(
114+
I, reinterpret_cast<const uint8_t *>(Buff + sizeof(uint32_t)),
115+
BitWidth / CHAR_BIT);
116+
117+
return FixedPoint(I, Sem);
118+
}
119+
94120
static bool neg(const FixedPoint &A, FixedPoint *R) {
95121
bool Overflow = false;
96122
*R = FixedPoint(A.V.negate(&Overflow));

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,11 @@ bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
416416
AccessKinds AK) {
417417
if (!Ptr.isOnePastEnd())
418418
return true;
419-
const SourceInfo &Loc = S.Current->getSource(OpPC);
420-
S.FFDiag(Loc, diag::note_constexpr_access_past_end)
421-
<< AK << S.Current->getRange(OpPC);
419+
if (S.getLangOpts().CPlusPlus) {
420+
const SourceInfo &Loc = S.Current->getSource(OpPC);
421+
S.FFDiag(Loc, diag::note_constexpr_access_past_end)
422+
<< AK << S.Current->getRange(OpPC);
423+
}
422424
return false;
423425
}
424426

@@ -538,7 +540,7 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
538540
return true;
539541

540542
if (const auto *VD = Ptr.getDeclDesc()->asVarDecl();
541-
VD && VD->hasGlobalStorage()) {
543+
VD && (VD->isConstexpr() || VD->hasGlobalStorage())) {
542544
const SourceInfo &Loc = S.Current->getSource(OpPC);
543545
if (VD->getAnyInitializer()) {
544546
S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD;

clang/lib/AST/ByteCode/Interp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,6 +2693,10 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
26932693
inline bool GetIntPtr(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
26942694
const T &IntVal = S.Stk.pop<T>();
26952695

2696+
if (Desc)
2697+
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_cast)
2698+
<< 2 << S.getLangOpts().CPlusPlus;
2699+
26962700
S.Stk.push<Pointer>(static_cast<uint64_t>(IntVal), Desc);
26972701
return true;
26982702
}
@@ -3070,6 +3074,13 @@ inline IntegralAP<true> ReadArg<IntegralAP<true>>(InterpState &S,
30703074
return I;
30713075
}
30723076

3077+
template <>
3078+
inline FixedPoint ReadArg<FixedPoint>(InterpState &S, CodePtr &OpPC) {
3079+
FixedPoint FP = FixedPoint::deserialize(*OpPC);
3080+
OpPC += align(FP.bytesToSerialize());
3081+
return FP;
3082+
}
3083+
30733084
} // namespace interp
30743085
} // namespace clang
30753086

0 commit comments

Comments
 (0)