Skip to content

Commit 8a08d84

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge llvm/main into amd-debug
2 parents fe9f535 + e665cf3 commit 8a08d84

File tree

161 files changed

+2890
-1320
lines changed

Some content is hidden

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

161 files changed

+2890
-1320
lines changed

.ci/metrics/metrics.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,29 @@ def github_get_metrics(
336336
name_suffix = GITHUB_JOB_TO_TRACK[name_prefix][job.name]
337337
metric_name = name_prefix + "_" + name_suffix
338338

339+
ag_metric_name = None
340+
if libcxx_testing:
341+
job_key = None
342+
if job.name.find("stage1") != -1:
343+
job_key = "stage1"
344+
elif job.name.find("stage2") != -1:
345+
job_key = "stage2"
346+
elif job.name.find("stage3") != -1:
347+
job_key = "stage3"
348+
if job_key:
349+
ag_name = (
350+
name_prefix + "_" + GITHUB_JOB_TO_TRACK[name_prefix][job_key]
351+
)
352+
339353
if task.status != "completed":
340354
if job.status == "queued":
341355
queued_count[metric_name] += 1
356+
if libcxx_testing:
357+
queued_count[ag_name] += 1
342358
elif job.status == "in_progress":
343359
running_count[metric_name] += 1
360+
if libcxx_testing:
361+
running_count[ag_name] += 1
344362
continue
345363

346364
job_result = int(job.conclusion == "success" or job.conclusion == "skipped")

bolt/lib/Core/BinaryBasicBlock.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,18 @@ bool BinaryBasicBlock::validateSuccessorInvariants() {
103103
Valid &= (Sym == Function->getFunctionEndLabel() ||
104104
Sym == Function->getFunctionEndLabel(getFragmentNum()));
105105
if (!Valid) {
106-
BC.errs() << "BOLT-WARNING: Jump table contains illegal entry: "
107-
<< Sym->getName() << "\n";
106+
const BinaryFunction *TargetBF = BC.getFunctionForSymbol(Sym);
107+
if (TargetBF) {
108+
// It's possible for another function to be in the jump table entry
109+
// as a result of built-in unreachable.
110+
Valid = true;
111+
} else {
112+
BC.errs() << "BOLT-WARNING: Jump table contains illegal entry: "
113+
<< Sym->getName() << "\n";
114+
}
108115
}
116+
if (!Valid)
117+
break;
109118
}
110119
}
111120
} else {

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,9 @@ void BinaryFunction::postProcessJumpTables() {
19591959
return EntryAddress == Parent->getAddress() + Parent->getSize();
19601960
});
19611961
if (IsBuiltinUnreachable) {
1962-
MCSymbol *Label = getOrCreateLocalLabel(EntryAddress, true);
1962+
BinaryFunction *TargetBF = BC.getBinaryFunctionAtAddress(EntryAddress);
1963+
MCSymbol *Label = TargetBF ? TargetBF->getSymbol()
1964+
: getOrCreateLocalLabel(EntryAddress, true);
19631965
JT.Entries.push_back(Label);
19641966
continue;
19651967
}

bolt/lib/Passes/IndirectCallPromotion.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,7 @@ IndirectCallPromotion::getCallTargets(BinaryBasicBlock &BB,
261261
for (size_t I = Range.first; I < Range.second; ++I, JI += JIAdj) {
262262
MCSymbol *Entry = JT->Entries[I];
263263
const BinaryBasicBlock *ToBB = BF.getBasicBlockForLabel(Entry);
264-
assert(ToBB || Entry == BF.getFunctionEndLabel() ||
265-
Entry == BF.getFunctionEndLabel(FragmentNum::cold()));
266-
if (Entry == BF.getFunctionEndLabel() ||
267-
Entry == BF.getFunctionEndLabel(FragmentNum::cold()))
264+
if (!ToBB)
268265
continue;
269266
const Location To(Entry);
270267
const BinaryBasicBlock::BinaryBranchInfo &BI = BB.getBranchInfo(*ToBB);
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## Check that llvm-bolt correctly updates ambiguous jump table entries that
2+
## can correspond to either builtin_unreachable() or could be a pointer to
3+
## the next function.
4+
5+
# REQUIRES: system-linux
6+
7+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
8+
# RUN: %clang %cflags %t.o -o %t.exe -no-pie -Wl,-q
9+
10+
# RUN: llvm-bolt %t.exe --print-normalized --print-only=foo -o %t.out \
11+
# RUN: 2>&1 | FileCheck %s
12+
13+
14+
15+
.text
16+
.globl _start
17+
.type _start, %function
18+
_start:
19+
.cfi_startproc
20+
call foo
21+
ret
22+
.cfi_endproc
23+
.size _start, .-_start
24+
25+
.globl foo
26+
.type foo, %function
27+
foo:
28+
.cfi_startproc
29+
.LBB00:
30+
movq 0x8(%rdi), %rdi
31+
movzbl 0x1(%rdi), %eax
32+
.LBB00_br:
33+
jmpq *"JUMP_TABLE/foo.0"(,%rax,8)
34+
# CHECK: jmpq {{.*}} # JUMPTABLE
35+
# CHECK-NEXT: Successors: {{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}
36+
37+
.Ltmp87085:
38+
xorl %eax, %eax
39+
retq
40+
41+
.Ltmp87086:
42+
cmpb $0x0, 0x8(%rdi)
43+
setne %al
44+
retq
45+
46+
.Ltmp87088:
47+
movb $0x1, %al
48+
retq
49+
50+
.Ltmp87087:
51+
movzbl 0x14(%rdi), %eax
52+
andb $0x2, %al
53+
shrb %al
54+
retq
55+
56+
.cfi_endproc
57+
.size foo, .-foo
58+
59+
.globl bar
60+
.type bar, %function
61+
bar:
62+
.cfi_startproc
63+
ret
64+
.cfi_endproc
65+
.size bar, .-bar
66+
67+
# Jump tables
68+
.section .rodata
69+
.global jump_table
70+
jump_table:
71+
"JUMP_TABLE/foo.0":
72+
.quad bar
73+
.quad .Ltmp87085
74+
.quad bar
75+
.quad .Ltmp87086
76+
.quad .Ltmp87087
77+
.quad .LBB00
78+
.quad .Ltmp87088
79+
.quad bar
80+
.quad .LBB00
81+
82+
# CHECK: Jump table {{.*}} for function foo
83+
# CHECK-NEXT: 0x{{.*}} : bar
84+
# CHECK-NEXT: 0x{{.*}} :
85+
# CHECK-NEXT: 0x{{.*}} : bar
86+
# CHECK-NEXT: 0x{{.*}} :
87+
# CHECK-NEXT: 0x{{.*}} :

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,8 @@ parseBases(RecordInfo &I, const CXXRecordDecl *D, bool IsFileInRootDir,
901901
if (!D->isThisDeclarationADefinition())
902902
return;
903903
for (const CXXBaseSpecifier &B : D->bases()) {
904-
if (const RecordType *Ty = B.getType()->getAs<RecordType>()) {
905-
if (const CXXRecordDecl *Base = cast_or_null<CXXRecordDecl>(
906-
Ty->getOriginalDecl()->getDefinition())) {
904+
if (const auto *Base = B.getType()->getAsCXXRecordDecl()) {
905+
if (Base->isCompleteDefinition()) {
907906
// Initialized without USR and name, this will be set in the following
908907
// if-else stmt.
909908
BaseRecordInfo BI(

clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void DefaultOperatorNewAlignmentCheck::check(
3131
return;
3232
const TagDecl *D = T->getAsTagDecl();
3333
// Alignment can not be obtained for undefined type.
34-
if (!D || !D->getDefinition() || !D->isCompleteDefinition())
34+
if (!D || !D->isCompleteDefinition())
3535
return;
3636

3737
ASTContext &Context = D->getASTContext();

clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ void SlicingCheck::diagnoseSlicedOverriddenMethods(
9090
}
9191
// Recursively process bases.
9292
for (const auto &Base : DerivedDecl.bases()) {
93-
if (const auto *BaseRecordType = Base.getType()->getAs<RecordType>()) {
94-
if (const auto *BaseRecord = cast_or_null<CXXRecordDecl>(
95-
BaseRecordType->getOriginalDecl()->getDefinition()))
93+
if (const auto *BaseRecord = Base.getType()->getAsCXXRecordDecl()) {
94+
if (BaseRecord->isCompleteDefinition())
9695
diagnoseSlicedOverriddenMethods(Call, *BaseRecord, BaseDecl);
9796
}
9897
}

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,10 @@ bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
7171
for (const auto &I : Node->bases()) {
7272
if (I.isVirtual())
7373
continue;
74-
const auto *Ty = I.getType()->getAs<RecordType>();
75-
if (!Ty)
74+
const auto *Base = I.getType()->getAsCXXRecordDecl();
75+
if (!Base)
7676
continue;
77-
const RecordDecl *D = Ty->getOriginalDecl()->getDefinition();
78-
if (!D)
79-
continue;
80-
const auto *Base = cast<CXXRecordDecl>(D);
77+
assert(Base->isCompleteDefinition());
8178
if (!isInterface(Base)) {
8279
addNodeToInterfaceMap(Node, false);
8380
return false;
@@ -103,23 +100,21 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
103100
for (const auto &I : D->bases()) {
104101
if (I.isVirtual())
105102
continue;
106-
const auto *Ty = I.getType()->getAs<RecordType>();
107-
if (!Ty)
103+
const auto *Base = I.getType()->getAsCXXRecordDecl();
104+
if (!Base)
108105
continue;
109-
const auto *Base =
110-
cast<CXXRecordDecl>(Ty->getOriginalDecl()->getDefinition());
106+
assert(Base->isCompleteDefinition());
111107
if (!isInterface(Base))
112108
NumConcrete++;
113109
}
114110

115111
// Check virtual bases to see if there is more than one concrete
116112
// non-virtual base.
117113
for (const auto &V : D->vbases()) {
118-
const auto *Ty = V.getType()->getAs<RecordType>();
119-
if (!Ty)
114+
const auto *Base = V.getType()->getAsCXXRecordDecl();
115+
if (!Base)
120116
continue;
121-
const auto *Base =
122-
cast<CXXRecordDecl>(Ty->getOriginalDecl()->getDefinition());
117+
assert(Base->isCompleteDefinition());
123118
if (!isInterface(Base))
124119
NumConcrete++;
125120
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context) {
119119
if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
120120
return true;
121121

122-
if (const auto *RT = CanonicalType->getAs<RecordType>()) {
123-
return recordIsTriviallyDefaultConstructible(
124-
*RT->getOriginalDecl()->getDefinitionOrSelf(), Context);
122+
if (const auto *RD = CanonicalType->getAsRecordDecl()) {
123+
return recordIsTriviallyDefaultConstructible(*RD, Context);
125124
}
126125

127126
// No other types can match.

0 commit comments

Comments
 (0)