Skip to content

Commit f6c13fb

Browse files
committed
Merge branch 'main' of github.com:llvm/llvm-project into loop-vectorize/optimizeMaskToEVL-pattern-matching
2 parents 71e24f0 + 74275a1 commit f6c13fb

File tree

916 files changed

+29524
-10699
lines changed

Some content is hidden

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

916 files changed

+29524
-10699
lines changed

bolt/test/link_fdata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# Regexes to extract FDATA lines from input and parse FDATA and pre-aggregated
3434
# profile data
35-
prefix_pat = re.compile(f"^# {args.prefix}: (.*)")
35+
prefix_pat = re.compile(f"^(#|//) {args.prefix}: (.*)")
3636

3737
# FDATA records:
3838
# <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
@@ -61,7 +61,7 @@
6161
prefix_match = prefix_pat.match(line)
6262
if not prefix_match:
6363
continue
64-
profile_line = prefix_match.group(1)
64+
profile_line = prefix_match.group(2)
6565
fdata_match = fdata_pat.match(profile_line)
6666
preagg_match = preagg_pat.match(profile_line)
6767
nolbr_match = nolbr_pat.match(profile_line)

bolt/test/runtime/copy_file.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
import shutil
3+
4+
with open(sys.argv[1] + ".output") as log_file:
5+
lines = log_file.readlines()
6+
for line in lines:
7+
if line.startswith(sys.argv[2]):
8+
pid = line.split(" ")[1].strip()
9+
shutil.copy(
10+
sys.argv[1] + "." + pid + ".fdata",
11+
sys.argv[1] + "." + sys.argv[3] + ".fdata",
12+
)
13+
sys.exit(0)
14+
15+
sys.exit(1)

bolt/test/runtime/instrumentation-indirect-2.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main() {
5050
return 0;
5151
}
5252
/*
53-
REQUIRES: system-linux,shell,fuser
53+
REQUIRES: system-linux,fuser
5454
5555
RUN: %clang %cflags %s -o %t.exe -Wl,-q -pie -fpie
5656
@@ -61,10 +61,14 @@ RUN: --instrumentation-wait-forks
6161
6262
# Instrumented program needs to finish returning zero
6363
# Both output and profile must contain all 16 functions
64-
RUN: %t.instrumented_conservative > %t.output
65-
# Wait for profile and output to be fully written
66-
RUN: bash %S/wait_file.sh %t.output
67-
RUN: bash %S/wait_file.sh %t.fdata
64+
# We need to use bash to invoke this as otherwise we hang inside a
65+
# popen.communicate call in lit's internal shell. Eventually we should not
66+
# need this.
67+
# TODO(boomanaiden154): Remove once
68+
# https://github.com/llvm/llvm-project/issues/156484 is fixed.
69+
RUN: bash -c "%t.instrumented_conservative; wait" > %t.output
70+
# We can just read because we ensure the profile will be fully written by
71+
# calling wait inside the bash invocation.
6872
RUN: cat %t.output | FileCheck %s --check-prefix=CHECK-OUTPUT
6973
RUN: cat %t.fdata | FileCheck %s --check-prefix=CHECK-COMMON-PROF
7074
@@ -112,14 +116,8 @@ RUN: bash %S/wait_file.sh %t.output
112116
# Make sure all functions were called
113117
RUN: cat %t.output | FileCheck %s --check-prefix=CHECK-OUTPUT
114118
115-
RUN: child_pid=$(cat %t.output | grep funcA | awk '{print $2;}')
116-
RUN: par_pid=$(cat %t.output | grep funcB | awk '{print $2;}')
117-
118-
RUN: bash %S/wait_file.sh %t.$child_pid.fdata
119-
RUN: bash %S/wait_file.sh %t.$par_pid.fdata
120-
121-
RUN: mv %t.$child_pid.fdata %t.child.fdata
122-
RUN: mv %t.$par_pid.fdata %t.parent.fdata
119+
RUN: %python %S/copy_file.py %t funcA child
120+
RUN: %python %S/copy_file.py %t funcB parent
123121
124122
# Instrumented binary must produce two profiles with only local calls
125123
# recorded. Functions called only in child should not appear in parent's

bolt/test/timers.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
/* This test checks timers for metadata manager phases.
2-
# RUN: %clang %cflags %s -o %t.exe
3-
# RUN: link_fdata %s %t.exe %t.fdata
4-
# RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5-
# RUN: 2>&1 | FileCheck %s
6-
# RUN: link_fdata %s %t.exe %t.preagg PREAGG
7-
# RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8-
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
1+
// This test checks timers for metadata manager phases.
2+
// RUN: %clang %cflags %s -o %t.exe
3+
// RUN: link_fdata %s %t.exe %t.fdata
4+
// RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5+
// RUN: 2>&1 | FileCheck %s
6+
// RUN: link_fdata %s %t.exe %t.preagg PREAGG
7+
// RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
99

10-
# CHECK-DAG: update metadata post-emit
11-
# CHECK-DAG: process section metadata
12-
# CHECK-DAG: process metadata pre-CFG
13-
# CHECK-DAG: process metadata post-CFG
14-
# CHECK-DAG: finalize metadata pre-emit
10+
// CHECK-DAG: update metadata post-emit
11+
// CHECK-DAG: process section metadata
12+
// CHECK-DAG: process metadata pre-CFG
13+
// CHECK-DAG: process metadata post-CFG
14+
// CHECK-DAG: finalize metadata pre-emit
1515

16-
# CHECK-P2B-DAG: process section metadata
17-
# CHECK-P2B-DAG: process metadata pre-CFG
16+
// CHECK-P2B-DAG: process section metadata
17+
// CHECK-P2B-DAG: process metadata pre-CFG
1818

19-
# FDATA: 0 [unknown] 0 1 main 0 1 0
20-
# PREAGG: B X:0 #main# 1 0
21-
*/
19+
// FDATA: 0 [unknown] 0 1 main 0 1 0
20+
// PREAGG: B X:0 #main# 1 0
2221
int main() { return 0; }

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,11 +1106,11 @@ class FindControlFlow : public RecursiveASTVisitor<FindControlFlow> {
11061106
return true;
11071107
}
11081108
bool VisitBreakStmt(BreakStmt *B) {
1109-
found(Break, B->getBreakLoc());
1109+
found(Break, B->getKwLoc());
11101110
return true;
11111111
}
11121112
bool VisitContinueStmt(ContinueStmt *C) {
1113-
found(Continue, C->getContinueLoc());
1113+
found(Continue, C->getKwLoc());
11141114
return true;
11151115
}
11161116
bool VisitSwitchCase(SwitchCase *C) {

clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ void nullable_value_after_swap(BloombergLP::bdlb::NullableValue<int> &opt1, Bloo
141141
}
142142
}
143143

144+
void assertion_handler() __attribute__((analyzer_noreturn));
145+
146+
void function_calling_analyzer_noreturn(const bsl::optional<int>& opt)
147+
{
148+
if (!opt) {
149+
assertion_handler();
150+
}
151+
152+
*opt; // no-warning: The previous condition guards this dereference.
153+
}
154+
144155
template <typename T>
145156
void function_template_without_user(const absl::optional<T> &opt) {
146157
opt.value(); // no-warning

clang/docs/LanguageExtensions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,9 @@ The following type trait primitives are supported by Clang. Those traits marked
20492049
Returns true if a reference ``T`` can be copy-initialized from a temporary of type
20502050
a non-cv-qualified ``U``.
20512051
* ``__underlying_type`` (C++, GNU, Microsoft)
2052+
* ``__builtin_lt_synthesises_from_spaceship``, ``__builtin_gt_synthesises_from_spaceship``,
2053+
``__builtin_le_synthesises_from_spaceship``, ``__builtin_ge_synthesises_from_spaceship`` (Clang):
2054+
These builtins can be used to determine whether the corresponding operator is synthesised from a spaceship operator.
20522055

20532056
In addition, the following expression traits are supported:
20542057

clang/docs/ReleaseNotes.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ What's New in Clang |release|?
109109
C++ Language Changes
110110
--------------------
111111

112+
- A new family of builtins ``__builtin_*_synthesises_from_spaceship`` has been added. These can be queried to know
113+
whether the ``<`` (``lt``), ``>`` (``gt``), ``<=`` (``le``), or ``>=`` (``ge``) operators are synthesised from a
114+
``<=>``. This makes it possible to optimize certain facilities by using the ``<=>`` operation directly instead of
115+
doing multiple comparisons.
116+
112117
C++2c Feature Support
113118
^^^^^^^^^^^^^^^^^^^^^
114119

@@ -129,6 +134,7 @@ C Language Changes
129134

130135
C2y Feature Support
131136
^^^^^^^^^^^^^^^^^^^
137+
- Clang now supports `N3355 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm>`_ Named Loops.
132138

133139
C23 Feature Support
134140
^^^^^^^^^^^^^^^^^^^
@@ -241,11 +247,13 @@ Improvements to Clang's diagnostics
241247
"format specifies type 'unsigned int' but the argument has type 'int', which differs in signedness [-Wformat-signedness]"
242248
"signedness of format specifier 'u' is incompatible with 'c' [-Wformat-signedness]"
243249
and the API-visible diagnostic id will be appropriate.
244-
250+
245251
- Fixed false positives in ``-Waddress-of-packed-member`` diagnostics when
246252
potential misaligned members get processed before they can get discarded.
247253
(#GH144729)
248254

255+
- Clang now emits dignostic with correct message in case of assigning to const reference captured in lambda. (#GH105647)
256+
249257
- Fixed false positive in ``-Wmissing-noreturn`` diagnostic when it was requiring the usage of
250258
``[[noreturn]]`` on lambdas before C++23 (#GH154493).
251259

@@ -263,6 +271,10 @@ Improvements to Clang's diagnostics
263271
decorated with the ``alloc_size`` attribute don't allocate enough space for
264272
the target pointer type.
265273

274+
- The :doc:`ThreadSafetyAnalysis` attributes ``ACQUIRED_BEFORE(...)`` and
275+
``ACQUIRED_AFTER(...)`` have been moved to the stable feature set and no
276+
longer require ``-Wthread-safety-beta`` to be used.
277+
266278
Improvements to Clang's time-trace
267279
----------------------------------
268280

@@ -273,7 +285,7 @@ Bug Fixes in This Version
273285
-------------------------
274286
- Fix a crash when marco name is empty in ``#pragma push_macro("")`` or
275287
``#pragma pop_macro("")``. (#GH149762).
276-
- Fix a crash in variable length array (e.g. ``int a[*]``) function parameter type
288+
- Fix a crash in variable length array (e.g. ``int a[*]``) function parameter type
277289
being used in ``_Countof`` expression. (#GH152826).
278290
- ``-Wunreachable-code`` now diagnoses tautological or contradictory
279291
comparisons such as ``x != 0 || x != 1.0`` and ``x == 0 && x == 1.0`` on
@@ -358,7 +370,7 @@ X86 Support
358370
arithmetic can now be used in C++ constant expressions.
359371
- Some SSE, AVX and AVX512 intrinsics have been converted to wrap
360372
generic __builtin intrinsics.
361-
- NOTE: Please avoid use of the __builtin_ia32_* intrinsics - these are not
373+
- NOTE: Please avoid use of the __builtin_ia32_* intrinsics - these are not
362374
guaranteed to exist in future releases, or match behaviour with previous
363375
releases of clang or other compilers.
364376

clang/include/clang/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,10 @@ class FunctionDecl : public DeclaratorDecl,
26682668
/// an attribute on its declaration or its type.
26692669
bool isNoReturn() const;
26702670

2671+
/// Determines whether this function is known to be 'noreturn' for analyzer,
2672+
/// through an `analyzer_noreturn` attribute on its declaration.
2673+
bool isAnalyzerNoReturn() const;
2674+
26712675
/// True if the function was a definition but its body was skipped.
26722676
bool hasSkippedBody() const { return FunctionDeclBits.HasSkippedBody; }
26732677
void setHasSkippedBody(bool Skipped = true) {

clang/include/clang/AST/JSONNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class JSONNodeDumper
333333
void VisitStringLiteral(const StringLiteral *SL);
334334
void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *BLE);
335335

336+
void VisitLoopControlStmt(const LoopControlStmt *LS);
336337
void VisitIfStmt(const IfStmt *IS);
337338
void VisitSwitchStmt(const SwitchStmt *SS);
338339
void VisitCaseStmt(const CaseStmt *CS);

0 commit comments

Comments
 (0)