Skip to content

Commit 8b549f6

Browse files
committed
Merge from 'main' to 'sycl-web' (43 commits)
CONFLICT (content): Merge conflict in llvm/unittests/Support/Base64Test.cpp CONFLICT (add/add): Merge conflict in llvm/lib/Support/Base64.cpp CONFLICT (content): Merge conflict in llvm/include/llvm/Support/Base64.h
2 parents c518ab0 + ea9ac35 commit 8b549f6

File tree

132 files changed

+3007
-1000
lines changed

Some content is hidden

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

132 files changed

+3007
-1000
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ void ProBoundsConstantArrayIndexCheck::check(
6161
const auto *Matched = Result.Nodes.getNodeAs<Expr>("expr");
6262
const auto *IndexExpr = Result.Nodes.getNodeAs<Expr>("index");
6363

64+
// This expression can only appear inside ArrayInitLoopExpr, which
65+
// is always implicitly generated. ArrayInitIndexExpr is not a
66+
// constant, but we shouldn't report a warning for it.
67+
if (isa<ArrayInitIndexExpr>(IndexExpr))
68+
return;
69+
6470
if (IndexExpr->isValueDependent())
6571
return; // We check in the specialization.
6672

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,34 @@ void customOperator() {
7575
s[i] = 3; // OK, custom operator
7676
}
7777

78+
namespace ArrayInitIndexExpr {
7879
struct A {
7980
// The compiler-generated copy constructor uses an ArraySubscriptExpr. Don't warn.
8081
int x[3];
8182
};
8283

83-
void use_A() {
84+
void implicitCopyMoveCtor() {
8485
// Force the compiler to generate a copy constructor.
8586
A a;
8687
A a2(a);
88+
89+
// Force the compiler to generate a move constructor.
90+
A a3 = (A&&) a;
91+
}
92+
93+
void lambdaCapture() {
94+
int arr[3];
95+
96+
// Capturing an array by value uses an ArraySubscriptExpr. Don't warn.
97+
[arr](){};
98+
}
99+
100+
#if __cplusplus >= 201703L
101+
void structuredBindings() {
102+
int arr[3];
103+
104+
// Creating structured bindings by value uses an ArraySubscriptExpr. Don't warn.
105+
auto [a,b,c] = arr;
87106
}
107+
#endif
108+
} // namespace ArrayInitIndexExpr

clang/docs/HLSL/EntryFunctions.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
====================
2+
HLSL Entry Functions
3+
====================
4+
5+
.. contents::
6+
:local:
7+
8+
Usage
9+
=====
10+
11+
In HLSL, entry functions denote the starting point for shader execution. They
12+
must be known at compile time. For all non-library shaders, the compiler assumes
13+
the default entry function name ``main``, unless the DXC ``/E`` option is
14+
provided to specify an alternate entry point. For library shaders entry points
15+
are denoted using the ``[shader(...)]`` attribute.
16+
17+
All scalar parameters to entry functions must have semantic annotations, and all
18+
struct parameters must have semantic annotations on every field in the struct
19+
declaration. Additionally if the entry function has a return type, a semantic
20+
annotation must be provided for the return type as well.
21+
22+
HLSL entry functions can be called from other parts of the shader, which has
23+
implications on code generation.
24+
25+
Implementation Details
26+
======================
27+
28+
In Clang, the DXC ``/E`` option is translated to the cc1 flag ``-hlsl-entry``,
29+
which in turn applies the ``HLSLShader`` attribute to the function with the
30+
specified name. This allows code generation for entry functions to always key
31+
off the presence of the ``HLSLShader`` attribute, regardless of what shader
32+
profile you are compiling.
33+
34+
In code generation, two functions are generated. One is the user defined
35+
function, which is code generated as a mangled C++ function with internal
36+
linkage following normal function code generation.
37+
38+
The actual exported entry function which can be called by the GPU driver is a
39+
``void(void)`` function that isn't name mangled. In code generation we generate
40+
the unmangled entry function, instantiations of the parameters with their
41+
semantic values populated, and a call to the user-defined function. After the
42+
call instruction the return value (if any) is saved using a target-appropriate
43+
intrinsic for storing outputs (for DirectX, the ``llvm.dx.store.output``).
44+
45+
.. note::
46+
47+
HLSL support in Clang is currently focused on compute shaders, which do not
48+
support output semantics. Support for output semantics will not be
49+
implemented until other shader profiles are supported.
50+
51+
Below is example IR that represents the planned implementation, subject to
52+
change as the ``llvm.dx.store.output`` and ``llvm.dx.load.input`` intrinsics are
53+
not yet implemented.
54+
55+
.. code-block:: none
56+
57+
; Function Attrs: norecurse
58+
define void @main() #1 {
59+
entry:
60+
%0 = call i32 @llvm.dx.load.input.i32(...)
61+
%1 = call i32 @"?main@@YAXII@Z"(i32 %0)
62+
call @llvm.dx.store.output.i32(%1, ...)
63+
ret void
64+
}
65+

clang/docs/HLSL/HLSLDocs.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ HLSL Design and Implementation
1212
:maxdepth: 1
1313

1414
ResourceTypes
15+
EntryFunctions

clang/docs/HLSL/ResourceTypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
============
2-
HLSL Support
3-
============
1+
===================
2+
HLSL Resource Types
3+
===================
44

55
.. contents::
66
:local:

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ C++20 Feature Support
198198
and `DR1734 <https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1734>`_.
199199
- Class member variables are now in scope when parsing a ``requires`` clause. Fixes
200200
`GH55216 <https://github.com/llvm/llvm-project/issues/55216>`_.
201-
202201
- Correctly set expression evaluation context as 'immediate function context' in
203202
consteval functions.
204203
This fixes `GH51182 <https://github.com/llvm/llvm-project/issues/51182>`
204+
- Fixes an assert crash caused by looking up missing vtable information on ``consteval``
205+
virtual functions. Fixes `GH55065 <https://github.com/llvm/llvm-project/issues/55065>`_.
205206

206207

207208
C++2b Feature Support

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "clang/AST/Expr.h"
2727
#include "clang/AST/RecordLayout.h"
2828
#include "clang/AST/RecursiveASTVisitor.h"
29+
#include "clang/AST/VTableBuilder.h"
2930
#include "clang/Basic/CodeGenOptions.h"
3031
#include "clang/Basic/FileManager.h"
3132
#include "clang/Basic/SourceManager.h"
@@ -1765,7 +1766,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
17651766
llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
17661767
int ThisAdjustment = 0;
17671768

1768-
if (Method->isVirtual()) {
1769+
if (VTableContextBase::hasVtableSlot(Method)) {
17691770
if (Method->isPure())
17701771
SPFlags |= llvm::DISubprogram::SPFlagPureVirtual;
17711772
else

clang/lib/Lex/ModuleMap.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,8 +2026,7 @@ void ModuleMapParser::parseModuleDecl() {
20262026
ActiveModule->IsSystem = true;
20272027
if (Attrs.IsExternC)
20282028
ActiveModule->IsExternC = true;
2029-
if (Attrs.NoUndeclaredIncludes ||
2030-
(!ActiveModule->Parent && ModuleName == "Darwin"))
2029+
if (Attrs.NoUndeclaredIncludes)
20312030
ActiveModule->NoUndeclaredIncludes = true;
20322031
ActiveModule->Directory = Directory;
20332032

clang/test/CodeGenCXX/cxx20-consteval-crash.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm -o - | FileCheck %s
2+
// RUN: %clang_cc1 -emit-obj -debug-info-kind=constructor -std=c++20 %s -o -
23

34
namespace PR50787 {
45
// This code would previously cause a crash.
@@ -71,3 +72,23 @@ int foo() {
7172
return function(Item{'a'}, Item{'a'});
7273
}
7374
} // namespace Issue58871
75+
76+
namespace Issue55065 {
77+
struct Base {
78+
consteval virtual int Get() const = 0;
79+
};
80+
81+
struct Derived : Base {
82+
consteval int Get() const override {
83+
return 42;
84+
}
85+
};
86+
87+
int foo() {
88+
constexpr Derived a;
89+
90+
auto val = a.Get();
91+
return val;
92+
}
93+
} // namespace Issue55065
94+

compiler-rt/lib/profile/InstrProfilingWriter.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
276276
/* Create the header. */
277277
__llvm_profile_header Header;
278278

279-
if (!NumData && (!DebugInfoCorrelate || !NumCounters))
280-
return 0;
281-
282279
/* Determine how much padding is needed before/after the counters and after
283280
* the names. */
284281
uint64_t PaddingBytesBeforeCounters, PaddingBytesAfterCounters,

0 commit comments

Comments
 (0)