Skip to content

Commit 8c9f422

Browse files
authored
merge main into amd-staging (#759)
2 parents d82664f + f9ff47c commit 8c9f422

File tree

276 files changed

+8769
-2541
lines changed

Some content is hidden

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

276 files changed

+8769
-2541
lines changed

.ci/generate_test_report_lib.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
6262
# aligned with the failure.
6363
failing_action = ninja_log[index].split("FAILED: ")[1]
6464
failure_log = []
65+
66+
# Parse the lines above the FAILED: string if the line does not come
67+
# immediately after a progress indicator to ensure that we capture the
68+
# entire failure message.
69+
if not ninja_log[index - 1].startswith("["):
70+
before_index = index - 1
71+
while before_index > 0 and not ninja_log[before_index].startswith("["):
72+
failure_log.append(ninja_log[before_index])
73+
before_index = before_index - 1
74+
failure_log.reverse()
75+
76+
# Parse the failure information, which comes after the FAILED: tag.
6577
while (
6678
index < len(ninja_log)
6779
and not ninja_log[index].startswith("[")

.ci/generate_test_report_lib_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def test_ninja_log_mismatched_failed(self):
181181
"tools/check-langley",
182182
dedent(
183183
"""\
184+
ModuleNotFoundError: No module named 'mount_langley'
184185
FAILED: tools/check-langley
185186
Wow! This system is really broken!"""
186187
),

.github/workflows/premerge.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
fetch-depth: 2
6464
- name: Build and Test
6565
timeout-minutes: 120
66-
continue-on-error: ${{ runner.arch == 'ARM64' }}
6766
env:
6867
GITHUB_TOKEN: ${{ github.token }}
6968
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}

bolt/include/bolt/Passes/IdenticalCodeFolding.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@ class IdenticalCodeFolding : public BinaryFunctionPass {
3737
Error runOnFunctions(BinaryContext &BC) override;
3838

3939
private:
40+
static constexpr uint64_t VTableAddressGranularity = 4;
41+
4042
/// Bit vector of memory addresses of vtables.
4143
llvm::SparseBitVector<> VTableBitVector;
4244

4345
/// Return true if the memory address is in a vtable.
4446
bool isAddressInVTable(uint64_t Address) const {
45-
return VTableBitVector.test(Address / 8);
47+
return VTableBitVector.test(Address / VTableAddressGranularity);
4648
}
4749

4850
/// Mark memory address of a vtable as used.
4951
void setAddressUsedInVTable(uint64_t Address) {
50-
VTableBitVector.set(Address / 8);
52+
VTableBitVector.set(Address / VTableAddressGranularity);
5153
}
5254

5355
/// Scan symbol table and mark memory addresses of

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,9 +1408,7 @@ Error BinaryFunction::disassemble() {
14081408
// A recursive call. Calls to internal blocks are handled by
14091409
// ValidateInternalCalls pass.
14101410
TargetSymbol = getSymbol();
1411-
}
1412-
1413-
if (!TargetSymbol) {
1411+
} else {
14141412
// Create either local label or external symbol.
14151413
if (containsAddress(TargetAddress)) {
14161414
TargetSymbol = getOrCreateLocalLabel(TargetAddress);

bolt/lib/Passes/IdenticalCodeFolding.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ void IdenticalCodeFolding::initVTableReferences(const BinaryContext &BC) {
380380
if (!Data->getName().starts_with("_ZTV") && // vtable
381381
!Data->getName().starts_with("_ZTCN")) // construction vtable
382382
continue;
383-
for (uint64_t I = Address, End = I + Data->getSize(); I < End; I += 8)
383+
for (uint64_t I = Address, End = I + Data->getSize(); I < End;
384+
I += VTableAddressGranularity)
384385
setAddressUsedInVTable(I);
385386
}
386387
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Test safe ICF works with binaries that contain relative vtable.
2+
3+
// REQUIRES: system-linux,asserts
4+
5+
// RUN: %clang %cxxflags -o %t.so %s -Wl,-q -fno-rtti
6+
// RUN: llvm-bolt %t.so -o %t.bolt --no-threads --icf=safe \
7+
// RUN: --debug-only=bolt-icf 2>&1 | FileCheck %s
8+
9+
// RUN: %clang %cxxflags -o %t.so %s -Wl,-q -fno-rtti \
10+
// RUN: -fexperimental-relative-c++-abi-vtables
11+
// RUN: llvm-bolt %t.so -o %t.bolt --no-threads --icf=safe \
12+
// RUN: --debug-only=bolt-icf 2>&1 | FileCheck %s
13+
14+
// CHECK: folding {{.*bar.*}} into {{.*foo.*}}
15+
// CHECK-NOT: skipping function with reference taken {{.*bar.*}}
16+
17+
class TT {
18+
public:
19+
virtual int foo(int a) { return ++a; }
20+
virtual int bar(int a) { return ++a; }
21+
};
22+
23+
int main() {
24+
TT T;
25+
return T.foo(0) + T.bar(1);
26+
}

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88

99
#include "BitcodeReader.h"
1010
#include "llvm/Support/Error.h"
11+
#include "llvm/Support/ErrorHandling.h"
1112
#include "llvm/Support/TimeProfiler.h"
1213
#include "llvm/Support/raw_ostream.h"
1314
#include <optional>
1415

1516
namespace clang {
1617
namespace doc {
1718

19+
static llvm::ExitOnError ExitOnErr("clang-doc error: ");
20+
1821
using Record = llvm::SmallVector<uint64_t, 1024>;
1922

2023
// This implements decode for SmallString.
@@ -716,8 +719,8 @@ llvm::Error addReference(FriendInfo *Friend, Reference &&R, FieldId F) {
716719

717720
template <typename T, typename ChildInfoType>
718721
static void addChild(T I, ChildInfoType &&R) {
719-
llvm::errs() << "invalid child type for info";
720-
exit(1);
722+
ExitOnErr(llvm::createStringError(llvm::inconvertibleErrorCode(),
723+
"invalid child type for info"));
721724
}
722725

723726
// Namespace children:
@@ -766,8 +769,9 @@ template <> void addChild(BaseRecordInfo *I, FunctionInfo &&R) {
766769
// parameters) or TemplateSpecializationInfo (for the specialization's
767770
// parameters).
768771
template <typename T> static void addTemplateParam(T I, TemplateParamInfo &&P) {
769-
llvm::errs() << "invalid container for template parameter";
770-
exit(1);
772+
ExitOnErr(
773+
llvm::createStringError(llvm::inconvertibleErrorCode(),
774+
"invalid container for template parameter"));
771775
}
772776
template <> void addTemplateParam(TemplateInfo *I, TemplateParamInfo &&P) {
773777
I->Params.emplace_back(std::move(P));
@@ -779,8 +783,8 @@ void addTemplateParam(TemplateSpecializationInfo *I, TemplateParamInfo &&P) {
779783

780784
// Template info. These apply to either records or functions.
781785
template <typename T> static void addTemplate(T I, TemplateInfo &&P) {
782-
llvm::errs() << "invalid container for template info";
783-
exit(1);
786+
ExitOnErr(llvm::createStringError(llvm::inconvertibleErrorCode(),
787+
"invalid container for template info"));
784788
}
785789
template <> void addTemplate(RecordInfo *I, TemplateInfo &&P) {
786790
I->Template.emplace(std::move(P));
@@ -798,8 +802,9 @@ template <> void addTemplate(FriendInfo *I, TemplateInfo &&P) {
798802
// Template specializations go only into template records.
799803
template <typename T>
800804
static void addTemplateSpecialization(T I, TemplateSpecializationInfo &&TSI) {
801-
llvm::errs() << "invalid container for template specialization info";
802-
exit(1);
805+
ExitOnErr(llvm::createStringError(
806+
llvm::inconvertibleErrorCode(),
807+
"invalid container for template specialization info"));
803808
}
804809
template <>
805810
void addTemplateSpecialization(TemplateInfo *I,
@@ -808,8 +813,8 @@ void addTemplateSpecialization(TemplateInfo *I,
808813
}
809814

810815
template <typename T> static void addConstraint(T I, ConstraintInfo &&C) {
811-
llvm::errs() << "invalid container for constraint info";
812-
exit(1);
816+
ExitOnErr(llvm::createStringError(llvm::inconvertibleErrorCode(),
817+
"invalid container for constraint info"));
813818
}
814819
template <> void addConstraint(TemplateInfo *I, ConstraintInfo &&C) {
815820
I->Constraints.emplace_back(std::move(C));

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace doc {
2727
// Class to read bitstream into an InfoSet collection
2828
class ClangDocBitcodeReader {
2929
public:
30-
ClangDocBitcodeReader(llvm::BitstreamCursor &Stream) : Stream(Stream) {}
30+
ClangDocBitcodeReader(llvm::BitstreamCursor &Stream, DiagnosticsEngine &Diags)
31+
: Stream(Stream), Diags(Diags) {}
3132

3233
// Main entry point, calls readBlock to read each block in the given stream.
3334
llvm::Expected<std::vector<std::unique_ptr<Info>>> readBitcode();
@@ -72,6 +73,7 @@ class ClangDocBitcodeReader {
7273
llvm::BitstreamCursor &Stream;
7374
std::optional<llvm::BitstreamBlockInfo> BlockInfo;
7475
FieldId CurrentReferenceField;
76+
DiagnosticsEngine &Diags;
7577
};
7678

7779
} // namespace doc

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,9 @@ bool ClangDocBitcodeWriter::dispatchInfoForWrite(Info *I) {
769769
emitBlock(*static_cast<FriendInfo *>(I));
770770
break;
771771
case InfoType::IT_default:
772-
llvm::errs() << "Unexpected info, unable to write.\n";
772+
unsigned ID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
773+
"Unexpected info, unable to write.");
774+
Diags.Report(ID);
773775
return true;
774776
}
775777
return false;

0 commit comments

Comments
 (0)