Skip to content

Commit

Permalink
[AutoBump] Merge with f035d9f (Oct 15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorickert committed Jan 14, 2025
2 parents 9c02f81 + f035d9f commit e8aa382
Show file tree
Hide file tree
Showing 1,303 changed files with 56,249 additions and 22,894 deletions.
11 changes: 6 additions & 5 deletions bolt/include/bolt/Profile/BoltAddressTranslation.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,13 @@ class BoltAddressTranslation {
uint64_t FuncOutputAddress) const;

/// Write the serialized address translation table for a function.
template <bool Cold>
void writeMaps(std::map<uint64_t, MapTy> &Maps, uint64_t &PrevAddress,
raw_ostream &OS);
template <bool Cold> void writeMaps(uint64_t &PrevAddress, raw_ostream &OS);

/// Read the serialized address translation table for a function.
/// Return a parse error if failed.
template <bool Cold>
void parseMaps(std::vector<uint64_t> &HotFuncs, uint64_t &PrevAddress,
DataExtractor &DE, uint64_t &Offset, Error &Err);
void parseMaps(uint64_t &PrevAddress, DataExtractor &DE, uint64_t &Offset,
Error &Err);

/// Returns the bitmask with set bits corresponding to indices of BRANCHENTRY
/// entries in function address translation map.
Expand All @@ -161,6 +159,9 @@ class BoltAddressTranslation {

std::map<uint64_t, MapTy> Maps;

/// Ordered vector with addresses of hot functions.
std::vector<uint64_t> HotFuncs;

/// Map a function to its basic blocks count
std::unordered_map<uint64_t, size_t> NumBasicBlocksMap;

Expand Down
8 changes: 2 additions & 6 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3684,9 +3684,8 @@ BinaryFunction::BasicBlockListType BinaryFunction::dfs() const {
BinaryBasicBlock *BB = Stack.top();
Stack.pop();

if (Visited.find(BB) != Visited.end())
if (!Visited.insert(BB).second)
continue;
Visited.insert(BB);
DFS.push_back(BB);

for (BinaryBasicBlock *SuccBB : BB->landing_pads()) {
Expand Down Expand Up @@ -3879,11 +3878,8 @@ void BinaryFunction::disambiguateJumpTables(
JumpTable *JT = getJumpTable(Inst);
if (!JT)
continue;
auto Iter = JumpTables.find(JT);
if (Iter == JumpTables.end()) {
JumpTables.insert(JT);
if (JumpTables.insert(JT).second)
continue;
}
// This instruction is an indirect jump using a jump table, but it is
// using the same jump table of another jump. Try all our tricks to
// extract the jump table symbol and make it point to a new, duplicated JT
Expand Down
8 changes: 3 additions & 5 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ getDWOName(llvm::DWARFUnit &CU,
"DW_AT_dwo_name/DW_AT_GNU_dwo_name does not exist.");
if (DwarfOutputPath) {
DWOName = std::string(sys::path::filename(DWOName));
auto Iter = NameToIndexMap.find(DWOName);
if (Iter == NameToIndexMap.end())
Iter = NameToIndexMap.insert({DWOName, 0}).first;
DWOName.append(std::to_string(Iter->second));
++Iter->second;
uint32_t &Index = NameToIndexMap[DWOName];
DWOName.append(std::to_string(Index));
++Index;
}
DWOName.append(".dwo");
return DWOName;
Expand Down
6 changes: 2 additions & 4 deletions bolt/lib/Passes/Instrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ static bool hasAArch64ExclusiveMemop(
BinaryBasicBlock *BB = BBQueue.front().first;
bool IsLoad = BBQueue.front().second;
BBQueue.pop();
if (Visited.find(BB) != Visited.end())
if (!Visited.insert(BB).second)
continue;
Visited.insert(BB);

for (const MCInst &Inst : *BB) {
// Two loads one after another - skip whole function
Expand All @@ -126,8 +125,7 @@ static bool hasAArch64ExclusiveMemop(
if (BC.MIB->isAArch64ExclusiveLoad(Inst))
IsLoad = true;

if (IsLoad && BBToSkip.find(BB) == BBToSkip.end()) {
BBToSkip.insert(BB);
if (IsLoad && BBToSkip.insert(BB).second) {
if (opts::Verbosity >= 2) {
outs() << "BOLT-INSTRUMENTER: skip BB " << BB->getName()
<< " due to exclusive instruction in function "
Expand Down
22 changes: 10 additions & 12 deletions bolt/lib/Profile/BoltAddressTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {

// Output addresses are delta-encoded
uint64_t PrevAddress = 0;
writeMaps</*Cold=*/false>(Maps, PrevAddress, OS);
writeMaps</*Cold=*/true>(Maps, PrevAddress, OS);
writeMaps</*Cold=*/false>(PrevAddress, OS);
writeMaps</*Cold=*/true>(PrevAddress, OS);

BC.outs() << "BOLT-INFO: Wrote " << Maps.size() << " BAT maps\n";
BC.outs() << "BOLT-INFO: Wrote " << FuncHashes.getNumFunctions()
Expand Down Expand Up @@ -182,8 +182,7 @@ size_t BoltAddressTranslation::getNumEqualOffsets(const MapTy &Map,
}

template <bool Cold>
void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
uint64_t &PrevAddress, raw_ostream &OS) {
void BoltAddressTranslation::writeMaps(uint64_t &PrevAddress, raw_ostream &OS) {
const uint32_t NumFuncs =
llvm::count_if(llvm::make_first_range(Maps), [&](const uint64_t Address) {
return Cold == ColdPartSource.count(Address);
Expand Down Expand Up @@ -213,16 +212,17 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
: 0;
uint32_t Skew = 0;
if (Cold) {
auto HotEntryIt = Maps.find(ColdPartSource[Address]);
assert(HotEntryIt != Maps.end());
size_t HotIndex = std::distance(Maps.begin(), HotEntryIt);
auto HotEntryIt = llvm::lower_bound(HotFuncs, ColdPartSource[Address]);
assert(HotEntryIt != HotFuncs.end());
size_t HotIndex = std::distance(HotFuncs.begin(), HotEntryIt);
encodeULEB128(HotIndex - PrevIndex, OS);
PrevIndex = HotIndex;
// Skew of all input offsets for cold fragments is simply the first input
// offset.
Skew = Map.begin()->second >> 1;
encodeULEB128(Skew, OS);
} else {
HotFuncs.push_back(Address);
// Function hash
size_t BFHash = getBFHash(HotInputAddress);
LLVM_DEBUG(dbgs() << "Hash: " << formatv("{0:x}\n", BFHash));
Expand Down Expand Up @@ -311,17 +311,15 @@ std::error_code BoltAddressTranslation::parse(raw_ostream &OS, StringRef Buf) {
return make_error_code(llvm::errc::io_error);

Error Err(Error::success());
std::vector<uint64_t> HotFuncs;
uint64_t PrevAddress = 0;
parseMaps</*Cold=*/false>(HotFuncs, PrevAddress, DE, Offset, Err);
parseMaps</*Cold=*/true>(HotFuncs, PrevAddress, DE, Offset, Err);
parseMaps</*Cold=*/false>(PrevAddress, DE, Offset, Err);
parseMaps</*Cold=*/true>(PrevAddress, DE, Offset, Err);
OS << "BOLT-INFO: Parsed " << Maps.size() << " BAT entries\n";
return errorToErrorCode(std::move(Err));
}

template <bool Cold>
void BoltAddressTranslation::parseMaps(std::vector<uint64_t> &HotFuncs,
uint64_t &PrevAddress, DataExtractor &DE,
void BoltAddressTranslation::parseMaps(uint64_t &PrevAddress, DataExtractor &DE,
uint64_t &Offset, Error &Err) {
const uint32_t NumFunctions = DE.getULEB128(&Offset, &Err);
LLVM_DEBUG(dbgs() << "Parsing " << NumFunctions << (Cold ? " cold" : "")
Expand Down
4 changes: 2 additions & 2 deletions bolt/tools/driver/llvm-bolt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ int main(int argc, char **argv) {

ToolName = argv[0];

if (llvm::sys::path::filename(ToolName) == "perf2bolt")
if (llvm::sys::path::filename(ToolName).starts_with("perf2bolt"))
perf2boltMode(argc, argv);
else if (llvm::sys::path::filename(ToolName) == "llvm-boltdiff")
else if (llvm::sys::path::filename(ToolName).starts_with("llvm-boltdiff"))
boltDiffMode(argc, argv);
else
boltMode(argc, argv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void CrtpConstructorAccessibilityCheck::check(

WithFriendHintIfNeeded(
diag(Ctor->getLocation(),
"%0 contructor allows the CRTP to be %select{inherited "
"%0 constructor allows the CRTP to be %select{inherited "
"from|constructed}1 as a regular template class; consider making "
"it private%select{| and declaring the derived class as friend}2")
<< Access << IsPublic << NeedsFriend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ static bool mayShadow(const NamedDecl *ND0,
const ConfusableIdentifierCheck::ContextInfo *
ConfusableIdentifierCheck::getContextInfo(const DeclContext *DC) {
const DeclContext *PrimaryContext = DC->getPrimaryContext();
auto It = ContextInfos.find(PrimaryContext);
if (It != ContextInfos.end())
auto [It, Inserted] = ContextInfos.try_emplace(PrimaryContext);
if (!Inserted)
return &It->second;

ContextInfo &Info = ContextInfos[PrimaryContext];
ContextInfo &Info = It->second;
Info.PrimaryContext = PrimaryContext;
Info.NonTransparentContext = PrimaryContext;

Expand Down
Loading

0 comments on commit e8aa382

Please sign in to comment.