From f18fcdabda7271d386d24de71302907cc3f0fe4b Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Thu, 8 Apr 2021 23:31:12 -0700 Subject: [PATCH] [BOLT][NFC] Expand auto types pt.2 Summary: Expand autos where it may lead to differences in the BOLT binary. Test Plan: NFC Reviewers: maksfb Reviewed By: maks FBD27673231 --- bolt/lib/Core/BinaryFunction.cpp | 4 ++-- bolt/lib/Passes/IndirectCallPromotion.cpp | 12 ++++++------ bolt/lib/Profile/YAMLProfileWriter.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 9d55a83..18f521e 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3613,13 +3613,13 @@ void BinaryFunction::insertBasicBlocks( std::vector> &&NewBBs, const bool UpdateLayout, const bool UpdateCFIState, const bool RecomputeLandingPads) { - const auto StartIndex = Start ? getIndex(Start) : -1; + const int64_t StartIndex = Start ? getIndex(Start) : -1LL; const size_t NumNewBlocks = NewBBs.size(); BasicBlocks.insert(BasicBlocks.begin() + (StartIndex + 1), NumNewBlocks, nullptr); - auto I = StartIndex + 1; + int64_t I = StartIndex + 1; for (std::unique_ptr &BB : NewBBs) { assert(!BasicBlocks[I]); BasicBlocks[I++] = BB.release(); diff --git a/bolt/lib/Passes/IndirectCallPromotion.cpp b/bolt/lib/Passes/IndirectCallPromotion.cpp index 188655b..4f16041 100644 --- a/bolt/lib/Passes/IndirectCallPromotion.cpp +++ b/bolt/lib/Passes/IndirectCallPromotion.cpp @@ -281,7 +281,7 @@ IndirectCallPromotion::getCallTargets(BinaryBasicBlock &BB, Inst.getOperand(0).getReg() == BC.MRI->getProgramCounter()) return Targets; - auto ICSP = BC.MIB->tryGetAnnotationAs( + const auto ICSP = BC.MIB->tryGetAnnotationAs( Inst, "CallProfile"); if (ICSP) { for (const IndirectCallProfile &CSP : ICSP.get()) { @@ -938,7 +938,7 @@ size_t IndirectCallPromotion::canPromoteCallsite( // If we have no targets (or no calls), skip this callsite. if (Targets.empty() || !NumCalls) { if (opts::Verbosity >= 1) { - const auto InstIdx = &Inst - &(*BB.begin()); + const ptrdiff_t InstIdx = &Inst - &(*BB.begin()); outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ " << InstIdx << " in " << BB.getName() << ", calls = " << NumCalls << ", targets empty or NumCalls == 0.\n"; @@ -985,7 +985,7 @@ size_t IndirectCallPromotion::canPromoteCallsite( if (TopNFrequency == 0 || TopNFrequency < opts::IndirectCallPromotionMispredictThreshold) { if (opts::Verbosity >= 1) { - const auto InstIdx = &Inst - &(*BB.begin()); + const ptrdiff_t InstIdx = &Inst - &(*BB.begin()); outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ " << InstIdx << " in " << BB.getName() << ", calls = " << NumCalls << ", top N mis. frequency " << format("%.1f", TopNFrequency) @@ -1034,7 +1034,7 @@ size_t IndirectCallPromotion::canPromoteCallsite( if (TopNMispredictFrequency < opts::IndirectCallPromotionMispredictThreshold) { if (opts::Verbosity >= 1) { - const auto InstIdx = &Inst - &(*BB.begin()); + const ptrdiff_t InstIdx = &Inst - &(*BB.begin()); outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ " << InstIdx << " in " << BB.getName() << ", calls = " << NumCalls << ", top N mispredict frequency " @@ -1064,7 +1064,7 @@ void IndirectCallPromotion::printCallsiteInfo( BinaryContext &BC = BB.getFunction()->getBinaryContext(); const bool IsTailCall = BC.MIB->isTailCall(Inst); const bool IsJumpTable = BB.getFunction()->getJumpTable(Inst); - const auto InstIdx = &Inst - &(*BB.begin()); + const ptrdiff_t InstIdx = &Inst - &(*BB.begin()); outs() << "BOLT-INFO: ICP candidate branch info: " << *BB.getFunction() << " @ " << InstIdx << " in " << BB.getName() @@ -1219,7 +1219,7 @@ void IndirectCallPromotion::runOnFunctions(BinaryContext &BC) { for (unsigned Idx = 0; Idx < BB->size(); ++Idx) { MCInst &Inst = BB->getInstructionAtIndex(Idx); - const auto InstIdx = &Inst - &(*BB->begin()); + const ptrdiff_t InstIdx = &Inst - &(*BB->begin()); const bool IsTailCall = BC.MIB->isTailCall(Inst); const bool HasIndirectCallProfile = BC.MIB->hasAnnotation(Inst, "CallProfile"); diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index d8d6975..ddbcd59 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -59,7 +59,7 @@ void convert(const BinaryFunction &BF, CSI.Offset = *Offset - BB->getInputOffset(); if (BC.MIB->isIndirectCall(Instr) || BC.MIB->isIndirectBranch(Instr)) { - auto ICSP = BC.MIB->tryGetAnnotationAs( + const auto ICSP = BC.MIB->tryGetAnnotationAs( Instr, "CallProfile"); if (!ICSP) continue; -- 2.7.4