Skip to content

Commit 50c7888

Browse files
committed
Merge commit 'af773a18181dc1a1e3846f518b2d44f2abbbdf87' into feature/merge-upstream-20220124
2 parents e764a82 + af773a1 commit 50c7888

File tree

1,821 files changed

+34027
-77772
lines changed

Some content is hidden

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

1,821 files changed

+34027
-77772
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ CheckOptions:
1818
value: 1
1919
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
2020
value: 1
21+
- key: modernize-use-default-member-init.UseAssignment
22+
value: 1

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
#include "llvm/MC/MCAsmInfo.h"
2929
#include "llvm/MC/MCCodeEmitter.h"
3030
#include "llvm/MC/MCContext.h"
31-
#include "llvm/MC/MCDwarf.h"
32-
#include "llvm/MC/MCInstrInfo.h"
3331
#include "llvm/MC/MCObjectFileInfo.h"
3432
#include "llvm/MC/MCObjectWriter.h"
3533
#include "llvm/MC/MCPseudoProbe.h"
3634
#include "llvm/MC/MCSectionELF.h"
3735
#include "llvm/MC/MCSectionMachO.h"
36+
#include "llvm/MC/MCStreamer.h"
3837
#include "llvm/MC/MCSymbol.h"
3938
#include "llvm/MC/TargetRegistry.h"
4039
#include "llvm/Support/ErrorOr.h"

bolt/include/bolt/Core/BinaryData.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define BOLT_CORE_BINARY_DATA_H
1717

1818
#include "llvm/ADT/Twine.h"
19-
#include "llvm/MC/MCStreamer.h"
2019
#include "llvm/MC/MCSymbol.h"
2120
#include "llvm/Support/raw_ostream.h"
2221
#include <algorithm>

bolt/include/bolt/Core/DebugData.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifndef BOLT_CORE_DEBUG_DATA_H
1515
#define BOLT_CORE_DEBUG_DATA_H
1616

17-
#include "llvm/ADT/MapVector.h"
1817
#include "llvm/ADT/SmallVector.h"
1918
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
2019
#include "llvm/MC/MCDwarf.h"
@@ -33,8 +32,6 @@
3332

3433
namespace llvm {
3534

36-
class DWARFAbbreviationDeclarationSet;
37-
3835
namespace bolt {
3936

4037
class BinaryContext;

bolt/include/bolt/Passes/AllocCombiner.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
namespace llvm {
1515
namespace bolt {
16-
class DataflowInfoManager;
17-
class FrameAnalysis;
1816

1917
class AllocCombinerPass : public BinaryFunctionPass {
2018
/// Stats aggregating variables

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
#define BOLT_REWRITE_DWARF_REWRITER_H
1111

1212
#include "bolt/Core/DebugData.h"
13-
#include "bolt/Rewrite/RewriteInstance.h"
1413
#include <cstdint>
15-
#include <map>
1614
#include <memory>
1715
#include <mutex>
16+
#include <set>
1817
#include <unordered_map>
1918
#include <vector>
2019

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "llvm/MC/MCExpr.h"
2929
#include "llvm/MC/MCInst.h"
3030
#include "llvm/MC/MCInstPrinter.h"
31-
#include "llvm/MC/MCStreamer.h"
3231
#include "llvm/Object/ObjectFile.h"
3332
#include "llvm/Support/CommandLine.h"
3433
#include "llvm/Support/Debug.h"
@@ -3613,13 +3612,13 @@ void BinaryFunction::insertBasicBlocks(
36133612
std::vector<std::unique_ptr<BinaryBasicBlock>> &&NewBBs,
36143613
const bool UpdateLayout, const bool UpdateCFIState,
36153614
const bool RecomputeLandingPads) {
3616-
const auto StartIndex = Start ? getIndex(Start) : -1;
3615+
const int64_t StartIndex = Start ? getIndex(Start) : -1LL;
36173616
const size_t NumNewBlocks = NewBBs.size();
36183617

36193618
BasicBlocks.insert(BasicBlocks.begin() + (StartIndex + 1), NumNewBlocks,
36203619
nullptr);
36213620

3622-
auto I = StartIndex + 1;
3621+
int64_t I = StartIndex + 1;
36233622
for (std::unique_ptr<BinaryBasicBlock> &BB : NewBBs) {
36243623
assert(!BasicBlocks[I]);
36253624
BasicBlocks[I++] = BB.release();

bolt/lib/Core/DebugData.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "bolt/Core/DebugData.h"
14-
#include "bolt/Core/BinaryBasicBlock.h"
15-
#include "bolt/Core/BinaryFunction.h"
14+
#include "bolt/Core/BinaryContext.h"
1615
#include "bolt/Utils/Utils.h"
16+
#include "llvm/MC/MCContext.h"
1717
#include "llvm/MC/MCObjectStreamer.h"
18-
#include "llvm/MC/MCSymbol.h"
1918
#include "llvm/Support/CommandLine.h"
2019
#include "llvm/Support/EndianStream.h"
2120
#include "llvm/Support/LEB128.h"
@@ -32,6 +31,8 @@ extern llvm::cl::opt<unsigned> Verbosity;
3231
} // namespace opts
3332

3433
namespace llvm {
34+
class MCSymbol;
35+
3536
namespace bolt {
3637

3738
const DebugLineTableRowRef DebugLineTableRowRef::NULL_ROW{0, 0};

bolt/lib/Core/JumpTable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "bolt/Core/BinaryFunction.h"
1515
#include "bolt/Core/BinarySection.h"
1616
#include "llvm/Support/CommandLine.h"
17-
#include "llvm/Support/Debug.h"
1817

1918
#define DEBUG_TYPE "bolt"
2019

bolt/lib/Passes/IndirectCallPromotion.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "bolt/Passes/IndirectCallPromotion.h"
1414
#include "bolt/Passes/BinaryFunctionCallGraph.h"
1515
#include "bolt/Passes/DataflowInfoManager.h"
16-
#include "bolt/Utils/CommandLineOpts.h"
1716
#include "llvm/Support/CommandLine.h"
1817

1918
#define DEBUG_TYPE "ICP"
@@ -281,7 +280,7 @@ IndirectCallPromotion::getCallTargets(BinaryBasicBlock &BB,
281280
Inst.getOperand(0).getReg() == BC.MRI->getProgramCounter())
282281
return Targets;
283282

284-
auto ICSP = BC.MIB->tryGetAnnotationAs<IndirectCallSiteProfile>(
283+
const auto ICSP = BC.MIB->tryGetAnnotationAs<IndirectCallSiteProfile>(
285284
Inst, "CallProfile");
286285
if (ICSP) {
287286
for (const IndirectCallProfile &CSP : ICSP.get()) {
@@ -292,17 +291,18 @@ IndirectCallPromotion::getCallTargets(BinaryBasicBlock &BB,
292291
}
293292
}
294293

295-
// Sort by target count, number of indices in case of jump table, and
296-
// mispredicts. We prioritize targets with high count, small number of
297-
// indices and high mispredicts
294+
// Sort by target count, number of indices in case of jump table, and
295+
// mispredicts. We prioritize targets with high count, small number of indices
296+
// and high mispredicts. Break ties by selecting targets with lower addresses.
298297
std::stable_sort(Targets.begin(), Targets.end(),
299298
[](const Callsite &A, const Callsite &B) {
300299
if (A.Branches != B.Branches)
301300
return A.Branches > B.Branches;
302-
else if (A.JTIndices.size() != B.JTIndices.size())
301+
if (A.JTIndices.size() != B.JTIndices.size())
303302
return A.JTIndices.size() < B.JTIndices.size();
304-
else
303+
if (A.Mispreds != B.Mispreds)
305304
return A.Mispreds > B.Mispreds;
305+
return A.To.Addr < B.To.Addr;
306306
});
307307

308308
// Remove non-symbol targets
@@ -938,7 +938,7 @@ size_t IndirectCallPromotion::canPromoteCallsite(
938938
// If we have no targets (or no calls), skip this callsite.
939939
if (Targets.empty() || !NumCalls) {
940940
if (opts::Verbosity >= 1) {
941-
const auto InstIdx = &Inst - &(*BB.begin());
941+
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
942942
outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ "
943943
<< InstIdx << " in " << BB.getName() << ", calls = " << NumCalls
944944
<< ", targets empty or NumCalls == 0.\n";
@@ -985,7 +985,7 @@ size_t IndirectCallPromotion::canPromoteCallsite(
985985
if (TopNFrequency == 0 ||
986986
TopNFrequency < opts::IndirectCallPromotionMispredictThreshold) {
987987
if (opts::Verbosity >= 1) {
988-
const auto InstIdx = &Inst - &(*BB.begin());
988+
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
989989
outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ "
990990
<< InstIdx << " in " << BB.getName() << ", calls = " << NumCalls
991991
<< ", top N mis. frequency " << format("%.1f", TopNFrequency)
@@ -1034,7 +1034,7 @@ size_t IndirectCallPromotion::canPromoteCallsite(
10341034
if (TopNMispredictFrequency <
10351035
opts::IndirectCallPromotionMispredictThreshold) {
10361036
if (opts::Verbosity >= 1) {
1037-
const auto InstIdx = &Inst - &(*BB.begin());
1037+
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
10381038
outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ "
10391039
<< InstIdx << " in " << BB.getName()
10401040
<< ", calls = " << NumCalls << ", top N mispredict frequency "
@@ -1064,7 +1064,7 @@ void IndirectCallPromotion::printCallsiteInfo(
10641064
BinaryContext &BC = BB.getFunction()->getBinaryContext();
10651065
const bool IsTailCall = BC.MIB->isTailCall(Inst);
10661066
const bool IsJumpTable = BB.getFunction()->getJumpTable(Inst);
1067-
const auto InstIdx = &Inst - &(*BB.begin());
1067+
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
10681068

10691069
outs() << "BOLT-INFO: ICP candidate branch info: " << *BB.getFunction()
10701070
<< " @ " << InstIdx << " in " << BB.getName()
@@ -1219,7 +1219,7 @@ void IndirectCallPromotion::runOnFunctions(BinaryContext &BC) {
12191219

12201220
for (unsigned Idx = 0; Idx < BB->size(); ++Idx) {
12211221
MCInst &Inst = BB->getInstructionAtIndex(Idx);
1222-
const auto InstIdx = &Inst - &(*BB->begin());
1222+
const ptrdiff_t InstIdx = &Inst - &(*BB->begin());
12231223
const bool IsTailCall = BC.MIB->isTailCall(Inst);
12241224
const bool HasIndirectCallProfile =
12251225
BC.MIB->hasAnnotation(Inst, "CallProfile");

0 commit comments

Comments
 (0)