Skip to content

Commit 8c48a5a

Browse files
committed
merge main into amd-staging
2 parents 1fd1cc6 + 03912a1 commit 8c48a5a

File tree

118 files changed

+2516
-1041
lines changed

Some content is hidden

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

118 files changed

+2516
-1041
lines changed

.github/workflows/libclang-python-tests.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ permissions:
44
contents: read
55

66
on:
7-
workflow_dispatch:
87
push:
98
branches:
109
- 'main'
@@ -13,29 +12,46 @@ on:
1312
- 'clang/tools/libclang/**'
1413
- 'clang/CMakeList.txt'
1514
- '.github/workflows/libclang-python-tests.yml'
16-
- '.github/workflows/llvm-project-tests.yml'
1715
pull_request:
1816
paths:
1917
- 'clang/bindings/python/**'
2018
- 'clang/tools/libclang/**'
2119
- 'clang/CMakeList.txt'
2220
- '.github/workflows/libclang-python-tests.yml'
23-
- '.github/workflows/llvm-project-tests.yml'
2421

2522
jobs:
2623
check-clang-python:
2724
# Build libclang and then run the libclang Python binding's unit tests.
25+
# There is an issue running on "windows-2019".
26+
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
2827
name: Build and run Python unit tests
2928
if: github.repository == 'llvm/llvm-project'
29+
runs-on: ubuntu-24.04
3030
strategy:
3131
fail-fast: false
3232
matrix:
3333
python-version: ["3.8", "3.13"]
34-
uses: ./.github/workflows/llvm-project-tests.yml
35-
with:
36-
build_target: check-clang-python
37-
projects: clang
38-
# There is an issue running on "windows-2019".
39-
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
40-
os_list: '["ubuntu-24.04"]'
41-
python_version: ${{ matrix.python-version }}
34+
steps:
35+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
36+
- name: Setup Python
37+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
- name: Setup ccache
41+
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
42+
with:
43+
max-size: 2G
44+
key: spirv-ubuntu-24.04
45+
variant: sccache
46+
- name: Build and Test
47+
run: |
48+
mkdir build
49+
cmake -GNinja \
50+
-S llvm \
51+
-B build \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-DLLVM_ENABLE_ASSERTIONS=ON \
54+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
55+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
56+
-DLLVM_ENABLE_PROJECTS=clang
57+
ninja -C build check-clang-python

.github/workflows/mlir-spirv-tests.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,28 @@ jobs:
2424
check_spirv:
2525
if: github.repository_owner == 'llvm'
2626
name: Test MLIR SPIR-V
27-
uses: ./.github/workflows/llvm-project-tests.yml
28-
with:
29-
build_target: check-mlir
30-
projects: mlir
31-
extra_cmake_args: '-DLLVM_TARGETS_TO_BUILD="host" -DLLVM_INCLUDE_SPIRV_TOOLS_TESTS=ON'
32-
os_list: '["ubuntu-24.04"]'
27+
runs-on: ubuntu-24.04
28+
container:
29+
image: ghcr.io/llvm/ci-ubuntu-24.04:latest
30+
steps:
31+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
- name: Setup ccache
33+
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
34+
with:
35+
max-size: 2G
36+
key: spirv-mlir-ubuntu-24.04
37+
variant: sccache
38+
- name: Build and Test
39+
run: |
40+
mkdir build
41+
cmake -GNinja \
42+
-S llvm \
43+
-B build \
44+
-DCMAKE_BUILD_TYPE=Release \
45+
-DLLVM_ENABLE_ASSERTIONS=ON \
46+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
47+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
48+
-DLLVM_TARGETS_TO_BUILD="host" \
49+
-DLLVM_INCLUDE_SPIRV_TOOLS_TESTS=ON \
50+
-DLLVM_ENABLE_PROJECTS=mlir
51+
ninja -C build check-mlir

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ Bug Fixes in This Version
439439
targets that treat ``_Float16``/``__fp16`` as native scalar types. Previously
440440
the warning was silently lost because the operands differed only by an implicit
441441
cast chain. (#GH149967).
442+
- Fixed a crash with incompatible pointer to integer conversions in designated
443+
initializers involving string literals. (#GH154046)
442444

443445
Bug Fixes to Compiler Builtins
444446
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/SourceBasedCodeCoverage.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ supported. Uninstrumented code simply won't be accounted for in reports.
6666

6767
To compile code with Modified Condition/Decision Coverage (MC/DC) enabled,
6868
pass ``-fcoverage-mcdc`` in addition to the clang options specified above.
69-
MC/DC is an advanced form of code coverage most applicable in the embedded
69+
MC/DC is an advanced form of code coverage most applicable to the embedded
7070
space.
7171

7272
Running the instrumented program
7373
================================
7474

75-
The next step is to run the instrumented program. When the program exits it
75+
The next step is to run the instrumented program. When the program exits, it
7676
will write a **raw profile** to the path specified by the ``LLVM_PROFILE_FILE``
7777
environment variable. If that variable does not exist, the profile is written
7878
to ``default.profraw`` in the current directory of the program. If
79-
``LLVM_PROFILE_FILE`` contains a path to a non-existent directory, the missing
79+
``LLVM_PROFILE_FILE`` specifies a path to a non-existent directory, the missing
8080
directory structure will be created. Additionally, the following special
8181
**pattern strings** are rewritten:
8282

@@ -97,7 +97,7 @@ directory structure will be created. Additionally, the following special
9797
* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to
9898
avoid binary signature collisions. To use it, the program should be compiled
9999
with the build ID linker option (``--build-id`` for GNU ld or LLD,
100-
``/build-id`` for lld-link on Windows). Linux, Windows and AIX are supported.
100+
``/build-id`` for lld-link on Windows). Linux, Windows, and AIX are supported.
101101

102102
* "%c" expands out to nothing, but enables a mode in which profile counter
103103
updates are continuously synced to a file. This means that if the
@@ -128,7 +128,7 @@ and set bias to the offset between the original and the new counter location,
128128
at which point every subsequent counter access will be to the new location,
129129
which allows updating profile directly akin to the continuous mode.
130130

131-
The advantage of this approach is that doesn't require any special OS support.
131+
The advantage of this approach is that it doesn't require any special OS support.
132132
The disadvantage is the extra overhead due to additional instructions required
133133
for each counter access (overhead both in terms of binary size and performance)
134134
plus duplication of counters (i.e. one copy in the binary itself and another
@@ -137,7 +137,7 @@ other platforms by passing the ``-runtime-counter-relocation`` option to the
137137
backend during compilation.
138138

139139
For a program such as the `Lit <https://llvm.org/docs/CommandGuide/lit.html>`_
140-
testing tool which invokes other programs, it may be necessary to set
140+
testing tool, which invokes other programs, it may be necessary to set
141141
``LLVM_PROFILE_FILE`` for each invocation. The pattern strings "%p" or "%Nm"
142142
may help to avoid corruption due to concurrency. Note that "%p" is also a Lit
143143
token and needs to be escaped as "%%p".
@@ -149,7 +149,7 @@ token and needs to be escaped as "%%p".
149149
Creating coverage reports
150150
=========================
151151

152-
Raw profiles have to be **indexed** before they can be used to generate
152+
Raw profiles must be **indexed** before they can be used to generate
153153
coverage reports. This is done using the "merge" tool in ``llvm-profdata``
154154
(which can combine multiple raw profiles and index them at the same time):
155155

@@ -240,13 +240,13 @@ line-oriented report, try:
240240
TOTAL 13 0 100.00% 3 0 100.00% 13 0 100.00% 12 2 83.33%
241241
242242
The ``llvm-cov`` tool supports specifying a custom demangler, writing out
243-
reports in a directory structure, and generating html reports. For the full
243+
reports in a directory structure, and generating HTML reports. For the full
244244
list of options, please refer to the `command guide
245245
<https://llvm.org/docs/CommandGuide/llvm-cov.html>`_.
246246

247247
A few final notes:
248248

249-
* The ``-sparse`` flag is optional but can result in dramatically smaller
249+
* The ``-sparse`` flag is optional but can produce dramatically smaller
250250
indexed profiles. This option should not be used if the indexed profile will
251251
be reused for PGO.
252252

@@ -255,7 +255,7 @@ A few final notes:
255255
information directly into an existing raw profile on disk. The details are
256256
out of scope.
257257

258-
* The ``llvm-profdata`` tool can be used to merge together multiple raw or
258+
* The ``llvm-profdata`` tool can be used to merge multiple raw or
259259
indexed profiles. To combine profiling data from multiple runs of a program,
260260
try e.g:
261261

@@ -299,7 +299,7 @@ There are six statistics tracked in a coverage summary:
299299
source code that may each evaluate to either "true" or "false". These
300300
conditions may comprise larger boolean expressions linked by boolean logical
301301
operators. For example, "x = (y == 2) || (z < 10)" is a boolean expression
302-
that is comprised of two individual conditions, each of which evaluates to
302+
comprised of two individual conditions, each of which evaluates to
303303
either true or false, producing four total branch outcomes.
304304

305305
* Modified Condition/Decision Coverage (MC/DC) is the percentage of individual
@@ -316,7 +316,7 @@ There are six statistics tracked in a coverage summary:
316316
``-show-mcdc-summary`` option as long as code was also compiled using the
317317
clang option ``-fcoverage-mcdc``.
318318

319-
* Boolean expressions that are only comprised of one condition (and therefore
319+
* Boolean expressions comprised of only one condition (and therefore
320320
have no logical operators) are not included in MC/DC analysis and are
321321
trivially deducible using branch coverage.
322322

@@ -366,7 +366,7 @@ By default the compiler runtime uses a static initializer to determine the
366366
profile output path and to register a writer function. To collect profiles
367367
without using static initializers, do this manually:
368368

369-
* Export a ``int __llvm_profile_runtime`` symbol from each instrumented shared
369+
* Export an ``int __llvm_profile_runtime`` symbol from each instrumented shared
370370
library and executable. When the linker finds a definition of this symbol, it
371371
knows to skip loading the object which contains the profiling runtime's
372372
static initializer.
@@ -380,7 +380,7 @@ without using static initializers, do this manually:
380380
to ``__llvm_profile_write_file``.
381381

382382
* Forward-declare ``int __llvm_profile_write_file(void)`` and call it to write
383-
out a profile. This function returns 0 when it succeeds, and a non-zero value
383+
out a profile. This function returns 0 on success, and a non-zero value
384384
otherwise. Calling this function multiple times appends profile data to an
385385
existing on-disk raw profile.
386386

@@ -418,7 +418,7 @@ Collecting coverage reports for the llvm project
418418
================================================
419419

420420
To prepare a coverage report for llvm (and any of its sub-projects), add
421-
``-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On`` to the cmake configuration. Raw
421+
``-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On`` to the CMake configuration. Raw
422422
profiles will be written to ``$BUILD_DIR/profiles/``. To prepare an html
423423
report, run ``llvm/utils/prepare-code-coverage-artifact.py``.
424424

@@ -429,7 +429,7 @@ To specify an alternate directory for raw profiles, use
429429
Drawbacks and limitations
430430
=========================
431431

432-
* Prior to version 2.26, the GNU binutils BFD linker is not able link programs
432+
* Prior to version 2.26, the GNU binutils BFD linker cannot link programs
433433
compiled with ``-fcoverage-mapping`` in its ``--gc-sections`` mode. Possible
434434
workarounds include disabling ``--gc-sections``, upgrading to a newer version
435435
of BFD, or using the Gold linker.

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,11 @@ bool EndLifetime(InterpState &S, CodePtr OpPC) {
18521852
const auto &Ptr = S.Stk.peek<Pointer>();
18531853
if (Ptr.isBlockPointer() && !CheckDummy(S, OpPC, Ptr.block(), AK_Destroy))
18541854
return false;
1855+
1856+
// FIXME: We need per-element lifetime information for primitive arrays.
1857+
if (Ptr.isArrayElement())
1858+
return true;
1859+
18551860
endLifetimeRecurse(Ptr.narrow());
18561861
return true;
18571862
}
@@ -1861,6 +1866,11 @@ bool EndLifetimePop(InterpState &S, CodePtr OpPC) {
18611866
const auto &Ptr = S.Stk.pop<Pointer>();
18621867
if (Ptr.isBlockPointer() && !CheckDummy(S, OpPC, Ptr.block(), AK_Destroy))
18631868
return false;
1869+
1870+
// FIXME: We need per-element lifetime information for primitive arrays.
1871+
if (Ptr.isArrayElement())
1872+
return true;
1873+
18641874
endLifetimeRecurse(Ptr.narrow());
18651875
return true;
18661876
}

clang/lib/AST/ByteCode/InterpBlock.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class Block final {
5050

5151
public:
5252
/// Creates a new block.
53-
Block(unsigned EvalID, const std::optional<unsigned> &DeclID,
54-
const Descriptor *Desc, bool IsStatic = false, bool IsExtern = false,
55-
bool IsWeak = false, bool IsDummy = false)
53+
Block(unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc,
54+
bool IsStatic = false, bool IsExtern = false, bool IsWeak = false,
55+
bool IsDummy = false)
5656
: Desc(Desc), DeclID(DeclID), EvalID(EvalID), IsStatic(IsStatic) {
5757
assert(Desc);
5858
AccessFlags |= (ExternFlag * IsExtern);
@@ -62,8 +62,7 @@ class Block final {
6262

6363
Block(unsigned EvalID, const Descriptor *Desc, bool IsStatic = false,
6464
bool IsExtern = false, bool IsWeak = false, bool IsDummy = false)
65-
: Desc(Desc), DeclID((unsigned)-1), EvalID(EvalID), IsStatic(IsStatic),
66-
IsDynamic(false) {
65+
: Desc(Desc), EvalID(EvalID), IsStatic(IsStatic), IsDynamic(false) {
6766
assert(Desc);
6867
AccessFlags |= (ExternFlag * IsExtern);
6968
AccessFlags |= (WeakFlag * IsWeak);
@@ -87,7 +86,7 @@ class Block final {
8786
/// Returns the size of the block.
8887
unsigned getSize() const { return Desc->getAllocSize(); }
8988
/// Returns the declaration ID.
90-
std::optional<unsigned> getDeclID() const { return DeclID; }
89+
UnsignedOrNone getDeclID() const { return DeclID; }
9190
/// Returns whether the data of this block has been initialized via
9291
/// invoking the Ctor func.
9392
bool isInitialized() const { return IsInitialized; }
@@ -177,7 +176,7 @@ class Block final {
177176
/// Start of the chain of pointers.
178177
Pointer *Pointers = nullptr;
179178
/// Unique identifier of the declaration.
180-
std::optional<unsigned> DeclID;
179+
UnsignedOrNone DeclID = std::nullopt;
181180
const unsigned EvalID = ~0u;
182181
/// Flag indicating if the block has static storage duration.
183182
bool IsStatic = false;

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class Pointer {
593593
}
594594

595595
/// Returns the declaration ID.
596-
std::optional<unsigned> getDeclID() const {
596+
UnsignedOrNone getDeclID() const {
597597
if (isBlockPointer()) {
598598
assert(asBlockPointer().Pointee);
599599
return asBlockPointer().Pointee->getDeclID();

clang/lib/AST/ByteCode/Program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Program final {
152152
};
153153

154154
/// Returns the current declaration ID.
155-
std::optional<unsigned> getCurrentDecl() const {
155+
UnsignedOrNone getCurrentDecl() const {
156156
if (CurrentDeclaration == NoDeclaration)
157157
return std::nullopt;
158158
return CurrentDeclaration;

clang/lib/AST/Expr.cpp

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,32 +2805,20 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
28052805

28062806
case CXXTemporaryObjectExprClass:
28072807
case CXXConstructExprClass: {
2808-
if (const CXXRecordDecl *Type = getType()->getAsCXXRecordDecl()) {
2809-
const auto *WarnURAttr = Type->getAttr<WarnUnusedResultAttr>();
2810-
if (Type->hasAttr<WarnUnusedAttr>() ||
2811-
(WarnURAttr && WarnURAttr->IsCXX11NoDiscard())) {
2812-
WarnE = this;
2813-
Loc = getBeginLoc();
2814-
R1 = getSourceRange();
2815-
return true;
2816-
}
2817-
}
2818-
28192808
const auto *CE = cast<CXXConstructExpr>(this);
2820-
if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
2821-
const auto *WarnURAttr = Ctor->getAttr<WarnUnusedResultAttr>();
2822-
if (WarnURAttr && WarnURAttr->IsCXX11NoDiscard()) {
2823-
WarnE = this;
2824-
Loc = getBeginLoc();
2825-
R1 = getSourceRange();
2809+
const CXXRecordDecl *Type = getType()->getAsCXXRecordDecl();
28262810

2827-
if (unsigned NumArgs = CE->getNumArgs())
2828-
R2 = SourceRange(CE->getArg(0)->getBeginLoc(),
2829-
CE->getArg(NumArgs - 1)->getEndLoc());
2830-
return true;
2831-
}
2832-
}
2811+
if ((Type && Type->hasAttr<WarnUnusedAttr>()) ||
2812+
CE->hasUnusedResultAttr(Ctx)) {
2813+
WarnE = this;
2814+
Loc = getBeginLoc();
2815+
R1 = getSourceRange();
28332816

2817+
if (unsigned NumArgs = CE->getNumArgs())
2818+
R2 = SourceRange(CE->getArg(0)->getBeginLoc(),
2819+
CE->getArg(NumArgs - 1)->getEndLoc());
2820+
return true;
2821+
}
28342822
return false;
28352823
}
28362824

0 commit comments

Comments
 (0)