Skip to content

Commit 825f1c7

Browse files
authored
Merge branch 'main' into scalarize-load-bitcast
2 parents 401c933 + 22b6c49 commit 825f1c7

File tree

443 files changed

+8794
-3649
lines changed

Some content is hidden

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

443 files changed

+8794
-3649
lines changed

.ci/generate_test_report_github.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import generate_test_report_lib
1010

11+
1112
def compute_platform_title() -> str:
1213
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
1314
# On Linux the machine value is x86_64 on Windows it is AMD64.

.ci/generate_test_report_lib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
100100
)
101101
return output
102102

103+
103104
def get_failures(junit_objects) -> dict[str, list[tuple[str, str]]]:
104105
failures = {}
105106
for results in junit_objects:

bolt/lib/Core/Relocation.cpp

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,41 +1018,15 @@ void Relocation::print(raw_ostream &OS) const {
10181018
default:
10191019
OS << "RType:" << Twine::utohexstr(Type);
10201020
break;
1021-
1022-
case Triple::aarch64: {
1023-
static const char *const AArch64RelocNames[] = {
1024-
#define ELF_RELOC(name, value) #name,
1025-
#include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
1026-
#undef ELF_RELOC
1027-
};
1028-
assert(Type < ArrayRef(AArch64RelocNames).size());
1029-
OS << AArch64RelocNames[Type];
1030-
} break;
1031-
1021+
case Triple::aarch64:
1022+
OS << object::getELFRelocationTypeName(ELF::EM_AARCH64, Type);
1023+
break;
10321024
case Triple::riscv64:
1033-
// RISC-V relocations are not sequentially numbered so we cannot use an
1034-
// array
1035-
switch (Type) {
1036-
default:
1037-
llvm_unreachable("illegal RISC-V relocation");
1038-
#define ELF_RELOC(name, value) \
1039-
case value: \
1040-
OS << #name; \
1025+
OS << object::getELFRelocationTypeName(ELF::EM_RISCV, Type);
10411026
break;
1042-
#include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
1043-
#undef ELF_RELOC
1044-
}
1027+
case Triple::x86_64:
1028+
OS << object::getELFRelocationTypeName(ELF::EM_X86_64, Type);
10451029
break;
1046-
1047-
case Triple::x86_64: {
1048-
static const char *const X86RelocNames[] = {
1049-
#define ELF_RELOC(name, value) #name,
1050-
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
1051-
#undef ELF_RELOC
1052-
};
1053-
assert(Type < ArrayRef(X86RelocNames).size());
1054-
OS << X86RelocNames[Type];
1055-
} break;
10561030
}
10571031
OS << ", 0x" << Twine::utohexstr(Offset);
10581032
if (Symbol) {

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
640640
Insts[1].addOperand(MCOperand::createImm(0));
641641
Insts[1].addOperand(MCOperand::createImm(0));
642642
setOperandToSymbolRef(Insts[1], /* OpNum */ 2, Target, 0, Ctx,
643-
ELF::R_AARCH64_ADD_ABS_LO12_NC);
643+
isLDRXl(LDRInst) ? ELF::R_AARCH64_LDST64_ABS_LO12_NC
644+
: ELF::R_AARCH64_LDST32_ABS_LO12_NC);
644645
return Insts;
645646
}
646647

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Verify that llvm-bolt correctly prints relocation types.
2+
3+
# REQUIRES: system-linux
4+
5+
# RUN: %clang %cflags -nostartfiles %s -o %t.exe -Wl,-q,--no-relax
6+
# RUN: llvm-bolt %t.exe --print-cfg --print-relocations -o %t.bolt \
7+
# RUN: | FileCheck %s
8+
9+
.section .text
10+
.align 4
11+
.globl _start
12+
.type _start, %function
13+
_start:
14+
15+
adrp x0, _start
16+
# CHECK: adrp
17+
# CHECK-SAME: R_AARCH64_ADR_PREL_PG_HI21
18+
19+
add x0, x0, :lo12:_start
20+
# CHECK-NEXT: add
21+
# CHECK-SAME: R_AARCH64_ADD_ABS_LO12_NC
22+
23+
ret
24+
.size _start, .-_start

bolt/test/runtime/AArch64/inline-memcpy.s

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@
8181
# CHECK-ASM: bl{{.*}}<memcpy
8282

8383
# Register move should NOT be inlined (size unknown at compile time)
84-
# CHECK-ASM-LABEL: <test_register_move_negative>:
84+
# CHECK-ASM-LABEL: <test_register_move_unknown>:
8585
# CHECK-ASM: bl{{.*}}<memcpy
8686

87-
# CHECK-ASM-LABEL: <test_x2_rewrite_negative>:
87+
# CHECK-ASM-LABEL: <test_x2_rewrite_unknown>:
8888
# CHECK-ASM: bl{{.*}}<memcpy
8989

9090
# Live-in parameter should NOT be inlined (size unknown at compile time)
91-
# CHECK-ASM-LABEL: <test_live_in_negative>:
91+
# CHECK-ASM-LABEL: <test_live_in_unknown>:
9292
# CHECK-ASM: bl{{.*}}<memcpy
9393

9494
# _memcpy8 should be inlined with end-pointer return (dest+size)
@@ -262,9 +262,9 @@ test_4_byte_add_immediate:
262262
ret
263263
.size test_4_byte_add_immediate, .-test_4_byte_add_immediate
264264

265-
.globl test_register_move_negative
266-
.type test_register_move_negative,@function
267-
test_register_move_negative:
265+
.globl test_register_move_unknown
266+
.type test_register_move_unknown,@function
267+
test_register_move_unknown:
268268
stp x29, x30, [sp, #-32]!
269269
mov x29, sp
270270
add x1, sp, #16
@@ -274,20 +274,20 @@ test_register_move_negative:
274274
bl memcpy
275275
ldp x29, x30, [sp], #32
276276
ret
277-
.size test_register_move_negative, .-test_register_move_negative
277+
.size test_register_move_unknown, .-test_register_move_unknown
278278

279-
.globl test_x2_rewrite_negative
280-
.type test_x2_rewrite_negative,@function
281-
test_x2_rewrite_negative:
279+
.globl test_x2_rewrite_unknown
280+
.type test_x2_rewrite_unknown,@function
281+
test_x2_rewrite_unknown:
282282
mov x2, #8
283283
ldr x2, [sp, #24]
284284
bl memcpy
285285
ret
286-
.size test_x2_rewrite_negative, .-test_x2_rewrite_negative
286+
.size test_x2_rewrite_unknown, .-test_x2_rewrite_unknown
287287

288-
.globl test_live_in_negative
289-
.type test_live_in_negative,@function
290-
test_live_in_negative:
288+
.globl test_live_in_unknown
289+
.type test_live_in_unknown,@function
290+
test_live_in_unknown:
291291
# x2 comes in as parameter, no instruction sets it (should NOT inline)
292292
stp x29, x30, [sp, #-32]!
293293
mov x29, sp
@@ -297,7 +297,7 @@ test_live_in_negative:
297297
bl memcpy
298298
ldp x29, x30, [sp], #32
299299
ret
300-
.size test_live_in_negative, .-test_live_in_negative
300+
.size test_live_in_unknown, .-test_live_in_unknown
301301

302302
.globl test_memcpy8_4_byte
303303
.type test_memcpy8_4_byte,@function

bolt/unittests/Profile/PerfSpeEvents.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,92 @@ TEST_F(PerfSpeEventsTestHelper, SpeBranchesWithBrstack) {
161161
parseAndCheckBrstackEvents(1234, ExpectedSamples);
162162
}
163163

164+
TEST_F(PerfSpeEventsTestHelper, SpeBranchesWithBrstackAndPbt) {
165+
// Check perf input with SPE branch events as brstack format by
166+
// combining with the previous branch target address (named as PBT).
167+
// Example collection command:
168+
// ```
169+
// perf record -e 'arm_spe_0/branch_filter=1/u' -- BINARY
170+
// ```
171+
// How Bolt extracts the branch events:
172+
// ```
173+
// perf script -F pid,brstack --itrace=bl
174+
// ```
175+
176+
opts::ArmSPE = true;
177+
opts::ReadPerfEvents =
178+
// "<PID> <SRC>/<DEST>/PN/-/-/10/COND/- <NULL>/<PBT>/-/-/-/0//-\n"
179+
" 4567 0xa002/0xa003/PN/-/-/10/COND/- 0x0/0xa001/-/-/-/0//-\n"
180+
" 4567 0xb002/0xb003/P/-/-/4/RET/- 0x0/0xb001/-/-/-/0//-\n"
181+
" 4567 0xc456/0xc789/P/-/-/13/-/- 0x0/0xc123/-/-/-/0//-\n"
182+
" 4567 0xd456/0xd789/M/-/-/7/RET/- 0x0/0xd123/-/-/-/0//-\n"
183+
" 4567 0xe005/0xe009/P/-/-/14/RET/- 0x0/0xe001/-/-/-/0//-\n"
184+
" 4567 0xd456/0xd789/M/-/-/7/RET/- 0x0/0xd123/-/-/-/0//-\n"
185+
" 4567 0xf002/0xf003/MN/-/-/8/COND/- 0x0/0xf001/-/-/-/0//-\n"
186+
" 4567 0xc456/0xc789/P/-/-/13/-/- 0x0/0xc123/-/-/-/0//-\n";
187+
188+
// ExpectedSamples contains the aggregated information about
189+
// a branch {{From, To, TraceTo}, {TakenCount, MispredCount}}.
190+
// Where
191+
// - From: is the source address of the sampled branch operation.
192+
// - To: is the target address of the sampled branch operation.
193+
// - TraceTo could be either
194+
// - A 'Type = Trace::BR_ONLY', which means the trace only contains branch
195+
// data.
196+
// - Or an address, when the trace contains information about the previous
197+
// branch.
198+
//
199+
// When FEAT_SPE_PBT is present, Arm SPE emits two records per sample:
200+
// - the current branch (Spe.From/Spe.To), and
201+
// - the previous taken branch target (PBT) (PBT.From, PBT.To).
202+
//
203+
// Together they behave like a depth-1 branch stack where:
204+
// - the PBT entry is always taken
205+
// - the current branch entry may represent a taken branch or a fall-through
206+
// - the destination (Spe.To) is the architecturally executed target
207+
//
208+
// There can be fall-throughs to be inferred between the PBT entry and
209+
// the current branch (Spe.From), but there cannot be between current
210+
// branch's (Spe.From/Spe.To).
211+
//
212+
// PBT records only the target address (PBT.To), meaning we have no
213+
// information as the branch source (PBT.From=0x0), branch type, and the
214+
// prediction bit.
215+
//
216+
// Consider the trace pair:
217+
// {{Spe.From, Spe.To, Type}, {TK, MP}},
218+
// {{PBT.From, PBT.To, TraceTo}, {TK, MP}}
219+
// {{0xd456, 0xd789, Trace::BR_ONLY}, {2, 2}}, {{0x0, 0xd123, 0xd456}, {2, 0}}
220+
//
221+
// The first entry is the Spe record, which represents a trace from 0xd456
222+
// (Spe.From) to 0xd789 (Spe.To). Type = Trace::BR_ONLY, as Bolt processes the
223+
// current branch event first. At this point we have no information about the
224+
// previous trace (PBT). This entry has a TakenCount = 2, as we have two
225+
// samples for (0xd456, 0xd789) in our input. It also has MispredsCount = 2,
226+
// as 'M' misprediction flag appears in both cases.
227+
//
228+
// The second entry is the PBT record. TakenCount = 2 because the
229+
// (PBT.From = 0x0, PBT.To = 0xd123) branch target appears twice in the input,
230+
// and MispredsCount = 0 because prediction data is absent. There is no branch
231+
// source information, so the PBT.From field is zero (0x0). TraceTo = 0xd456
232+
// connect the flow from the previous taken branch at 0xd123 (PBT.To) to the
233+
// current source branch at 0xd456 (Spe.From), which then continues to 0xd789
234+
// (Spe.To).
235+
std::vector<std::pair<Trace, TakenBranchInfo>> ExpectedSamples = {
236+
{{0xa002, 0xa003, Trace::BR_ONLY}, {1, 0}},
237+
{{0x0, 0xa001, 0xa002}, {1, 0}},
238+
{{0xb002, 0xb003, Trace::BR_ONLY}, {1, 0}},
239+
{{0x0, 0xb001, 0xb002}, {1, 0}},
240+
{{0xc456, 0xc789, Trace::BR_ONLY}, {2, 0}},
241+
{{0x0, 0xc123, 0xc456}, {2, 0}},
242+
{{0xd456, 0xd789, Trace::BR_ONLY}, {2, 2}},
243+
{{0x0, 0xd123, 0xd456}, {2, 0}},
244+
{{0xe005, 0xe009, Trace::BR_ONLY}, {1, 0}},
245+
{{0x0, 0xe001, 0xe005}, {1, 0}},
246+
{{0xf002, 0xf003, Trace::BR_ONLY}, {1, 1}},
247+
{{0x0, 0xf001, 0xf002}, {1, 0}}};
248+
249+
parseAndCheckBrstackEvents(4567, ExpectedSamples);
250+
}
251+
164252
#endif

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ static void insertArray(Object &Obj, json::Value &Array, StringRef Key) {
468468
static void serializeInfo(const RecordInfo &I, json::Object &Obj,
469469
const std::optional<StringRef> &RepositoryUrl) {
470470
serializeCommonAttributes(I, Obj, RepositoryUrl);
471-
Obj["FullName"] = I.FullName;
472471
Obj["TagType"] = getTagType(I.TagType);
473472
Obj["IsTypedef"] = I.IsTypeDef;
474473
Obj["MangledName"] = I.MangledName;

clang-tools-extra/clang-doc/Representation.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,6 @@ struct FunctionInfo : public SymbolInfo {
437437
// (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
438438
AccessSpecifier Access = AccessSpecifier::AS_public;
439439

440-
// Full qualified name of this function, including namespaces and template
441-
// specializations.
442-
SmallString<16> FullName;
443-
444440
// Function Prototype
445441
SmallString<256> Prototype;
446442

@@ -460,10 +456,6 @@ struct RecordInfo : public SymbolInfo {
460456
// Type of this record (struct, class, union, interface).
461457
TagTypeKind TagType = TagTypeKind::Struct;
462458

463-
// Full qualified name of this record, including namespaces and template
464-
// specializations.
465-
SmallString<16> FullName;
466-
467459
// When present, this record is a template or specialization.
468460
std::optional<TemplateInfo> Template;
469461

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -178,55 +178,6 @@ static llvm::SmallString<16> getTypeAlias(const TypeAliasDecl *Alias) {
178178
return Result;
179179
}
180180

181-
// extract full syntax for record declaration
182-
static llvm::SmallString<16> getRecordPrototype(const CXXRecordDecl *CXXRD) {
183-
llvm::SmallString<16> Result;
184-
LangOptions LangOpts;
185-
PrintingPolicy Policy(LangOpts);
186-
Policy.SuppressTagKeyword = false;
187-
Policy.FullyQualifiedName = true;
188-
Policy.IncludeNewlines = false;
189-
llvm::raw_svector_ostream OS(Result);
190-
if (const auto *TD = CXXRD->getDescribedClassTemplate()) {
191-
OS << "template <";
192-
bool FirstParam = true;
193-
for (const auto *Param : *TD->getTemplateParameters()) {
194-
if (!FirstParam)
195-
OS << ", ";
196-
Param->print(OS, Policy);
197-
FirstParam = false;
198-
}
199-
OS << ">\n";
200-
}
201-
202-
if (CXXRD->isStruct())
203-
OS << "struct ";
204-
else if (CXXRD->isClass())
205-
OS << "class ";
206-
else if (CXXRD->isUnion())
207-
OS << "union ";
208-
209-
OS << CXXRD->getNameAsString();
210-
211-
// We need to make sure we have a good enough declaration to check. In the
212-
// case where the class is a forward declaration, we'll fail assertions in
213-
// DeclCXX.
214-
if (CXXRD->isCompleteDefinition() && CXXRD->getNumBases() > 0) {
215-
OS << " : ";
216-
bool FirstBase = true;
217-
for (const auto &Base : CXXRD->bases()) {
218-
if (!FirstBase)
219-
OS << ", ";
220-
if (Base.isVirtual())
221-
OS << "virtual ";
222-
OS << getAccessSpelling(Base.getAccessSpecifier()) << " ";
223-
OS << Base.getType().getAsString(Policy);
224-
FirstBase = false;
225-
}
226-
}
227-
return Result;
228-
}
229-
230181
// A function to extract the appropriate relative path for a given info's
231182
// documentation. The path returned is a composite of the parent namespaces.
232183
//
@@ -1033,7 +984,6 @@ emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc,
1033984
parseFields(*RI, D, PublicOnly);
1034985

1035986
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
1036-
RI->FullName = getRecordPrototype(C);
1037987
if (const TypedefNameDecl *TD = C->getTypedefNameForAnonDecl()) {
1038988
RI->Name = TD->getNameAsString();
1039989
RI->IsTypeDef = true;

0 commit comments

Comments
 (0)