Skip to content

Commit f1528eb

Browse files
rebase
Created using spr 1.3.7
2 parents 2e4f547 + 12c0858 commit f1528eb

File tree

2,304 files changed

+299066
-21574
lines changed

Some content is hidden

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

2,304 files changed

+299066
-21574
lines changed

.github/workflows/release-binaries.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ jobs:
132132
arches=arm64
133133
else
134134
arches=x86_64
135-
# Disable Flang builds on macOS x86_64. The FortranLower library takes
136-
# 2-3 hours to build on macOS, much slower than on Linux.
137-
# The long build time causes the release build to time out on x86_64,
138-
# so we need to disable flang there.
139-
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;polly;mlir'"
140135
fi
141136
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
142137
fi

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,6 @@ class BinaryContext {
781781
uint64_t PseudoProbeLooseMatchedSampleCount{0};
782782
/// the count of call matched samples
783783
uint64_t CallMatchedSampleCount{0};
784-
/// the number of stale functions that have matching number of blocks in
785-
/// the profile
786-
uint64_t NumStaleFuncsWithEqualBlockCount{0};
787-
/// the number of blocks that have matching size but a differing hash
788-
uint64_t NumStaleBlocksWithEqualIcount{0};
789784
} Stats;
790785

791786
// Original binary execution count stats.

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,11 @@ class BinaryFunction {
620620
}
621621

622622
/// Return a label at a given \p Address in the function. If the label does
623-
/// not exist - create it. Assert if the \p Address does not belong to
624-
/// the function. If \p CreatePastEnd is true, then return the function
625-
/// end label when the \p Address points immediately past the last byte
626-
/// of the function.
623+
/// not exist - create it.
624+
///
627625
/// NOTE: the function always returns a local (temp) symbol, even if there's
628626
/// a global symbol that corresponds to an entry at this address.
629-
MCSymbol *getOrCreateLocalLabel(uint64_t Address, bool CreatePastEnd = false);
627+
MCSymbol *getOrCreateLocalLabel(uint64_t Address);
630628

631629
/// Register an data entry at a given \p Offset into the function.
632630
void markDataAtOffset(uint64_t Offset) {

bolt/include/bolt/Passes/MarkRAStates.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
#define BOLT_PASSES_MARK_RA_STATES
1414

1515
#include "bolt/Passes/BinaryPasses.h"
16+
#include <mutex>
1617

1718
namespace llvm {
1819
namespace bolt {
1920

2021
class MarkRAStates : public BinaryFunctionPass {
22+
// setIgnored() is not thread-safe, but the pass is running on functions in
23+
// parallel.
24+
std::mutex IgnoreMutex;
25+
2126
public:
2227
explicit MarkRAStates() : BinaryFunctionPass(false) {}
2328

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,13 +1035,9 @@ BinaryFunction::processIndirectBranch(MCInst &Instruction, unsigned Size,
10351035
return BranchType;
10361036
}
10371037

1038-
MCSymbol *BinaryFunction::getOrCreateLocalLabel(uint64_t Address,
1039-
bool CreatePastEnd) {
1038+
MCSymbol *BinaryFunction::getOrCreateLocalLabel(uint64_t Address) {
10401039
const uint64_t Offset = Address - getAddress();
10411040

1042-
if ((Offset == getSize()) && CreatePastEnd)
1043-
return getFunctionEndLabel();
1044-
10451041
auto LI = Labels.find(Offset);
10461042
if (LI != Labels.end())
10471043
return LI->second;
@@ -1052,6 +1048,9 @@ MCSymbol *BinaryFunction::getOrCreateLocalLabel(uint64_t Address,
10521048
return IslandSym;
10531049
}
10541050

1051+
if (Offset == getSize())
1052+
return getFunctionEndLabel();
1053+
10551054
MCSymbol *Label = BC.Ctx->createNamedTempSymbol();
10561055
Labels[Offset] = Label;
10571056

@@ -1994,7 +1993,7 @@ void BinaryFunction::postProcessJumpTables() {
19941993
if (IsBuiltinUnreachable) {
19951994
BinaryFunction *TargetBF = BC.getBinaryFunctionAtAddress(EntryAddress);
19961995
MCSymbol *Label = TargetBF ? TargetBF->getSymbol()
1997-
: getOrCreateLocalLabel(EntryAddress, true);
1996+
: getOrCreateLocalLabel(EntryAddress);
19981997
JT.Entries.push_back(Label);
19991998
continue;
20001999
}
@@ -2005,7 +2004,7 @@ void BinaryFunction::postProcessJumpTables() {
20052004
BC.getBinaryFunctionContainingAddress(EntryAddress);
20062005
MCSymbol *Label;
20072006
if (HasOneParent && TargetBF == this) {
2008-
Label = getOrCreateLocalLabel(EntryAddress, true);
2007+
Label = getOrCreateLocalLabel(EntryAddress);
20092008
} else {
20102009
const uint64_t Offset = EntryAddress - TargetBF->getAddress();
20112010
Label = Offset ? TargetBF->addEntryPointAtOffset(Offset)

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,16 @@ void EliminateUnreachableBlocks::runOnFunction(BinaryFunction &Function) {
346346
uint64_t Bytes;
347347
Function.markUnreachableBlocks();
348348
LLVM_DEBUG({
349+
bool HasInvalidBB = false;
349350
for (BinaryBasicBlock &BB : Function) {
350351
if (!BB.isValid()) {
352+
HasInvalidBB = true;
351353
dbgs() << "BOLT-INFO: UCE found unreachable block " << BB.getName()
352354
<< " in function " << Function << "\n";
353-
Function.dump();
354355
}
355356
}
357+
if (HasInvalidBB)
358+
Function.dump();
356359
});
357360
BinaryContext::IndependentCodeEmitter Emitter =
358361
BC.createIndependentMCCodeEmitter();
@@ -1505,12 +1508,6 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
15051508
if (NumAllStaleFunctions) {
15061509
const float PctStale =
15071510
NumAllStaleFunctions / (float)NumAllProfiledFunctions * 100.0f;
1508-
const float PctStaleFuncsWithEqualBlockCount =
1509-
(float)BC.Stats.NumStaleFuncsWithEqualBlockCount /
1510-
NumAllStaleFunctions * 100.0f;
1511-
const float PctStaleBlocksWithEqualIcount =
1512-
(float)BC.Stats.NumStaleBlocksWithEqualIcount /
1513-
BC.Stats.NumStaleBlocks * 100.0f;
15141511
auto printErrorOrWarning = [&]() {
15151512
if (PctStale > opts::StaleThreshold)
15161513
BC.errs() << "BOLT-ERROR: ";
@@ -1533,17 +1530,6 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
15331530
<< "%) belong to functions with invalid"
15341531
" (possibly stale) profile.\n";
15351532
}
1536-
BC.outs() << "BOLT-INFO: " << BC.Stats.NumStaleFuncsWithEqualBlockCount
1537-
<< " stale function"
1538-
<< (BC.Stats.NumStaleFuncsWithEqualBlockCount == 1 ? "" : "s")
1539-
<< format(" (%.1f%% of all stale)",
1540-
PctStaleFuncsWithEqualBlockCount)
1541-
<< " have matching block count.\n";
1542-
BC.outs() << "BOLT-INFO: " << BC.Stats.NumStaleBlocksWithEqualIcount
1543-
<< " stale block"
1544-
<< (BC.Stats.NumStaleBlocksWithEqualIcount == 1 ? "" : "s")
1545-
<< format(" (%.1f%% of all stale)", PctStaleBlocksWithEqualIcount)
1546-
<< " have matching icount.\n";
15471533
if (PctStale > opts::StaleThreshold) {
15481534
return createFatalBOLTError(
15491535
Twine("BOLT-ERROR: stale functions exceed specified threshold of ") +

bolt/lib/Passes/MarkRAStates.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
4343
// Not all functions have .cfi_negate_ra_state in them. But if one does,
4444
// we expect psign/pauth instructions to have the hasNegateRAState
4545
// annotation.
46-
BF.setIgnored();
4746
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
4847
<< BF.getPrintName()
4948
<< ": ptr sign/auth inst without .cfi_negate_ra_state\n";
49+
std::lock_guard<std::mutex> Lock(IgnoreMutex);
50+
BF.setIgnored();
5051
return false;
5152
}
5253
}
@@ -67,6 +68,7 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
6768
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
6869
<< BF.getPrintName()
6970
<< ": ptr signing inst encountered in Signed RA state\n";
71+
std::lock_guard<std::mutex> Lock(IgnoreMutex);
7072
BF.setIgnored();
7173
return false;
7274
}
@@ -80,6 +82,7 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
8082
<< BF.getPrintName()
8183
<< ": ptr authenticating inst encountered in Unsigned RA "
8284
"state\n";
85+
std::lock_guard<std::mutex> Lock(IgnoreMutex);
8386
BF.setIgnored();
8487
return false;
8588
}

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ bool YAMLProfileReader::parseFunctionProfile(
350350
<< MismatchedCalls << " calls, and " << MismatchedEdges
351351
<< " edges in profile did not match function " << BF << '\n';
352352

353-
if (YamlBF.NumBasicBlocks != BF.size())
354-
++BC.Stats.NumStaleFuncsWithEqualBlockCount;
355-
356353
if (!opts::InferStaleProfile)
357354
return false;
358355
ArrayRef<ProbeMatchSpec> ProbeMatchSpecs;

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,9 +2949,7 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
29492949
ReferencedSymbol =
29502950
ReferencedBF->addEntryPointAtOffset(RefFunctionOffset);
29512951
} else {
2952-
ReferencedSymbol =
2953-
ReferencedBF->getOrCreateLocalLabel(Address,
2954-
/*CreatePastEnd =*/true);
2952+
ReferencedSymbol = ReferencedBF->getOrCreateLocalLabel(Address);
29552953

29562954
// If ContainingBF != nullptr, it equals ReferencedBF (see
29572955
// if-condition above) so we're handling a relocation from a function

bolt/test/X86/dwarf4-ftypes-dwp-input-dwo-output.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# UNSUPPORTED: system-linux
21
; RUN: rm -rf %t
32
; RUN: mkdir %t
43
; RUN: cd %t

0 commit comments

Comments
 (0)