Skip to content

Commit f48fb98

Browse files
committed
Merge from 'main' to 'sycl-web' (246 commits)
CONFLICT (content): Merge conflict in llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
2 parents a089523 + 4ea6ffb commit f48fb98

File tree

835 files changed

+47791
-13274
lines changed

Some content is hidden

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

835 files changed

+47791
-13274
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,19 @@ void RewriteInstance::parsePseudoProbe() {
599599
errs() << "BOLT-WARNING: fail in building GUID2FuncDescMap\n";
600600
return;
601601
}
602+
603+
MCPseudoProbeDecoder::Uint64Set GuidFilter;
604+
MCPseudoProbeDecoder::Uint64Map FuncStartAddrs;
605+
for (const BinaryFunction *F : BC->getAllBinaryFunctions()) {
606+
for (const MCSymbol *Sym : F->getSymbols()) {
607+
FuncStartAddrs[Function::getGUID(NameResolver::restore(Sym->getName()))] =
608+
F->getAddress();
609+
}
610+
}
602611
Contents = PseudoProbeSection->getContents();
603612
if (!BC->ProbeDecoder.buildAddress2ProbeMap(
604-
reinterpret_cast<const uint8_t *>(Contents.data()),
605-
Contents.size())) {
613+
reinterpret_cast<const uint8_t *>(Contents.data()), Contents.size(),
614+
GuidFilter, FuncStartAddrs)) {
606615
BC->ProbeDecoder.getAddress2ProbesMap().clear();
607616
errs() << "BOLT-WARNING: fail in building Address2ProbeMap\n";
608617
return;
@@ -3426,6 +3435,8 @@ void RewriteInstance::encodePseudoProbes() {
34263435
// Address of the first probe is absolute.
34273436
// Other probes' address are represented by delta
34283437
auto EmitDecodedPseudoProbe = [&](MCDecodedPseudoProbe *&CurProbe) {
3438+
assert(!isSentinelProbe(CurProbe->getAttributes()) &&
3439+
"Sentinel probes should not be emitted");
34293440
EmitULEB128IntValue(CurProbe->getIndex());
34303441
uint8_t PackedType = CurProbe->getType() | (CurProbe->getAttributes() << 4);
34313442
uint8_t Flag =
@@ -3530,9 +3541,17 @@ void RewriteInstance::encodePseudoProbes() {
35303541
reinterpret_cast<const uint8_t *>(DescContents.data()),
35313542
DescContents.size());
35323543
StringRef ProbeContents = PseudoProbeSection->getOutputContents();
3544+
MCPseudoProbeDecoder::Uint64Set GuidFilter;
3545+
MCPseudoProbeDecoder::Uint64Map FuncStartAddrs;
3546+
for (const BinaryFunction *F : BC->getAllBinaryFunctions()) {
3547+
const uint64_t Addr =
3548+
F->isEmitted() ? F->getOutputAddress() : F->getAddress();
3549+
FuncStartAddrs[Function::getGUID(
3550+
NameResolver::restore(F->getOneName()))] = Addr;
3551+
}
35333552
DummyDecoder.buildAddress2ProbeMap(
35343553
reinterpret_cast<const uint8_t *>(ProbeContents.data()),
3535-
ProbeContents.size());
3554+
ProbeContents.size(), GuidFilter, FuncStartAddrs);
35363555
DummyDecoder.printProbesForAllAddresses(outs());
35373556
}
35383557
}

clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
241241
this);
242242
Finder->addMatcher(
243243
cxxConstructorDecl(
244-
unless(hasParent(IsUnionLikeClass)), isDefinition(),
244+
unless(
245+
hasParent(decl(anyOf(IsUnionLikeClass, functionTemplateDecl())))),
246+
isDefinition(),
245247
anyOf(
246248
// Default constructor.
247249
allOf(unless(hasAnyConstructorInitializer(isWritten())),
@@ -257,8 +259,9 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
257259
this);
258260
// Copy-assignment operator.
259261
Finder->addMatcher(
260-
cxxMethodDecl(unless(hasParent(IsUnionLikeClass)), isDefinition(),
261-
isCopyAssignmentOperator(),
262+
cxxMethodDecl(unless(hasParent(
263+
decl(anyOf(IsUnionLikeClass, functionTemplateDecl())))),
264+
isDefinition(), isCopyAssignmentOperator(),
262265
// isCopyAssignmentOperator() allows the parameter to be
263266
// passed by value, and in this case it cannot be
264267
// defaulted.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ Changes in existing checks
158158
The check now skips unions/union-like classes since in this case a default constructor
159159
with empty body is not equivalent to the explicitly defaulted one, variadic constructors
160160
since they cannot be explicitly defaulted. The check also skips copy assignment operators
161-
with nonstandard return types, private/protected default constructors for C++17 or earlier.
162-
The automatic fixit has been adjusted to avoid adding superfluous semicolon.
163-
The check is restricted to C++11 or later.
161+
with nonstandard return types, template constructors, private/protected default constructors
162+
for C++17 or earlier. The automatic fixit has been adjusted to avoid adding superfluous
163+
semicolon. The check is restricted to C++11 or later.
164164

165165
- Change the default behavior of :doc:`readability-avoid-const-params-in-decls
166166
<clang-tidy/checks/readability/avoid-const-params-in-decls>` to not

clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ struct VA {
5858
VA(...) {}
5959
};
6060

61+
// Skip template constructors.
62+
struct TC {
63+
template <unsigned U>
64+
TC() {}
65+
66+
template <unsigned U>
67+
TC(const TC &) {}
68+
69+
template <unsigned U>
70+
TC& operator = (const TC &) { return *this; }
71+
};
72+
6173
// Initializer or arguments.
6274
class IA {
6375
public:

clang/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
cmake_minimum_required(VERSION 3.13.4)
22

3+
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
4+
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
5+
endif()
6+
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
7+
NO_POLICY_SCOPE)
8+
39
# If we are not building as a part of LLVM, build Clang as an
410
# standalone project, using LLVM as an external library:
511
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -136,10 +142,6 @@ if(CLANG_BUILT_STANDALONE)
136142
endif() # LLVM_INCLUDE_TESTS
137143
endif() # standalone
138144

139-
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
140-
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
141-
endif()
142-
143145
# Make sure that our source directory is on the current cmake module path so that
144146
# we can include cmake files from this directory.
145147
list(INSERT CMAKE_MODULE_PATH 0

clang/bindings/python/clang/cindex.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,31 @@ def is_deleted_method(self):
14791479
"""
14801480
return conf.lib.clang_CXXMethod_isDeleted(self)
14811481

1482+
def is_copy_assignment_operator_method(self):
1483+
"""Returnrs True if the cursor refers to a copy-assignment operator.
1484+
1485+
A copy-assignment operator `X::operator=` is a non-static,
1486+
non-template member function of _class_ `X` with exactly one
1487+
parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
1488+
volatile X&`.
1489+
1490+
1491+
That is, for example, the `operator=` in:
1492+
1493+
class Foo {
1494+
bool operator=(const volatile Foo&);
1495+
};
1496+
1497+
Is a copy-assignment operator, while the `operator=` in:
1498+
1499+
class Bar {
1500+
bool operator=(const int&);
1501+
};
1502+
1503+
Is not.
1504+
"""
1505+
return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self)
1506+
14821507
def is_mutable_field(self):
14831508
"""Returns True if the cursor refers to a C++ field that is declared
14841509
'mutable'.
@@ -3436,6 +3461,10 @@ def cursor(self):
34363461
[Cursor],
34373462
bool),
34383463

3464+
("clang_CXXMethod_isCopyAssignmentOperator",
3465+
[Cursor],
3466+
bool),
3467+
34393468
("clang_CXXMethod_isPureVirtual",
34403469
[Cursor],
34413470
bool),

clang/docs/ClangFormat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ your `.vimrc`:
168168
169169
function! Formatonsave()
170170
let l:formatdiff = 1
171-
pyf ~/llvm/tools/clang/tools/clang-format/clang-format.py
171+
pyf <path-to-this-file>/clang-format.py
172172
endfunction
173173
autocmd BufWritePre *.h,*.cc,*.cpp call Formatonsave()
174174

clang/docs/ReleaseNotes.rst

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ Bug Fixes
255255
- Reject non-type template arguments formed by casting a non-zero integer
256256
to a pointer in pre-C++17 modes, instead of treating them as null
257257
pointers.
258+
- Fix template arguments of pointer and reference not taking the type as
259+
part of their identity.
260+
`Issue 47136 <https://github.com/llvm/llvm-project/issues/47136>`_
258261

259262
Improvements to Clang's diagnostics
260263
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -328,6 +331,13 @@ Improvements to Clang's diagnostics
328331
- Clang now correctly points to the problematic parameter for the ``-Wnonnull``
329332
warning. This fixes
330333
`Issue 58273 <https://github.com/llvm/llvm-project/issues/58273>`_.
334+
- Introduced ``-Wcast-function-type-strict`` to warn about function type mismatches
335+
in casts that may result in runtime indirect call `Control-Flow Integrity (CFI)
336+
<https://clang.llvm.org/docs/ControlFlowIntegrity.html>`_ failures. This diagnostic
337+
is grouped under ``-Wcast-function-type`` as it identifies a more strict set of
338+
potentially problematic function type casts.
339+
- Clang will now disambiguate NTTP types when printing diagnostic that contain NTTP types.
340+
Fixes `Issue 57562 <https://github.com/llvm/llvm-project/issues/57562>`_.
331341

332342
Non-comprehensive list of changes in this release
333343
-------------------------------------------------
@@ -383,9 +393,27 @@ New Compiler Flags
383393
`::operator new(size_­t, std::aligned_val_t, nothrow_­t)` if there is
384394
`get_­return_­object_­on_­allocation_­failure`. We feel this is more consistent
385395
with the intention.
396+
386397
- Added ``--no-default-config`` to disable automatically loading configuration
387398
files using default paths.
388399

400+
- Added the new level, ``3``, to the ``-fstrict-flex-arrays=`` flag. The new
401+
level is the strict, standards-conforming mode for flexible array members. It
402+
recognizes only incomplete arrays as flexible array members (which is how the
403+
feature is defined by the C standard).
404+
405+
.. code-block:: c
406+
407+
struct foo {
408+
int a;
409+
int b[]; // Flexible array member.
410+
};
411+
412+
struct bar {
413+
int a;
414+
int b[0]; // NOT a flexible array member.
415+
};
416+
389417
Deprecated Compiler Flags
390418
-------------------------
391419
- ``-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang``
@@ -548,9 +576,13 @@ C++20 Feature Support
548576
- Implemented `P0634r3 <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0634r3.html>`_,
549577
which removes the requirement for the ``typename`` keyword in certain contexts.
550578
- Implemented The Equality Operator You Are Looking For (`P2468 <http://wg21.link/p2468r2>`_).
551-
552579
- Implemented `P2113R0: Proposed resolution for 2019 comment CA 112 <https://wg21.link/P2113R0>`_
553580
([temp.func.order]p6.2.1 is not implemented, matching GCC).
581+
- Implemented `P0857R0 <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0857r0.html>`_,
582+
which specifies constrained lambdas and constrained template *template-parameter*\s.
583+
584+
- Do not hide templated base members introduced via using-decl in derived class
585+
(useful specially for constrained members). Fixes `GH50886 <https://github.com/llvm/llvm-project/issues/50886>`_.
554586

555587
C++2b Feature Support
556588
^^^^^^^^^^^^^^^^^^^^^
@@ -579,6 +611,10 @@ ABI Changes in Clang
579611
such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
580612
You can switch back to the old ABI behavior with the flag:
581613
``-fclang-abi-compat=15.0``.
614+
- GCC allows POD types to have defaulted special members. Clang historically
615+
classified such types as non-POD. Clang now matches the gcc behavior (except
616+
on Darwin and PS4). You can switch back to the old ABI behavior with the flag:
617+
``-fclang-abi-compat=15.0``.
582618

583619
OpenMP Support in Clang
584620
-----------------------
@@ -606,6 +642,18 @@ X86 Support in Clang
606642
- Support ISA of ``CMPCCXADD``.
607643
* Support intrinsic of ``__cmpccxadd_epi32``.
608644
* Support intrinsic of ``__cmpccxadd_epi64``.
645+
- Add support for ``RAO-INT`` instructions.
646+
* Support intrinsic of ``_aadd_i32/64``
647+
* Support intrinsic of ``_aand_i32/64``
648+
* Support intrinsic of ``_aor_i32/64``
649+
* Support intrinsic of ``_axor_i32/64``
650+
- Support ISA of ``AVX-IFMA``.
651+
* Support intrinsic of ``_mm(256)_madd52hi_avx_epu64``.
652+
* Support intrinsic of ``_mm(256)_madd52lo_avx_epu64``.
653+
- Support ISA of ``AVX-VNNI-INT8``.
654+
* Support intrinsic of ``_mm(256)_dpbssd(s)_epi32``.
655+
* Support intrinsic of ``_mm(256)_dpbsud(s)_epi32``.
656+
* Support intrinsic of ``_mm(256)_dpbuud(s)_epi32``.
609657

610658
WebAssembly Support in Clang
611659
----------------------------
@@ -616,6 +664,13 @@ proposals are standardized and available in all major engines.
616664
DWARF Support in Clang
617665
----------------------
618666

667+
Previously when emitting DWARFv4 and tuning for GDB, Clang would use DWARF v2's
668+
``DW_AT_bit_offset`` and ``DW_AT_data_member_location``. Clang now uses DWARF v4's
669+
``DW_AT_data_bit_offset`` regardless of tuning.
670+
671+
Support for ``DW_AT_data_bit_offset`` was added in GDB 8.0. For earlier versions,
672+
you can use the ``-gdwarf-3`` option to emit compatible DWARF.
673+
619674
Arm and AArch64 Support in Clang
620675
--------------------------------
621676

@@ -665,8 +720,11 @@ libclang
665720
the behavior of ``QualType::getNonReferenceType`` for ``CXType``.
666721
- Introduced the new function ``clang_CXXMethod_isDeleted``, which queries
667722
whether the method is declared ``= delete``.
668-
- ``clang_Cursor_getNumTemplateArguments``, ``clang_Cursor_getTemplateArgumentKind``,
669-
``clang_Cursor_getTemplateArgumentType``, ``clang_Cursor_getTemplateArgumentValue`` and
723+
- Introduced the new function ``clang_CXXMethod_isCopyAssignmentOperator``,
724+
which identifies whether a method cursor is a copy-assignment
725+
operator.
726+
- ``clang_Cursor_getNumTemplateArguments``, ``clang_Cursor_getTemplateArgumentKind``,
727+
``clang_Cursor_getTemplateArgumentType``, ``clang_Cursor_getTemplateArgumentValue`` and
670728
``clang_Cursor_getTemplateArgumentUnsignedValue`` now work on struct, class,
671729
and partial template specialization cursors in addition to function cursors.
672730

clang/docs/UsersManual.rst

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ describes the various floating point semantic modes and the corresponding option
13711371
:header: "Mode", "Values"
13721372
:widths: 15, 30, 30
13731373

1374-
"ffp-exception-behavior", "{ignore, strict, may_trap}",
1374+
"ffp-exception-behavior", "{ignore, strict, maytrap}",
13751375
"fenv_access", "{off, on}", "(none)"
13761376
"frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
13771377
"ffp-contract", "{on, off, fast, fast-honor-pragmas}"
@@ -2841,11 +2841,17 @@ below. If multiple flags are present, the last one is used.
28412841
Clang supports a number of optimizations to reduce the size of debug
28422842
information in the binary. They work based on the assumption that
28432843
the debug type information can be spread out over multiple
2844-
compilation units. For instance, Clang will not emit type
2845-
definitions for types that are not needed by a module and could be
2846-
replaced with a forward declaration. Further, Clang will only emit
2847-
type info for a dynamic C++ class in the module that contains the
2848-
vtable for the class.
2844+
compilation units. Specifically, the optimizations are:
2845+
2846+
- will not emit type definitions for types that are not needed by a
2847+
module and could be replaced with a forward declaration.
2848+
- will only emit type info for a dynamic C++ class in the module that
2849+
contains the vtable for the class.
2850+
- will only emit type info for a C++ class (non-trivial, non-aggregate)
2851+
in the modules that contain a definition for one of its constructors.
2852+
- will only emit type definitions for types that are the subject of explicit
2853+
template instantiation declarations in the presence of an explicit
2854+
instantiation definition for the type.
28492855

28502856
The **-fstandalone-debug** option turns off these optimizations.
28512857
This is useful when working with 3rd-party libraries that don't come
@@ -2858,19 +2864,6 @@ below. If multiple flags are present, the last one is used.
28582864
**-fno-standalone-debug** option can be used to get to turn on the
28592865
vtable-based optimization described above.
28602866

2861-
.. option:: -fuse-ctor-homing
2862-
2863-
This optimization is similar to the optimizations that are enabled as part
2864-
of -fno-standalone-debug. Here, Clang only emits type info for a
2865-
non-trivial, non-aggregate C++ class in the modules that contain a
2866-
definition of one of its constructors. This relies on the additional
2867-
assumption that all classes that are not trivially constructible have a
2868-
non-trivial constructor that is used somewhere. The negation,
2869-
-fno-use-ctor-homing, ensures that constructor homing is not used.
2870-
2871-
This flag is not enabled by default, and needs to be used with -cc1 or
2872-
-Xclang.
2873-
28742867
.. option:: -g
28752868

28762869
Generate complete debug info.

clang/include/clang-c/Index.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,6 +4297,31 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
42974297
*/
42984298
CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
42994299

4300+
/**
4301+
* Determine if a C++ member function is a copy-assignment operator,
4302+
* returning 1 if such is the case and 0 otherwise.
4303+
*
4304+
* > A copy-assignment operator `X::operator=` is a non-static,
4305+
* > non-template member function of _class_ `X` with exactly one
4306+
* > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4307+
* > volatile X&`.
4308+
*
4309+
* That is, for example, the `operator=` in:
4310+
*
4311+
* class Foo {
4312+
* bool operator=(const volatile Foo&);
4313+
* };
4314+
*
4315+
* Is a copy-assignment operator, while the `operator=` in:
4316+
*
4317+
* class Bar {
4318+
* bool operator=(const int&);
4319+
* };
4320+
*
4321+
* Is not.
4322+
*/
4323+
CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
4324+
43004325
/**
43014326
* Determine if a C++ record is abstract, i.e. whether a class or struct
43024327
* has a pure virtual member function.

0 commit comments

Comments
 (0)