Skip to content

Commit 8644b4f

Browse files
authored
Merge branch 'main' into fetch-lr-for-frameless-function-async-interrupted
2 parents 4fc9acd + 6babd63 commit 8644b4f

File tree

413 files changed

+11012
-5045
lines changed

Some content is hidden

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

413 files changed

+11012
-5045
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,15 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
9292
declRefExpr(to(equalsBoundNode("param"))))));
9393
auto RefToParm = capturesVar(
9494
varDecl(anyOf(hasSameNameAsBoundNode("param"), RefToParmImplicit)));
95-
auto HasRefToParm = hasAnyCapture(RefToParm);
9695

9796
auto CaptureInRef =
9897
allOf(hasCaptureDefaultKind(LambdaCaptureDefault::LCD_ByRef),
9998
unless(hasAnyCapture(
10099
capturesVar(varDecl(hasSameNameAsBoundNode("param"))))));
101-
auto CaptureInCopy = allOf(
102-
hasCaptureDefaultKind(LambdaCaptureDefault::LCD_ByCopy), HasRefToParm);
103100
auto CaptureByRefExplicit = hasAnyCapture(
104101
allOf(hasCaptureKind(LambdaCaptureKind::LCK_ByRef), RefToParm));
105102

106-
auto CapturedInBody =
107-
lambdaExpr(anyOf(CaptureInRef, CaptureInCopy, CaptureByRefExplicit));
103+
auto CapturedInBody = lambdaExpr(anyOf(CaptureInRef, CaptureByRefExplicit));
108104
auto CapturedInCaptureList = hasAnyCapture(capturesVar(
109105
varDecl(hasInitializer(ignoringParenImpCasts(equalsBoundNode("call"))))));
110106

clang/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,17 @@ check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
183183
# This check requires _GNU_SOURCE on linux
184184
check_include_file(dlfcn.h CLANG_HAVE_DLFCN_H)
185185
if( CLANG_HAVE_DLFCN_H )
186+
include(CMakePushCheckState)
186187
include(CheckLibraryExists)
187188
include(CheckSymbolExists)
188189
check_library_exists(dl dlopen "" HAVE_LIBDL)
190+
cmake_push_check_state()
189191
if( HAVE_LIBDL )
190192
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
191193
endif()
192194
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
193195
check_symbol_exists(dladdr dlfcn.h CLANG_HAVE_DLADDR)
194-
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
195-
if( HAVE_LIBDL )
196-
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
197-
endif()
196+
cmake_pop_check_state()
198197
endif()
199198

200199
set(CLANG_RESOURCE_DIR "" CACHE STRING

clang/Maintainers.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ Clang LLVM IR generation
5151
| Anton Korobeynikov
5252
| anton\@korobeynikov.info (email), asl (Phabricator), asl (GitHub)
5353
54+
Clang MLIR generation
55+
~~~~~~~~~~~~~~~~~~~~~
56+
| Andy Kaylor
57+
| akaylor\@nvidia.com (email), AndyKaylor (Discord), AndyKaylor (GitHub)
58+
59+
| Bruno Cardoso Lopes
60+
| bruno.cardoso\@gmail.com (email), sonicsprawl (Discord), bcardosolopes (GitHub)
61+
5462

5563
Analysis & CFG
5664
~~~~~~~~~~~~~~
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build.
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake)
4+
5+
if(NOT APPLE)
6+
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
7+
endif()
8+
9+
set(CLANG_BOOTSTRAP_TARGETS
10+
check-all
11+
check-clang
12+
check-lld
13+
check-llvm
14+
check-polly
15+
clang
16+
clang-test-depends
17+
toolchain-distribution
18+
install-toolchain-distribution
19+
install-toolchain-distribution-stripped
20+
install-toolchain-distribution-toolchain
21+
lld-test-depends
22+
llvm-config
23+
llvm-test-depends
24+
test-depends
25+
test-suite CACHE STRING "")
26+
27+
get_cmake_property(variableNames VARIABLES)
28+
foreach(variableName ${variableNames})
29+
if(variableName MATCHES "^STAGE2_")
30+
string(REPLACE "STAGE2_" "" new_name ${variableName})
31+
list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
32+
endif()
33+
endforeach()
34+
35+
set(CLANG_PGO_TRAINING_DEPS
36+
builtins
37+
runtimes
38+
CACHE STRING "")
39+
40+
# Setup the bootstrap build.
41+
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
42+
set(CLANG_BOOTSTRAP_CMAKE_ARGS
43+
${EXTRA_ARGS}
44+
-C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
45+
CACHE STRING "")

clang/cmake/caches/Fuchsia.cmake

Lines changed: 78 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ else()
126126
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
127127
set(LIBCXX_HARDENING_MODE "none" CACHE STRING "")
128128
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
129+
set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
130+
set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "")
131+
set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
132+
set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
133+
set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
134+
set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
135+
set(SANITIZER_CXX_ABI "libc++" CACHE STRING "")
136+
set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
137+
set(SANITIZER_TEST_CXX "libc++" CACHE STRING "")
138+
set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
129139
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
130140
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
131141
endif()
@@ -165,33 +175,59 @@ endif()
165175
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
166176
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
167177

168-
set(_FUCHSIA_BOOTSTRAP_TARGETS
169-
check-all
170-
check-clang
171-
check-lld
172-
check-llvm
173-
check-polly
174-
llvm-config
175-
clang-test-depends
176-
lld-test-depends
177-
llvm-test-depends
178-
test-suite
179-
test-depends
180-
toolchain-distribution
181-
install-toolchain-distribution
182-
install-toolchain-distribution-stripped
183-
install-toolchain-distribution-toolchain
184-
clang)
185-
186-
if(FUCHSIA_ENABLE_LLDB)
187-
list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
188-
list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
189-
check-lldb
190-
lldb-test-depends
191-
debugger-distribution
192-
install-debugger-distribution
193-
install-debugger-distribution-stripped
194-
install-debugger-distribution-toolchain)
178+
if(FUCHSIA_ENABLE_PGO)
179+
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
180+
181+
set(_FUCHSIA_BOOTSTRAP_TARGETS
182+
generate-profdata
183+
stage2
184+
stage2-toolchain-distribution
185+
stage2-install-toolchain-distribution
186+
stage2-install-toolchain-distribution-stripped
187+
stage2-install-toolchain-distribution-toolchain
188+
stage2-check-all
189+
stage2-check-clang
190+
stage2-check-lld
191+
stage2-check-llvm
192+
stage2-check-polly
193+
stage2-test-suite)
194+
if(FUCHSIA_ENABLE_LLDB)
195+
list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
196+
list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
197+
stage2-check-lldb
198+
stage2-debugger-distribution
199+
stage2-install-debugger-distribution
200+
stage2-install-debugger-distribution-stripped
201+
stage2-install-debugger-distribution-toolchain)
202+
endif()
203+
else()
204+
set(_FUCHSIA_BOOTSTRAP_TARGETS
205+
check-all
206+
check-clang
207+
check-lld
208+
check-llvm
209+
check-polly
210+
llvm-config
211+
clang
212+
clang-test-depends
213+
lld-test-depends
214+
llvm-test-depends
215+
test-suite
216+
test-depends
217+
toolchain-distribution
218+
install-toolchain-distribution
219+
install-toolchain-distribution-stripped
220+
install-toolchain-distribution-toolchain)
221+
if(FUCHSIA_ENABLE_LLDB)
222+
list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
223+
list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
224+
check-lldb
225+
lldb-test-depends
226+
debugger-distribution
227+
install-debugger-distribution
228+
install-debugger-distribution-stripped
229+
install-debugger-distribution-toolchain)
230+
endif()
195231
endif()
196232

197233
set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
@@ -200,6 +236,7 @@ set(CLANG_BOOTSTRAP_TARGETS ${_FUCHSIA_BOOTSTRAP_TARGETS} CACHE STRING "")
200236
get_cmake_property(variableNames VARIABLES)
201237
foreach(variableName ${variableNames})
202238
if(variableName MATCHES "^STAGE2_")
239+
list(APPEND EXTRA_ARGS "-D${variableName}=${${variableName}}")
203240
string(REPLACE "STAGE2_" "" new_name ${variableName})
204241
string(REPLACE ";" "|" value "${${variableName}}")
205242
list(APPEND EXTRA_ARGS "-D${new_name}=${value}")
@@ -209,13 +246,23 @@ endforeach()
209246
# TODO: This is a temporary workaround until we figure out the right solution.
210247
set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
211248

249+
set(LLVM_BUILTIN_TARGETS "default" CACHE STRING "")
250+
set(LLVM_RUNTIME_TARGETS "default" CACHE STRING "")
251+
212252
# Setup the bootstrap build.
213253
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
214254
set(CLANG_BOOTSTRAP_EXTRA_DEPS
215255
builtins
216256
runtimes
217257
CACHE STRING "")
218-
set(CLANG_BOOTSTRAP_CMAKE_ARGS
219-
${EXTRA_ARGS}
220-
-C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
221-
CACHE STRING "")
258+
if(FUCHSIA_ENABLE_PGO)
259+
set(CLANG_BOOTSTRAP_CMAKE_ARGS
260+
${EXTRA_ARGS}
261+
-C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2-instrumented.cmake
262+
CACHE STRING "")
263+
else()
264+
set(CLANG_BOOTSTRAP_CMAKE_ARGS
265+
${EXTRA_ARGS}
266+
-C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
267+
CACHE STRING "")
268+
endif()

clang/docs/HIPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ Predefined Macros
518518
* - ``__HIPSTDPAR__``
519519
- Defined when Clang is compiling code in algorithm offload mode, enabled
520520
with the ``--hipstdpar`` compiler option.
521-
* - ``__HIPSTDPAR_INTERPOSE_ALLOC__``
521+
* - ``__HIPSTDPAR_INTERPOSE_ALLOC__`` / ``__HIPSTDPAR_INTERPOSE_ALLOC_V1__``
522522
- Defined only when compiling in algorithm offload mode, when the user
523523
enables interposition mode with the ``--hipstdpar-interpose-alloc``
524524
compiler option, indicating that all dynamic memory allocation /

clang/docs/LanguageExtensions.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,12 +1859,18 @@ The following type trait primitives are supported by Clang. Those traits marked
18591859
* ``__is_trivially_constructible`` (C++, GNU, Microsoft)
18601860
* ``__is_trivially_copyable`` (C++, GNU, Microsoft)
18611861
* ``__is_trivially_destructible`` (C++, MSVC 2013)
1862-
* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
1862+
* ``__is_trivially_relocatable`` (Clang) (Deprecated,
1863+
use ``__builtin_is_cpp_trivially_relocatable`` instead).
1864+
Returns true if moving an object
18631865
of the given type, and then destroying the source object, is known to be
18641866
functionally equivalent to copying the underlying bytes and then dropping the
18651867
source object on the floor. This is true of trivial types,
18661868
C++26 relocatable types, and types which
18671869
were made trivially relocatable via the ``clang::trivial_abi`` attribute.
1870+
This trait is deprecated and should be replaced by
1871+
``__builtin_is_cpp_trivially_relocatable``. Note however that it is generally
1872+
unsafe to relocate a C++-relocatable type with ``memcpy`` or ``memmove``;
1873+
use ``__builtin_trivially_relocate``.
18681874
* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if an object
18691875
is trivially relocatable, as defined by the C++26 standard [meta.unary.prop].
18701876
Note that when relocating the caller code should ensure that if the object is polymorphic,

clang/docs/ReleaseNotes.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ Improvements to Clang's diagnostics
434434
- The ``-Wsign-compare`` warning now treats expressions with bitwise not(~) and minus(-) as signed integers
435435
except for the case where the operand is an unsigned integer
436436
and throws warning if they are compared with unsigned integers (##18878).
437-
- The ``-Wunnecessary-virtual-specifier`` warning has been added to warn about
438-
methods which are marked as virtual inside a ``final`` class, and hence can
439-
never be overridden.
437+
- The ``-Wunnecessary-virtual-specifier`` warning (included in ``-Wextra``) has
438+
been added to warn about methods which are marked as virtual inside a
439+
``final`` class, and hence can never be overridden.
440440

441441
- Improve the diagnostics for chained comparisons to report actual expressions and operators (#GH129069).
442442

@@ -574,6 +574,15 @@ Bug Fixes to Compiler Builtins
574574
- ``__has_unique_object_representations(Incomplete[])`` is no longer accepted, per
575575
`LWG4113 <https://cplusplus.github.io/LWG/issue4113>`_.
576576

577+
- ``__builtin_is_cpp_trivially_relocatable``, ``__builtin_is_replaceable`` and
578+
``__builtin_trivially_relocate`` have been added to support standard C++26 relocation.
579+
580+
- ``__is_trivially_relocatable`` has been deprecated, and uses should be replaced by
581+
``__builtin_is_cpp_trivially_relocatable``.
582+
Note that, it is generally unsafe to ``memcpy`` non-trivially copyable types that
583+
are ``__builtin_is_cpp_trivially_relocatable``. It is recommended to use
584+
``__builtin_trivially_relocate`` instead.
585+
577586
Bug Fixes to Attribute Support
578587
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
579588
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125
@@ -660,6 +669,8 @@ Bug Fixes to C++ Support
660669
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
661670
- No longer crashes when instantiating invalid variable template specialization
662671
whose type depends on itself. (#GH51347), (#GH55872)
672+
- Improved parser recovery of invalid requirement expressions. In turn, this
673+
fixes crashes from follow-on processing of the invalid requirement. (#GH138820)
663674

664675
Bug Fixes to AST Handling
665676
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/SanitizerCoverage.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,50 @@ Users need to implement a single function to capture the CF table at startup:
385385
// the collected control flow.
386386
}
387387
388+
Tracing Stack Depth
389+
===================
390+
391+
With ``-fsanitize-coverage=stack-depth`` the compiler will track how much
392+
stack space has been used for a function call chain. Leaf functions are
393+
not included in this tracing.
394+
395+
The maximum depth of a function call graph is stored in the thread-local
396+
``__sancov_lowest_stack`` variable. Instrumentation is inserted in every
397+
non-leaf function to check the frame pointer against this variable,
398+
and if it is lower, store the current frame pointer. This effectively
399+
inserts the following:
400+
401+
.. code-block:: c++
402+
403+
extern thread_local uintptr_t __sancov_lowest_stack;
404+
405+
uintptr_t stack = (uintptr_t)__builtin_frame_address(0);
406+
if (stack < __sancov_lowest_stack)
407+
__sancov_lowest_stack = stack;
408+
409+
If ``-fsanitize-coverage-stack-depth-callback-min=N`` (where
410+
``N > 0``) is also used, the tracking is delegated to a callback,
411+
``__sanitizer_cov_stack_depth``, instead of adding instrumentation to
412+
update ``__sancov_lowest_stack``. The ``N`` of the argument is used
413+
to determine which functions to instrument. Only functions estimated
414+
to be using ``N`` bytes or more of stack space will be instrumented to
415+
call the tracing callback. In the case of a dynamically sized stack,
416+
the callback is unconditionally added.
417+
418+
The callback takes no arguments and is responsible for determining
419+
the stack usage and doing any needed comparisons and storage. A roughly
420+
equivalent implementation of ``__sancov_lowest_stack`` using the callback
421+
would look like this:
422+
423+
.. code-block:: c++
424+
425+
void __sanitizer_cov_stack_depth(void) {
426+
uintptr_t stack = (uintptr_t)__builtin_frame_address(0);
427+
428+
if (stack < __sancov_lowest_stack)
429+
__sancov_lowest_stack = stack;
430+
}
431+
388432
Gated Trace Callbacks
389433
=====================
390434

clang/include/clang/APINotes/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ class TagInfo : public CommonTypeInfo {
737737
std::optional<std::string> SwiftImportAs;
738738
std::optional<std::string> SwiftRetainOp;
739739
std::optional<std::string> SwiftReleaseOp;
740+
std::optional<std::string> SwiftDefaultOwnership;
740741

741742
/// The Swift protocol that this type should be automatically conformed to.
742743
std::optional<std::string> SwiftConformance;
@@ -786,6 +787,8 @@ class TagInfo : public CommonTypeInfo {
786787
SwiftRetainOp = RHS.SwiftRetainOp;
787788
if (!SwiftReleaseOp)
788789
SwiftReleaseOp = RHS.SwiftReleaseOp;
790+
if (!SwiftDefaultOwnership)
791+
SwiftDefaultOwnership = RHS.SwiftDefaultOwnership;
789792

790793
if (!SwiftConformance)
791794
SwiftConformance = RHS.SwiftConformance;
@@ -815,6 +818,7 @@ inline bool operator==(const TagInfo &LHS, const TagInfo &RHS) {
815818
LHS.SwiftImportAs == RHS.SwiftImportAs &&
816819
LHS.SwiftRetainOp == RHS.SwiftRetainOp &&
817820
LHS.SwiftReleaseOp == RHS.SwiftReleaseOp &&
821+
LHS.SwiftDefaultOwnership == RHS.SwiftDefaultOwnership &&
818822
LHS.SwiftConformance == RHS.SwiftConformance &&
819823
LHS.isFlagEnum() == RHS.isFlagEnum() &&
820824
LHS.isSwiftCopyable() == RHS.isSwiftCopyable() &&

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table.
305305
CODEGENOPT(SanitizeCoverageControlFlow, 1, 0) ///< Collect control flow
306306
CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
307307
CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth tracing
308+
VALUE_CODEGENOPT(SanitizeCoverageStackDepthCallbackMin , 32, 0) ///< Enable stack depth tracing callbacks.
308309
CODEGENOPT(SanitizeCoverageTraceLoads, 1, 0) ///< Enable tracing of loads.
309310
CODEGENOPT(SanitizeCoverageTraceStores, 1, 0) ///< Enable tracing of stores.
310311
CODEGENOPT(SanitizeBinaryMetadataCovered, 1, 0) ///< Emit PCs for covered functions.

0 commit comments

Comments
 (0)