Skip to content

Commit b56549d

Browse files
committed
rebase
Created using spr 1.3.7
2 parents 9a40b79 + dea330b commit b56549d

File tree

727 files changed

+27917
-12046
lines changed

Some content is hidden

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

727 files changed

+27917
-12046
lines changed

.ci/premerge_advisor_explain.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ def main(
7979
pr_number: The number of the PR associated with this run.
8080
return_code: The numerical return code of ninja/CMake.
8181
"""
82-
if return_code == 0:
83-
with open("comment", "w") as comment_file_handle:
84-
comment = get_comment(
85-
github_token,
86-
pr_number,
87-
":white_check_mark: With the latest revision this PR passed "
88-
"the premerge checks.",
89-
)
90-
if "id" in comment:
91-
json.dump([comment], comment_file_handle)
9282
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
9383
build_log_files
9484
)
@@ -105,34 +95,42 @@ def main(
10595
explanation_request["failures"].append(
10696
{"name": name, "message": failure_messsage}
10797
)
108-
else:
98+
elif return_code != 0:
10999
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
110100
for name, failure_message in ninja_failures:
111101
explanation_request["failures"].append(
112102
{"name": name, "message": failure_message}
113103
)
114-
advisor_response = requests.get(
115-
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
104+
comments = []
105+
advisor_explanations = []
106+
if return_code != 0:
107+
advisor_response = requests.get(
108+
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
109+
)
110+
if advisor_response.status_code == 200:
111+
print(advisor_response.json())
112+
advisor_explanations = advisor_response.json()
113+
else:
114+
print(advisor_response.reason)
115+
comments.append(
116+
get_comment(
117+
github_token,
118+
pr_number,
119+
generate_test_report_lib.generate_report(
120+
generate_test_report_lib.compute_platform_title(),
121+
return_code,
122+
junit_objects,
123+
ninja_logs,
124+
failure_explanations_list=advisor_explanations,
125+
),
126+
)
116127
)
117-
if advisor_response.status_code == 200:
118-
print(advisor_response.json())
119-
comments = [
120-
get_comment(
121-
github_token,
122-
pr_number,
123-
generate_test_report_lib.generate_report(
124-
generate_test_report_lib.compute_platform_title(),
125-
return_code,
126-
junit_objects,
127-
ninja_logs,
128-
failure_explanations_list=advisor_response.json(),
129-
),
130-
)
131-
]
132-
with open("comments", "w") as comment_file_handle:
133-
json.dump(comments, comment_file_handle)
134-
else:
135-
print(advisor_response.reason)
128+
if return_code == 0 and "id" not in comments[0]:
129+
# If the job succeeds and there is not an existing comment, we
130+
# should not write one to reduce noise.
131+
comments = []
132+
with open("comments", "w") as comment_file_handle:
133+
json.dump(comments, comment_file_handle)
136134

137135

138136
if __name__ == "__main__":

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,12 @@ class MCPlusBuilder {
632632
return false;
633633
}
634634

635+
/// Generate the matching pointer authentication instruction from a fused
636+
/// pauth-and-return instruction.
637+
virtual void createMatchingAuth(const MCInst &AuthAndRet, MCInst &Auth) {
638+
llvm_unreachable("not implemented");
639+
}
640+
635641
/// Returns the register used as a return address. Returns std::nullopt if
636642
/// not applicable, such as reading the return address from a system register
637643
/// or from the stack.

bolt/lib/Passes/Inliner.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ InliningInfo getInliningInfo(const BinaryFunction &BF) {
195195
if (BC.MIB->isPush(Inst) || BC.MIB->isPop(Inst))
196196
continue;
197197

198+
// Pointer signing and authenticatin instructions are used around
199+
// Push and Pop. These are also straightforward to handle.
200+
if (BC.isAArch64() &&
201+
(BC.MIB->isPSignOnLR(Inst) || BC.MIB->isPAuthOnLR(Inst) ||
202+
BC.MIB->isPAuthAndRet(Inst)))
203+
continue;
204+
198205
DirectSP |= BC.MIB->hasDefOfPhysReg(Inst, SPReg) ||
199206
BC.MIB->hasUseOfPhysReg(Inst, SPReg);
200207
}
@@ -338,6 +345,18 @@ Inliner::inlineCall(BinaryBasicBlock &CallerBB,
338345
BC.Ctx.get());
339346
}
340347

348+
// Handling fused authentication and return instructions (Armv8.3-A):
349+
// if the Callee does not end in a tailcall, the return will be removed
350+
// from the inlined block. If that return is RETA(A|B), we have to keep
351+
// the authentication part.
352+
// RETAA -> AUTIASP
353+
// RETAB -> AUTIBSP
354+
if (!CSIsTailCall && BC.isAArch64() && BC.MIB->isPAuthAndRet(Inst)) {
355+
MCInst Auth;
356+
BC.MIB->createMatchingAuth(Inst, Auth);
357+
InsertII =
358+
std::next(InlinedBB->insertInstruction(InsertII, std::move(Auth)));
359+
}
341360
if (CSIsTailCall || (!MIB.isCall(Inst) && !MIB.isReturn(Inst))) {
342361
InsertII =
343362
std::next(InlinedBB->insertInstruction(InsertII, std::move(Inst)));

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,33 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
313313
Inst.getOpcode() == AArch64::RETABSPPCr;
314314
}
315315

316+
void createMatchingAuth(const MCInst &AuthAndRet, MCInst &Auth) override {
317+
Auth.clear();
318+
Auth.setOperands(AuthAndRet.getOperands());
319+
switch (AuthAndRet.getOpcode()) {
320+
case AArch64::RETAA:
321+
Auth.setOpcode(AArch64::AUTIASP);
322+
break;
323+
case AArch64::RETAB:
324+
Auth.setOpcode(AArch64::AUTIBSP);
325+
break;
326+
case AArch64::RETAASPPCi:
327+
Auth.setOpcode(AArch64::AUTIASPPCi);
328+
break;
329+
case AArch64::RETABSPPCi:
330+
Auth.setOpcode(AArch64::AUTIBSPPCi);
331+
break;
332+
case AArch64::RETAASPPCr:
333+
Auth.setOpcode(AArch64::AUTIASPPCr);
334+
break;
335+
case AArch64::RETABSPPCr:
336+
Auth.setOpcode(AArch64::AUTIBSPPCr);
337+
break;
338+
default:
339+
llvm_unreachable("Unhandled fused pauth-and-return instruction");
340+
}
341+
}
342+
316343
std::optional<MCPhysReg> getSignedReg(const MCInst &Inst) const override {
317344
switch (Inst.getOpcode()) {
318345
case AArch64::PACIA:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This test checks that inlining functions with fused pointer-auth-and-return
2+
# instructions is properly handled by BOLT.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+v8.3a %s -o %t.o
7+
# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q
8+
# RUN: llvm-bolt --inline-all --print-inline --print-only=_Z3barP1A \
9+
# RUN: %t.exe -o %t.bolt | FileCheck %s
10+
11+
# CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 8 bytes.
12+
# CHECK: Binary Function "_Z3barP1A" after inlining {
13+
# CHECK-NOT: bl _Z3fooP1A
14+
# CHECK: ldr x8, [x0]
15+
# CHECK-NEXT: ldr w0, [x8]
16+
# CHECK-NEXT: autiasp
17+
18+
.text
19+
.globl _Z3fooP1A
20+
.type _Z3fooP1A,@function
21+
_Z3fooP1A:
22+
paciasp
23+
ldr x8, [x0]
24+
ldr w0, [x8]
25+
retaa
26+
.size _Z3fooP1A, .-_Z3fooP1A
27+
28+
.globl _Z3barP1A
29+
.type _Z3barP1A,@function
30+
_Z3barP1A:
31+
stp x29, x30, [sp, #-16]!
32+
mov x29, sp
33+
bl _Z3fooP1A
34+
mul w0, w0, w0
35+
ldp x29, x30, [sp], #16
36+
ret
37+
.size _Z3barP1A, .-_Z3barP1A
38+
39+
.globl main
40+
.p2align 2
41+
.type main,@function
42+
main:
43+
mov w0, wzr
44+
ret
45+
.size main, .-main
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This test checks that inlining functions with fused pointer-auth-and-return
2+
# instructions into a location with a tailcall is properly handled by BOLT.
3+
# Because _Z3barP1A ends in a tailcall, we don't remove the return instruction
4+
# from the inlined block. Therefore, we should see a retaa, and not an autiasp.
5+
6+
# REQUIRES: system-linux
7+
8+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+v8.3a %s -o %t.o
9+
# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q
10+
# RUN: llvm-bolt --inline-all --print-inline --print-only=_Z3barP1A \
11+
# RUN: %t.exe -o %t.bolt | FileCheck %s
12+
13+
# CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 12 bytes.
14+
# CHECK: Binary Function "_Z3barP1A" after inlining {
15+
# CHECK-NOT: bl _Z3fooP1A
16+
# CHECK: mov x29, sp
17+
# CHECK-NEXT: paciasp
18+
# CHECK-NEXT: ldr x8, [x0]
19+
# CHECK-NEXT: ldr w0, [x8]
20+
# CHECK-NEXT: retaa
21+
22+
.text
23+
.globl _Z3fooP1A
24+
.type _Z3fooP1A,@function
25+
_Z3fooP1A:
26+
paciasp
27+
ldr x8, [x0]
28+
ldr w0, [x8]
29+
retaa
30+
.size _Z3fooP1A, .-_Z3fooP1A
31+
32+
.globl _Z3barP1A
33+
.type _Z3barP1A,@function
34+
_Z3barP1A:
35+
stp x29, x30, [sp, #-16]!
36+
mov x29, sp
37+
b _Z3fooP1A // tailcall
38+
.size _Z3barP1A, .-_Z3barP1A
39+
40+
.globl main
41+
.p2align 2
42+
.type main,@function
43+
main:
44+
mov w0, wzr
45+
ret
46+
.size main, .-main
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This test checks that inlining functions with the pauth-lr variants of
2+
# fused pointer-auth-and-return instructions is properly handled by BOLT.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: %clang %cflags -march=armv9.5-a+pauth-lr -O0 %s -o %t.exe -Wl,-q
7+
# RUN: llvm-bolt --inline-all --print-inline --print-only=_Z3barP1A \
8+
# RUN: %t.exe -o %t.bolt | FileCheck %s
9+
10+
# CHECK: BOLT-INFO: inlined 0 calls at 2 call sites in 2 iteration(s). Change in binary size: 16 bytes.
11+
# CHECK: Binary Function "_Z3barP1A" after inlining {
12+
# CHECK-NOT: bl _Z3fooP1A
13+
# CHECK: paciasppc
14+
# CHECK-NEXT: ldr x8, [x0]
15+
# CHECK-NEXT: ldr w0, [x8]
16+
# CHECK-NEXT: autiasppcr x28
17+
# CHECK-NEXT: paciasppc
18+
# CHECK-NEXT: ldr x7, [x0]
19+
# CHECK-NEXT: ldr w0, [x7]
20+
# CHECK-NEXT: autiasppc _Z3bazP1A
21+
22+
.text
23+
.globl _Z3fooP1A
24+
.type _Z3fooP1A,@function
25+
_Z3fooP1A:
26+
paciasppc
27+
ldr x8, [x0]
28+
ldr w0, [x8]
29+
retaasppcr x28
30+
.size _Z3fooP1A, .-_Z3fooP1A
31+
32+
.text
33+
.globl _Z3bazP1A
34+
.type _Z3bazP1A,@function
35+
_Z3bazP1A:
36+
0:
37+
paciasppc
38+
ldr x7, [x0]
39+
ldr w0, [x7]
40+
retaasppc 0b
41+
.size _Z3bazP1A, .-_Z3bazP1A
42+
43+
.globl _Z3barP1A
44+
.type _Z3barP1A,@function
45+
_Z3barP1A:
46+
stp x29, x30, [sp, #-16]!
47+
mov x29, sp
48+
bl _Z3fooP1A
49+
bl _Z3bazP1A
50+
mul w0, w0, w0
51+
ldp x29, x30, [sp], #16
52+
ret
53+
.size _Z3barP1A, .-_Z3barP1A
54+
55+
.globl main
56+
.p2align 2
57+
.type main,@function
58+
main:
59+
mov w0, wzr
60+
ret
61+
.size main, .-main

clang-tools-extra/clang-doc/assets/class-template.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
<section class="hero section-container">
141141
<div class="hero__title">
142142
<h1 class="hero__title-large">{{TagType}} {{Name}}</h1>
143+
<p>Defined at line {{Location.LineNumber}} of file {{Location.Filename}}</p>
143144
{{#Description}}
144145
<div class="hero__subtitle">
145146
{{>Comments}}

clang-tools-extra/clang-tidy/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Checks: >
99
-bugprone-narrowing-conversions,
1010
-bugprone-unchecked-optional-access,
1111
-bugprone-unused-return-value,
12+
misc-const-correctness,
1213
modernize-*,
1314
-modernize-avoid-c-arrays,
1415
-modernize-pass-by-value,

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,14 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
600600
// whether the call itself throws.
601601
if (const auto *Call = dyn_cast<CallExpr>(St)) {
602602
if (const FunctionDecl *Func = Call->getDirectCallee()) {
603-
ExceptionInfo Excs =
603+
const ExceptionInfo Excs =
604604
throwsException(Func, Caught, CallStack, Call->getBeginLoc());
605605
Results.merge(Excs);
606606
}
607607
} else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
608-
ExceptionInfo Excs = throwsException(Construct->getConstructor(), Caught,
609-
CallStack, Construct->getBeginLoc());
608+
const ExceptionInfo Excs =
609+
throwsException(Construct->getConstructor(), Caught, CallStack,
610+
Construct->getBeginLoc());
610611
Results.merge(Excs);
611612
}
612613
}

0 commit comments

Comments
 (0)