Skip to content

Commit 5b362a0

Browse files
authored
Merge pull request llvm#72 from AMD-Lightning-Internal/amd/merge/011325-2-mergeMain2AS
Amd/merge/011325 2 merge main2 as
2 parents ab48bdc + 887f991 commit 5b362a0

File tree

404 files changed

+19608
-6294
lines changed

Some content is hidden

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

404 files changed

+19608
-6294
lines changed

.ci/generate_test_report.py

+88-14
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ def junit_from_xml(xml):
1919

2020
class TestReports(unittest.TestCase):
2121
def test_title_only(self):
22-
self.assertEqual(_generate_report("Foo", []), ("", "success"))
22+
self.assertEqual(_generate_report("Foo", 0, []), ("", "success"))
2323

2424
def test_no_tests_in_testsuite(self):
2525
self.assertEqual(
2626
_generate_report(
2727
"Foo",
28+
1,
2829
[
2930
junit_from_xml(
3031
dedent(
@@ -45,6 +46,7 @@ def test_no_failures(self):
4546
self.assertEqual(
4647
_generate_report(
4748
"Foo",
49+
0,
4850
[
4951
junit_from_xml(
5052
dedent(
@@ -70,10 +72,51 @@ def test_no_failures(self):
7072
),
7173
)
7274

75+
def test_no_failures_build_failed(self):
76+
self.assertEqual(
77+
_generate_report(
78+
"Foo",
79+
1,
80+
[
81+
junit_from_xml(
82+
dedent(
83+
"""\
84+
<?xml version="1.0" encoding="UTF-8"?>
85+
<testsuites time="0.00">
86+
<testsuite name="Passed" tests="1" failures="0" skipped="0" time="0.00">
87+
<testcase classname="Bar/test_1" name="test_1" time="0.00"/>
88+
</testsuite>
89+
</testsuites>"""
90+
)
91+
)
92+
],
93+
buildkite_info={
94+
"BUILDKITE_ORGANIZATION_SLUG": "organization_slug",
95+
"BUILDKITE_PIPELINE_SLUG": "pipeline_slug",
96+
"BUILDKITE_BUILD_NUMBER": "build_number",
97+
"BUILDKITE_JOB_ID": "job_id",
98+
},
99+
),
100+
(
101+
dedent(
102+
"""\
103+
# Foo
104+
105+
* 1 test passed
106+
107+
All tests passed but another part of the build **failed**.
108+
109+
[Download](https://buildkite.com/organizations/organization_slug/pipelines/pipeline_slug/builds/build_number/jobs/job_id/download.txt) the build's log file to see the details."""
110+
),
111+
"error",
112+
),
113+
)
114+
73115
def test_report_single_file_single_testsuite(self):
74116
self.assertEqual(
75117
_generate_report(
76118
"Foo",
119+
1,
77120
[
78121
junit_from_xml(
79122
dedent(
@@ -166,6 +209,7 @@ def test_report_single_file_multiple_testsuites(self):
166209
self.assertEqual(
167210
_generate_report(
168211
"ABC and DEF",
212+
1,
169213
[
170214
junit_from_xml(
171215
dedent(
@@ -198,6 +242,7 @@ def test_report_multiple_files_multiple_testsuites(self):
198242
self.assertEqual(
199243
_generate_report(
200244
"ABC and DEF",
245+
1,
201246
[
202247
junit_from_xml(
203248
dedent(
@@ -238,6 +283,7 @@ def test_report_dont_list_failures(self):
238283
self.assertEqual(
239284
_generate_report(
240285
"Foo",
286+
1,
241287
[
242288
junit_from_xml(
243289
dedent(
@@ -272,6 +318,7 @@ def test_report_dont_list_failures_link_to_log(self):
272318
self.assertEqual(
273319
_generate_report(
274320
"Foo",
321+
1,
275322
[
276323
junit_from_xml(
277324
dedent(
@@ -312,6 +359,7 @@ def test_report_size_limit(self):
312359
self.assertEqual(
313360
_generate_report(
314361
"Foo",
362+
1,
315363
[
316364
junit_from_xml(
317365
dedent(
@@ -351,12 +399,18 @@ def test_report_size_limit(self):
351399
# and output will not be.
352400
def _generate_report(
353401
title,
402+
return_code,
354403
junit_objects,
355404
size_limit=1024 * 1024,
356405
list_failures=True,
357406
buildkite_info=None,
358407
):
359408
if not junit_objects:
409+
# Note that we do not post an empty report, therefore we can ignore a
410+
# non-zero return code in situations like this.
411+
#
412+
# If we were going to post a report, then yes, it would be misleading
413+
# to say we succeeded when the final return code was non-zero.
360414
return ("", "success")
361415

362416
failures = {}
@@ -385,7 +439,11 @@ def _generate_report(
385439
if not tests_run:
386440
return ("", None)
387441

388-
style = "error" if tests_failed else "success"
442+
style = "success"
443+
# Either tests failed, or all tests passed but something failed to build.
444+
if tests_failed or return_code != 0:
445+
style = "error"
446+
389447
report = [f"# {title}", ""]
390448

391449
tests_passed = tests_run - tests_skipped - tests_failed
@@ -400,17 +458,17 @@ def plural(num_tests):
400458
if tests_failed:
401459
report.append(f"* {tests_failed} {plural(tests_failed)} failed")
402460

403-
if not list_failures:
404-
if buildkite_info is not None:
405-
log_url = (
406-
"https://buildkite.com/organizations/{BUILDKITE_ORGANIZATION_SLUG}/"
407-
"pipelines/{BUILDKITE_PIPELINE_SLUG}/builds/{BUILDKITE_BUILD_NUMBER}/"
408-
"jobs/{BUILDKITE_JOB_ID}/download.txt".format(**buildkite_info)
409-
)
410-
download_text = f"[Download]({log_url})"
411-
else:
412-
download_text = "Download"
461+
if buildkite_info is not None:
462+
log_url = (
463+
"https://buildkite.com/organizations/{BUILDKITE_ORGANIZATION_SLUG}/"
464+
"pipelines/{BUILDKITE_PIPELINE_SLUG}/builds/{BUILDKITE_BUILD_NUMBER}/"
465+
"jobs/{BUILDKITE_JOB_ID}/download.txt".format(**buildkite_info)
466+
)
467+
download_text = f"[Download]({log_url})"
468+
else:
469+
download_text = "Download"
413470

471+
if not list_failures:
414472
report.extend(
415473
[
416474
"",
@@ -435,11 +493,23 @@ def plural(num_tests):
435493
"</details>",
436494
]
437495
)
496+
elif return_code != 0:
497+
# No tests failed but the build was in a failed state. Bring this to the user's
498+
# attention.
499+
report.extend(
500+
[
501+
"",
502+
"All tests passed but another part of the build **failed**.",
503+
"",
504+
f"{download_text} the build's log file to see the details.",
505+
]
506+
)
438507

439508
report = "\n".join(report)
440509
if len(report.encode("utf-8")) > size_limit:
441510
return _generate_report(
442511
title,
512+
return_code,
443513
junit_objects,
444514
size_limit,
445515
list_failures=False,
@@ -449,9 +519,10 @@ def plural(num_tests):
449519
return report, style
450520

451521

452-
def generate_report(title, junit_files, buildkite_info):
522+
def generate_report(title, return_code, junit_files, buildkite_info):
453523
return _generate_report(
454524
title,
525+
return_code,
455526
[JUnitXml.fromfile(p) for p in junit_files],
456527
buildkite_info=buildkite_info,
457528
)
@@ -463,6 +534,7 @@ def generate_report(title, junit_files, buildkite_info):
463534
"title", help="Title of the test report, without Markdown formatting."
464535
)
465536
parser.add_argument("context", help="Annotation context to write to.")
537+
parser.add_argument("return_code", help="The build's return code.", type=int)
466538
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
467539
args = parser.parse_args()
468540

@@ -477,7 +549,9 @@ def generate_report(title, junit_files, buildkite_info):
477549
if len(buildkite_info) != len(env_var_names):
478550
buildkite_info = None
479551

480-
report, style = generate_report(args.title, args.junit_files, buildkite_info)
552+
report, style = generate_report(
553+
args.title, args.return_code, args.junit_files, buildkite_info
554+
)
481555

482556
if report:
483557
p = subprocess.Popen(

.ci/monolithic-linux.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ if [[ -n "${CLEAR_CACHE:-}" ]]; then
2929
fi
3030

3131
function at-exit {
32+
retcode=$?
33+
3234
mkdir -p artifacts
3335
ccache --print-stats > artifacts/ccache_stats.txt
3436

@@ -37,7 +39,7 @@ function at-exit {
3739
if command -v buildkite-agent 2>&1 >/dev/null
3840
then
3941
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report.py ":linux: Linux x64 Test Results" \
40-
"linux-x64-test-results" "${BUILD_DIR}"/test-results.*.xml
42+
"linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
4143
fi
4244
}
4345
trap at-exit EXIT

.ci/monolithic-windows.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ fi
2828

2929
sccache --zero-stats
3030
function at-exit {
31+
retcode=$?
32+
3133
mkdir -p artifacts
3234
sccache --show-stats >> artifacts/sccache_stats.txt
3335

@@ -36,7 +38,7 @@ function at-exit {
3638
if command -v buildkite-agent 2>&1 >/dev/null
3739
then
3840
python "${MONOREPO_ROOT}"/.ci/generate_test_report.py ":windows: Windows x64 Test Results" \
39-
"windows-x64-test-results" "${BUILD_DIR}"/test-results.*.xml
41+
"windows-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
4042
fi
4143
}
4244
trap at-exit EXIT

clang/docs/LanguageExtensions.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -2137,8 +2137,8 @@ method; it specifies that the method expects its ``self`` parameter to have a
21372137
- (void) bar __attribute__((ns_consumes_self));
21382138
- (void) baz:(id) __attribute__((ns_consumed)) x;
21392139
2140-
Further examples of these attributes are available in the static analyzer's `list of annotations for analysis
2141-
<https://clang-analyzer.llvm.org/annotations.html#cocoa_mem>`_.
2140+
Further examples of these attributes are available in the static analyzer's
2141+
`list of annotations for analysis <analyzer/user-docs/Annotations.html#cocoa-mem>`__.
21422142
21432143
Query for these features with ``__has_attribute(ns_consumed)``,
21442144
``__has_attribute(ns_returns_retained)``, etc.
@@ -4792,8 +4792,8 @@ Extensions for Static Analysis
47924792
Clang supports additional attributes that are useful for documenting program
47934793
invariants and rules for static analysis tools, such as the `Clang Static
47944794
Analyzer <https://clang-analyzer.llvm.org/>`_. These attributes are documented
4795-
in the analyzer's `list of source-level annotations
4796-
<https://clang-analyzer.llvm.org/annotations.html>`_.
4795+
in the analyzer's `list of annotations for analysis
4796+
<analyzer/user-docs/Annotations.html>`__.
47974797
47984798
47994799
Extensions for Dynamic Analysis

clang/docs/Modules.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ first include path that would refer to the current file. ``#include_next`` is
152152
interpreted as if the current file had been found in that path.
153153
If this search finds a file named by a module map, the ``#include_next``
154154
directive is translated into an import, just like for a ``#include``
155-
directive.``
155+
directive.
156156

157157
Module maps
158158
-----------

clang/docs/OpenMPSupport.rst

+2
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ implementation.
286286
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
287287
| memory management | 'allocator' modifier for allocate clause | :good:`done` | https://github.com/llvm/llvm-project/pull/114883 |
288288
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
289+
| memory management | 'align' modifier for allocate clause | :good:`done` | https://github.com/llvm/llvm-project/pull/121814 |
290+
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
289291
| memory management | new memory management routines | :none:`unclaimed` | |
290292
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
291293
| memory management | changes to omp_alloctrait_key enum | :none:`unclaimed` | |

clang/docs/ReleaseNotes.rst

+24
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ code bases.
5858
containing strict-aliasing violations. The new default behavior can be
5959
disabled using ``-fno-pointer-tbaa``.
6060

61+
- Clang will now more aggressively use undefined behavior on pointer addition
62+
overflow for optimization purposes. For example, a check like
63+
``ptr + unsigned_offset < ptr`` will now optimize to ``false``, because
64+
``ptr + unsigned_offset`` will cause undefined behavior if it overflows (or
65+
advances past the end of the object).
66+
67+
Previously, ``ptr + unsigned_offset < ptr`` was optimized (by both Clang and
68+
GCC) to ``(ssize_t)unsigned_offset < 0``. This also results in an incorrect
69+
overflow check, but in a way that is less apparent when only testing with
70+
pointers in the low half of the address space.
71+
72+
To avoid pointer addition overflow, it is necessary to perform the addition
73+
on integers, for example using
74+
``(uintptr_t)ptr + unsigned_offset < (uintptr_t)ptr``. Sometimes, it is also
75+
possible to rewrite checks by only comparing the offset. For example,
76+
``ptr + offset < end_ptr && ptr + offset >= ptr`` can be written as
77+
``offset < (uintptr_t)(end_ptr - ptr)``.
78+
79+
Undefined behavior due to pointer addition overflow can be reliably detected
80+
using ``-fsanitize=pointer-overflow``. It is also possible to use
81+
``-fno-strict-overflow`` to opt-in to a language dialect where signed integer
82+
and pointer overflow are well-defined.
83+
6184
C/C++ Language Potentially Breaking Changes
6285
-------------------------------------------
6386

@@ -1381,6 +1404,7 @@ OpenMP Support
13811404
always build support for AMDGPU and NVPTX targets.
13821405
- Added support for combined masked constructs 'omp parallel masked taskloop',
13831406
'omp parallel masked taskloop simd','omp masked taskloop' and 'omp masked taskloop simd' directive.
1407+
- Added support for align-modifier in 'allocate' clause.
13841408

13851409
Improvements
13861410
^^^^^^^^^^^^

clang/docs/UsersManual.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -1364,10 +1364,8 @@ Controlling Static Analyzer Diagnostics
13641364
While not strictly part of the compiler, the diagnostics from Clang's
13651365
`static analyzer <https://clang-analyzer.llvm.org>`_ can also be
13661366
influenced by the user via changes to the source code. See the available
1367-
`annotations <https://clang-analyzer.llvm.org/annotations.html>`_ and the
1368-
analyzer's `FAQ
1369-
page <https://clang-analyzer.llvm.org/faq.html#exclude_code>`_ for more
1370-
information.
1367+
`annotations <analyzer/user-docs/Annotations.html>`_ and the analyzer's
1368+
`FAQ page <analyzer/user-docs/FAQ.html#exclude-code>`_ for more information.
13711369

13721370
.. _usersmanual-precompiled-headers:
13731371

clang/docs/analyzer/user-docs.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ Contents:
1212
user-docs/FilingBugs
1313
user-docs/CrossTranslationUnit
1414
user-docs/TaintAnalysisConfiguration
15+
user-docs/Annotations
1516
user-docs/FAQ

0 commit comments

Comments
 (0)