Skip to content

Commit 3a0701c

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:5e007afa9d4f into amd-gfx:4c17e1c71592
Local branch amd-gfx 4c17e1c Merged main:c00a708fc954 into amd-gfx:6f6131a974b2 Remote branch main 5e007af [AMDGPU] Handle hazard in v_scalef32_sr_fp4_* conversions (llvm#118589)
2 parents 4c17e1c + 5e007af commit 3a0701c

File tree

666 files changed

+9015
-2611
lines changed

Some content is hidden

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

666 files changed

+9015
-2611
lines changed

.ci/generate_test_report.py

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# python3 -m unittest discover -p generate_test_report.py
66

77
import argparse
8+
import os
89
import subprocess
910
import unittest
1011
from io import StringIO
@@ -267,6 +268,46 @@ def test_report_dont_list_failures(self):
267268
),
268269
)
269270

271+
def test_report_dont_list_failures_link_to_log(self):
272+
self.assertEqual(
273+
_generate_report(
274+
"Foo",
275+
[
276+
junit_from_xml(
277+
dedent(
278+
"""\
279+
<?xml version="1.0" encoding="UTF-8"?>
280+
<testsuites time="0.02">
281+
<testsuite name="Bar" tests="1" failures="1" skipped="0" time="0.02">
282+
<testcase classname="Bar/test_1" name="test_1" time="0.02">
283+
<failure><![CDATA[Output goes here]]></failure>
284+
</testcase>
285+
</testsuite>
286+
</testsuites>"""
287+
)
288+
)
289+
],
290+
list_failures=False,
291+
buildkite_info={
292+
"BUILDKITE_ORGANIZATION_SLUG": "organization_slug",
293+
"BUILDKITE_PIPELINE_SLUG": "pipeline_slug",
294+
"BUILDKITE_BUILD_NUMBER": "build_number",
295+
"BUILDKITE_JOB_ID": "job_id",
296+
},
297+
),
298+
(
299+
dedent(
300+
"""\
301+
# Foo
302+
303+
* 1 test failed
304+
305+
Failed tests and their output was too large to report. [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."""
306+
),
307+
"error",
308+
),
309+
)
310+
270311
def test_report_size_limit(self):
271312
self.assertEqual(
272313
_generate_report(
@@ -308,7 +349,13 @@ def test_report_size_limit(self):
308349
# listed. This minimal report will always fit into an annotation.
309350
# If include failures is False, total number of test will be reported but their names
310351
# and output will not be.
311-
def _generate_report(title, junit_objects, size_limit=1024 * 1024, list_failures=True):
352+
def _generate_report(
353+
title,
354+
junit_objects,
355+
size_limit=1024 * 1024,
356+
list_failures=True,
357+
buildkite_info=None,
358+
):
312359
if not junit_objects:
313360
return ("", "success")
314361

@@ -354,11 +401,21 @@ def plural(num_tests):
354401
report.append(f"* {tests_failed} {plural(tests_failed)} failed")
355402

356403
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"
413+
357414
report.extend(
358415
[
359416
"",
360417
"Failed tests and their output was too large to report. "
361-
"Download the build's log file to see the details.",
418+
f"{download_text} the build's log file to see the details.",
362419
]
363420
)
364421
elif failures:
@@ -381,13 +438,23 @@ def plural(num_tests):
381438

382439
report = "\n".join(report)
383440
if len(report.encode("utf-8")) > size_limit:
384-
return _generate_report(title, junit_objects, size_limit, list_failures=False)
441+
return _generate_report(
442+
title,
443+
junit_objects,
444+
size_limit,
445+
list_failures=False,
446+
buildkite_info=buildkite_info,
447+
)
385448

386449
return report, style
387450

388451

389-
def generate_report(title, junit_files):
390-
return _generate_report(title, [JUnitXml.fromfile(p) for p in junit_files])
452+
def generate_report(title, junit_files, buildkite_info):
453+
return _generate_report(
454+
title,
455+
[JUnitXml.fromfile(p) for p in junit_files],
456+
buildkite_info=buildkite_info,
457+
)
391458

392459

393460
if __name__ == "__main__":
@@ -399,7 +466,18 @@ def generate_report(title, junit_files):
399466
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
400467
args = parser.parse_args()
401468

402-
report, style = generate_report(args.title, args.junit_files)
469+
# All of these are required to build a link to download the log file.
470+
env_var_names = [
471+
"BUILDKITE_ORGANIZATION_SLUG",
472+
"BUILDKITE_PIPELINE_SLUG",
473+
"BUILDKITE_BUILD_NUMBER",
474+
"BUILDKITE_JOB_ID",
475+
]
476+
buildkite_info = {k: v for k, v in os.environ.items() if k in env_var_names}
477+
if len(buildkite_info) != len(env_var_names):
478+
buildkite_info = None
479+
480+
report, style = generate_report(args.title, args.junit_files, buildkite_info)
403481

404482
if report:
405483
p = subprocess.Popen(

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ BreakFunctionNames("break-funcs",
4646
cl::Hidden,
4747
cl::cat(BoltCategory));
4848

49-
static cl::list<std::string>
50-
FunctionPadSpec("pad-funcs",
51-
cl::CommaSeparated,
52-
cl::desc("list of functions to pad with amount of bytes"),
53-
cl::value_desc("func1:pad1,func2:pad2,func3:pad3,..."),
54-
cl::Hidden,
55-
cl::cat(BoltCategory));
49+
cl::list<std::string>
50+
FunctionPadSpec("pad-funcs", cl::CommaSeparated,
51+
cl::desc("list of functions to pad with amount of bytes"),
52+
cl::value_desc("func1:pad1,func2:pad2,func3:pad3,..."),
53+
cl::Hidden, cl::cat(BoltCategory));
54+
55+
cl::list<std::string> FunctionPadBeforeSpec(
56+
"pad-funcs-before", cl::CommaSeparated,
57+
cl::desc("list of functions to pad with amount of bytes"),
58+
cl::value_desc("func1:pad1,func2:pad2,func3:pad3,..."), cl::Hidden,
59+
cl::cat(BoltCategory));
5660

5761
static cl::opt<bool> MarkFuncs(
5862
"mark-funcs",
@@ -70,11 +74,12 @@ X86AlignBranchBoundaryHotOnly("x86-align-branch-boundary-hot-only",
7074
cl::init(true),
7175
cl::cat(BoltOptCategory));
7276

73-
size_t padFunction(const BinaryFunction &Function) {
77+
size_t padFunction(const cl::list<std::string> &Spec,
78+
const BinaryFunction &Function) {
7479
static std::map<std::string, size_t> FunctionPadding;
7580

76-
if (FunctionPadding.empty() && !FunctionPadSpec.empty()) {
77-
for (std::string &Spec : FunctionPadSpec) {
81+
if (FunctionPadding.empty() && !Spec.empty()) {
82+
for (const std::string &Spec : Spec) {
7883
size_t N = Spec.find(':');
7984
if (N == std::string::npos)
8085
continue;
@@ -319,6 +324,32 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
319324
Streamer.emitCodeAlignment(Function.getAlign(), &*BC.STI);
320325
}
321326

327+
if (size_t Padding =
328+
opts::padFunction(opts::FunctionPadBeforeSpec, Function)) {
329+
// Handle padFuncsBefore after the above alignment logic but before
330+
// symbol addresses are decided.
331+
if (!BC.HasRelocations) {
332+
BC.errs() << "BOLT-ERROR: -pad-before-funcs is not supported in "
333+
<< "non-relocation mode\n";
334+
exit(1);
335+
}
336+
337+
// Preserve Function.getMinAlign().
338+
if (!isAligned(Function.getMinAlign(), Padding)) {
339+
BC.errs() << "BOLT-ERROR: user-requested " << Padding
340+
<< " padding bytes before function " << Function
341+
<< " is not a multiple of the minimum function alignment ("
342+
<< Function.getMinAlign().value() << ").\n";
343+
exit(1);
344+
}
345+
346+
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: padding before function " << Function
347+
<< " with " << Padding << " bytes\n");
348+
349+
// Since the padding is not executed, it can be null bytes.
350+
Streamer.emitFill(Padding, 0);
351+
}
352+
322353
MCContext &Context = Streamer.getContext();
323354
const MCAsmInfo *MAI = Context.getAsmInfo();
324355

@@ -373,7 +404,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
373404
emitFunctionBody(Function, FF, /*EmitCodeOnly=*/false);
374405

375406
// Emit padding if requested.
376-
if (size_t Padding = opts::padFunction(Function)) {
407+
if (size_t Padding = opts::padFunction(opts::FunctionPadSpec, Function)) {
377408
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: padding function " << Function << " with "
378409
<< Padding << " bytes\n");
379410
Streamer.emitFill(Padding, MAI->getTextAlignFillValue());

bolt/lib/Passes/ReorderFunctions.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ extern cl::OptionCategory BoltOptCategory;
2828
extern cl::opt<unsigned> Verbosity;
2929
extern cl::opt<uint32_t> RandomSeed;
3030

31-
extern size_t padFunction(const bolt::BinaryFunction &Function);
31+
extern size_t padFunction(const cl::list<std::string> &Spec,
32+
const bolt::BinaryFunction &Function);
33+
extern cl::list<std::string> FunctionPadSpec, FunctionPadBeforeSpec;
3234

3335
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
3436
cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions(
@@ -304,8 +306,12 @@ Error ReorderFunctions::runOnFunctions(BinaryContext &BC) {
304306
return false;
305307
if (B->isIgnored())
306308
return true;
307-
const size_t PadA = opts::padFunction(*A);
308-
const size_t PadB = opts::padFunction(*B);
309+
const size_t PadA =
310+
opts::padFunction(opts::FunctionPadSpec, *A) +
311+
opts::padFunction(opts::FunctionPadBeforeSpec, *A);
312+
const size_t PadB =
313+
opts::padFunction(opts::FunctionPadSpec, *B) +
314+
opts::padFunction(opts::FunctionPadBeforeSpec, *B);
309315
if (!PadA || !PadB) {
310316
if (PadA)
311317
return true;

bolt/test/AArch64/pad-before-funcs.s

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Test checks that --pad-before-funcs is working as expected.
2+
# It should be able to introduce a configurable offset for the _start symbol.
3+
# It should reject requests which don't obey the code alignment requirement.
4+
5+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
6+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -Wl,--section-start=.text=0x4000
7+
# RUN: llvm-bolt %t.exe -o %t.bolt.0 --pad-funcs-before=_start:0
8+
# RUN: llvm-bolt %t.exe -o %t.bolt.4 --pad-funcs-before=_start:4
9+
# RUN: llvm-bolt %t.exe -o %t.bolt.8 --pad-funcs-before=_start:8
10+
11+
# RUN: not llvm-bolt %t.exe -o %t.bolt.8 --pad-funcs-before=_start:1 2>&1 | FileCheck --check-prefix=CHECK-BAD-ALIGN %s
12+
13+
# CHECK-BAD-ALIGN: user-requested 1 padding bytes before function _start(*2) is not a multiple of the minimum function alignment (4).
14+
15+
# RUN: llvm-objdump --section=.text --disassemble %t.bolt.0 | FileCheck --check-prefix=CHECK-0 %s
16+
# RUN: llvm-objdump --section=.text --disassemble %t.bolt.4 | FileCheck --check-prefix=CHECK-4 %s
17+
# RUN: llvm-objdump --section=.text --disassemble %t.bolt.8 | FileCheck --check-prefix=CHECK-8 %s
18+
19+
# Trigger relocation mode in bolt.
20+
.reloc 0, R_AARCH64_NONE
21+
22+
.section .text
23+
.globl _start
24+
25+
# CHECK-0: 0000000000400000 <_start>
26+
# CHECK-4: 0000000000400004 <_start>
27+
# CHECK-8: 0000000000400008 <_start>
28+
_start:
29+
ret

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_clang_library(clangTidyBugproneModule STATIC
1616
ChainedComparisonCheck.cpp
1717
ComparePointerToMemberVirtualFunctionCheck.cpp
1818
CopyConstructorInitCheck.cpp
19+
CrtpConstructorAccessibilityCheck.cpp
1920
DanglingHandleCheck.cpp
2021
DynamicStaticInitializersCheck.cpp
2122
EasilySwappableParametersCheck.cpp
@@ -26,11 +27,8 @@ add_clang_library(clangTidyBugproneModule STATIC
2627
ForwardingReferenceOverloadCheck.cpp
2728
ImplicitWideningOfMultiplicationResultCheck.cpp
2829
InaccurateEraseCheck.cpp
29-
IncorrectEnableIfCheck.cpp
30-
ReturnConstRefFromParameterCheck.cpp
31-
SuspiciousStringviewDataUsageCheck.cpp
32-
SwitchMissingDefaultCaseCheck.cpp
3330
IncDecInConditionsCheck.cpp
31+
IncorrectEnableIfCheck.cpp
3432
IncorrectRoundingsCheck.cpp
3533
InfiniteLoopCheck.cpp
3634
IntegerDivisionCheck.cpp
@@ -45,15 +43,16 @@ add_clang_library(clangTidyBugproneModule STATIC
4543
MultipleNewInOneExpressionCheck.cpp
4644
MultipleStatementMacroCheck.cpp
4745
NoEscapeCheck.cpp
48-
NondeterministicPointerIterationOrderCheck.cpp
4946
NonZeroEnumToBoolConversionCheck.cpp
47+
NondeterministicPointerIterationOrderCheck.cpp
5048
NotNullTerminatedResultCheck.cpp
5149
OptionalValueConversionCheck.cpp
5250
ParentVirtualCallCheck.cpp
5351
PointerArithmeticOnPolymorphicObjectCheck.cpp
5452
PosixReturnCheck.cpp
5553
RedundantBranchConditionCheck.cpp
5654
ReservedIdentifierCheck.cpp
55+
ReturnConstRefFromParameterCheck.cpp
5756
SharedPtrArrayMismatchCheck.cpp
5857
SignalHandlerCheck.cpp
5958
SignedCharMisuseCheck.cpp
@@ -74,7 +73,9 @@ add_clang_library(clangTidyBugproneModule STATIC
7473
SuspiciousReallocUsageCheck.cpp
7574
SuspiciousSemicolonCheck.cpp
7675
SuspiciousStringCompareCheck.cpp
76+
SuspiciousStringviewDataUsageCheck.cpp
7777
SwappedArgumentsCheck.cpp
78+
SwitchMissingDefaultCaseCheck.cpp
7879
TaggedUnionMemberCountCheck.cpp
7980
TerminatingContinueCheck.cpp
8081
ThrowKeywordMissingCheck.cpp
@@ -85,7 +86,6 @@ add_clang_library(clangTidyBugproneModule STATIC
8586
UnhandledExceptionAtNewCheck.cpp
8687
UnhandledSelfAssignmentCheck.cpp
8788
UniquePtrArrayMismatchCheck.cpp
88-
CrtpConstructorAccessibilityCheck.cpp
8989
UnsafeFunctionsCheck.cpp
9090
UnusedLocalNonTrivialVariableCheck.cpp
9191
UnusedRaiiCheck.cpp

0 commit comments

Comments
 (0)