From 1c06193d0f4f04fd191ad982fc59752aebc28763 Mon Sep 17 00:00:00 2001 From: James Luo Date: Wed, 2 Jun 2021 22:46:57 -0700 Subject: [PATCH] [BOLT] Resolve JumpTable namespace issue in pseudo probe decoder migration Summary: This diff fixes the JumpTable namespace conflicts during the migration of pseudo probe decoder. (cherry picked from FBD28859927) --- bolt/src/BinaryEmitter.cpp | 1 + bolt/src/JumpTable.cpp | 32 ++++++++++-------------- bolt/src/Passes/IdenticalCodeFolding.cpp | 1 + 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/bolt/src/BinaryEmitter.cpp b/bolt/src/BinaryEmitter.cpp index 4171f187226f..bdf78a5cc66e 100644 --- a/bolt/src/BinaryEmitter.cpp +++ b/bolt/src/BinaryEmitter.cpp @@ -123,6 +123,7 @@ size_t padFunction(const BinaryFunction &Function) { } // namespace opts namespace { +using JumpTable = bolt::JumpTable; class BinaryEmitter { private: diff --git a/bolt/src/JumpTable.cpp b/bolt/src/JumpTable.cpp index d348a9079e3d..700c9bf881a2 100644 --- a/bolt/src/JumpTable.cpp +++ b/bolt/src/JumpTable.cpp @@ -20,28 +20,21 @@ using namespace llvm; using namespace bolt; +using JumpTable = bolt::JumpTable; + namespace opts { extern cl::opt JumpTables; extern cl::opt Verbosity; } -JumpTable::JumpTable(MCSymbol &Symbol, - uint64_t Address, - size_t EntrySize, - JumpTableType Type, - LabelMapType &&Labels, - BinaryFunction &BF, - BinarySection &Section) - : BinaryData(Symbol, Address, 0, EntrySize, Section), - EntrySize(EntrySize), - OutputEntrySize(EntrySize), - Type(Type), - Labels(Labels), - Parent(&BF) { -} +bolt::JumpTable::JumpTable(MCSymbol &Symbol, uint64_t Address, size_t EntrySize, + JumpTableType Type, LabelMapType &&Labels, + BinaryFunction &BF, BinarySection &Section) + : BinaryData(Symbol, Address, 0, EntrySize, Section), EntrySize(EntrySize), + OutputEntrySize(EntrySize), Type(Type), Labels(Labels), Parent(&BF) {} std::pair -JumpTable::getEntriesForAddress(const uint64_t Addr) const { +bolt::JumpTable::getEntriesForAddress(const uint64_t Addr) const { // Check if this is not an address, but a cloned JT id if ((int64_t)Addr < 0ll) return std::make_pair(0, Entries.size()); @@ -72,8 +65,9 @@ JumpTable::getEntriesForAddress(const uint64_t Addr) const { return std::make_pair(StartIndex, EndIndex); } -bool JumpTable::replaceDestination(uint64_t JTAddress, const MCSymbol *OldDest, - MCSymbol *NewDest) { +bool bolt::JumpTable::replaceDestination(uint64_t JTAddress, + const MCSymbol *OldDest, + MCSymbol *NewDest) { bool Patched = false; const std::pair Range = getEntriesForAddress(JTAddress); for (auto I = &Entries[Range.first], E = &Entries[Range.second]; I != E; @@ -87,7 +81,7 @@ bool JumpTable::replaceDestination(uint64_t JTAddress, const MCSymbol *OldDest, return Patched; } -void JumpTable::updateOriginal() { +void bolt::JumpTable::updateOriginal() { BinaryContext &BC = getSection().getBinaryContext(); const uint64_t BaseOffset = getAddress() - getSection().getAddress(); uint64_t EntryOffset = BaseOffset; @@ -105,7 +99,7 @@ void JumpTable::updateOriginal() { } } -void JumpTable::print(raw_ostream &OS) const { +void bolt::JumpTable::print(raw_ostream &OS) const { uint64_t Offset = 0; if (Type == JTT_PIC) OS << "PIC "; diff --git a/bolt/src/Passes/IdenticalCodeFolding.cpp b/bolt/src/Passes/IdenticalCodeFolding.cpp index e9d1cc33d5c1..e9b0dd0b23c6 100644 --- a/bolt/src/Passes/IdenticalCodeFolding.cpp +++ b/bolt/src/Passes/IdenticalCodeFolding.cpp @@ -43,6 +43,7 @@ TimeICF("time-icf", } // namespace opts namespace { +using JumpTable = bolt::JumpTable; /// Compare two jump tables in 2 functions. The function relies on consistent /// ordering of basic blocks in both binary functions (e.g. DFS).