Skip to content

Commit bf5d0fa

Browse files
authored
Merge branch 'main' into objc_make_exception_ptr_fix
2 parents 966c3c7 + 4b54d1a commit bf5d0fa

File tree

1,488 files changed

+33356
-11001
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,488 files changed

+33356
-11001
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,19 @@ class BinaryFunction {
804804
return iterator_range<const_cfi_iterator>(cie_begin(), cie_end());
805805
}
806806

807+
/// Iterate over instructions (only if CFG is unavailable or not built yet).
808+
iterator_range<InstrMapType::iterator> instrs() {
809+
assert(!hasCFG() && "Iterate over basic blocks instead");
810+
return make_range(Instructions.begin(), Instructions.end());
811+
}
812+
iterator_range<InstrMapType::const_iterator> instrs() const {
813+
assert(!hasCFG() && "Iterate over basic blocks instead");
814+
return make_range(Instructions.begin(), Instructions.end());
815+
}
816+
817+
/// Returns whether there are any labels at Offset.
818+
bool hasLabelAt(unsigned Offset) const { return Labels.count(Offset) != 0; }
819+
807820
/// Iterate over all jump tables associated with this function.
808821
iterator_range<std::map<uint64_t, JumpTable *>::const_iterator>
809822
jumpTables() const {

bolt/include/bolt/Passes/PAuthGadgetScanner.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ struct MCInstInBFReference {
6565
uint64_t Offset;
6666
MCInstInBFReference(BinaryFunction *BF, uint64_t Offset)
6767
: BF(BF), Offset(Offset) {}
68+
69+
static MCInstInBFReference get(const MCInst *Inst, BinaryFunction &BF) {
70+
for (auto &I : BF.instrs())
71+
if (Inst == &I.second)
72+
return MCInstInBFReference(&BF, I.first);
73+
return {};
74+
}
75+
6876
MCInstInBFReference() : BF(nullptr), Offset(0) {}
6977
bool operator==(const MCInstInBFReference &RHS) const {
7078
return BF == RHS.BF && Offset == RHS.Offset;
@@ -104,6 +112,12 @@ struct MCInstReference {
104112
MCInstReference(BinaryFunction *BF, uint32_t Offset)
105113
: MCInstReference(MCInstInBFReference(BF, Offset)) {}
106114

115+
static MCInstReference get(const MCInst *Inst, BinaryFunction &BF) {
116+
if (BF.hasCFG())
117+
return MCInstInBBReference::get(Inst, BF);
118+
return MCInstInBFReference::get(Inst, BF);
119+
}
120+
107121
bool operator<(const MCInstReference &RHS) const {
108122
if (ParentKind != RHS.ParentKind)
109123
return ParentKind < RHS.ParentKind;
@@ -138,6 +152,16 @@ struct MCInstReference {
138152
llvm_unreachable("");
139153
}
140154

155+
operator bool() const {
156+
switch (ParentKind) {
157+
case BasicBlockParent:
158+
return U.BBRef.BB != nullptr;
159+
case FunctionParent:
160+
return U.BFRef.BF != nullptr;
161+
}
162+
llvm_unreachable("");
163+
}
164+
141165
uint64_t getAddress() const {
142166
switch (ParentKind) {
143167
case BasicBlockParent:

bolt/include/bolt/Profile/DataReader.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,8 @@ struct FuncBranchData {
114114

115115
FuncBranchData() {}
116116

117-
FuncBranchData(StringRef Name, ContainerTy Data)
118-
: Name(Name), Data(std::move(Data)) {}
119-
120-
FuncBranchData(StringRef Name, ContainerTy Data, ContainerTy EntryData)
117+
FuncBranchData(StringRef Name, ContainerTy Data = ContainerTy(),
118+
ContainerTy EntryData = ContainerTy())
121119
: Name(Name), Data(std::move(Data)), EntryData(std::move(EntryData)) {}
122120

123121
ErrorOr<const BranchInfo &> getBranch(uint64_t From, uint64_t To) const;
@@ -205,7 +203,7 @@ struct FuncMemData {
205203

206204
FuncMemData() {}
207205

208-
FuncMemData(StringRef Name, ContainerTy Data)
206+
FuncMemData(StringRef Name, ContainerTy Data = ContainerTy())
209207
: Name(Name), Data(std::move(Data)) {}
210208
};
211209

@@ -241,7 +239,7 @@ struct FuncBasicSampleData {
241239
StringRef Name;
242240
ContainerTy Data;
243241

244-
FuncBasicSampleData(StringRef Name, ContainerTy Data)
242+
FuncBasicSampleData(StringRef Name, ContainerTy Data = ContainerTy())
245243
: Name(Name), Data(std::move(Data)) {}
246244

247245
/// Get the number of samples recorded in [Start, End)

bolt/lib/Core/DebugData.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
676676
return;
677677
}
678678

679-
std::vector<uint64_t> OffsetsArray;
680679
auto writeExpression = [&](uint32_t Index) -> void {
681680
const DebugLocationEntry &Entry = LocList[Index];
682681
encodeULEB128(Entry.Expr.size(), LocBodyStream);

bolt/lib/Passes/FrameAnalysis.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ bool FrameAnalysis::updateArgsTouchedFor(const BinaryFunction &BF, MCInst &Inst,
320320
if (!BC.MIB->isCall(Inst))
321321
return false;
322322

323-
std::set<int64_t> Res;
324323
const MCSymbol *TargetSymbol = BC.MIB->getTargetSymbol(Inst);
325324
// If indirect call, we conservatively assume it accesses all stack positions
326325
if (TargetSymbol == nullptr) {

bolt/lib/Passes/HFSort.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ std::vector<Cluster> clusterize(const CallGraph &Cg) {
239239
}
240240

241241
std::vector<Cluster> randomClusters(const CallGraph &Cg) {
242-
std::vector<NodeId> FuncIds(Cg.numNodes(), 0);
243242
std::vector<Cluster> Clusters;
244243
Clusters.reserve(Cg.numNodes());
245244

0 commit comments

Comments
 (0)