[BOLT][NFC] Expand auto types pt.2
authorAmir Ayupov <aaupov@fb.com>
Fri, 9 Apr 2021 06:31:12 +0000 (23:31 -0700)
committerAmir Ayupov <aaupov@fb.com>
Fri, 21 Jan 2022 20:02:57 +0000 (12:02 -0800)
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
bolt/lib/Passes/IndirectCallPromotion.cpp
bolt/lib/Profile/YAMLProfileWriter.cpp

index 9d55a83..18f521e 100644 (file)
@@ -3613,13 +3613,13 @@ void BinaryFunction::insertBasicBlocks(
     std::vector<std::unique_ptr<BinaryBasicBlock>> &&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<BinaryBasicBlock> &BB : NewBBs) {
     assert(!BasicBlocks[I]);
     BasicBlocks[I++] = BB.release();
index 188655b..4f16041 100644 (file)
@@ -281,7 +281,7 @@ IndirectCallPromotion::getCallTargets(BinaryBasicBlock &BB,
         Inst.getOperand(0).getReg() == BC.MRI->getProgramCounter())
       return Targets;
 
-    auto ICSP = BC.MIB->tryGetAnnotationAs<IndirectCallSiteProfile>(
+    const auto ICSP = BC.MIB->tryGetAnnotationAs<IndirectCallSiteProfile>(
         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");
index d8d6975..ddbcd59 100644 (file)
@@ -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<IndirectCallSiteProfile>(
+        const auto ICSP = BC.MIB->tryGetAnnotationAs<IndirectCallSiteProfile>(
             Instr, "CallProfile");
         if (!ICSP)
           continue;