liberty/lib/Utilities/InlineFunctionWithVmap.cpp
/// Update inlined instructions' line numbers to
/// to encode location where these instructions are inlined.
Update inlined instructions' line numbers to
to encode location where these instructions are inlined.
Update inlined instructions ' line numbers to to encode location where these instructions are inlined .
static void fixupLineNumbers(Function *Fn, Function::iterator FI,
                             Instruction *TheCall, bool CalleeHasDebugInfo) {
  const DebugLoc &TheCallDL = TheCall->getDebugLoc();
  if (!TheCallDL)
    return;
  auto &Ctx = Fn->getContext();
  DILocation *InlinedAtNode = TheCallDL;
  InlinedAtNode = DILocation::getDistinct(
      Ctx, InlinedAtNode->getLine(), InlinedAtNode->getColumn(),
      InlinedAtNode->getScope(), InlinedAtNode->getInlinedAt());
  DenseMap<const MDNode *, MDNode *> IANodes;
  for (; FI != Fn->end(); ++FI) {
    for (BasicBlock::iterator BI = FI->begin(), BE = FI->end();
         BI != BE; ++BI) {
      if (MDNode *LoopID = BI->getMetadata(LLVMContext::MD_loop)) {
        MDNode *NewLoopID =
            inlineLoopID(LoopID, InlinedAtNode, BI->getContext(), IANodes);
        BI->setMetadata(LLVMContext::MD_loop, NewLoopID);
      }
      if (DebugLoc DL = BI->getDebugLoc()) {
        DebugLoc IDL =
            inlineDebugLoc(DL, InlinedAtNode, BI->getContext(), IANodes);
        BI->setDebugLoc(IDL);
        continue;
      }
      if (CalleeHasDebugInfo)
        continue;
      if (auto *AI = dyn_cast<AllocaInst>(BI))
        if (allocaWouldBeStaticInEntry(AI))
          continue;
      BI->setDebugLoc(TheCallDL);
    }
  }
}
static void fixupLineNumbers ( Function * Fn , Function :: iterator FI , Instruction * TheCall , bool CalleeHasDebugInfo ) { const DebugLoc & TheCallDL = TheCall -> getDebugLoc ( ) ; if ( ! TheCallDL ) return ; auto & Ctx = Fn -> getContext ( ) ; DILocation * InlinedAtNode = TheCallDL ; InlinedAtNode = DILocation :: getDistinct ( Ctx , InlinedAtNode -> getLine ( ) , InlinedAtNode -> getColumn ( ) , InlinedAtNode -> getScope ( ) , InlinedAtNode -> getInlinedAt ( ) ) ; DenseMap < const MDNode * , MDNode * > IANodes ; for ( ; FI != Fn -> end ( ) ; ++ FI ) { for ( BasicBlock :: iterator BI = FI -> begin ( ) , BE = FI -> end ( ) ; BI != BE ; ++ BI ) { if ( MDNode * LoopID = BI -> getMetadata ( LLVMContext :: MD_loop ) ) { MDNode * NewLoopID = inlineLoopID ( LoopID , InlinedAtNode , BI -> getContext ( ) , IANodes ) ; BI -> setMetadata ( LLVMContext :: MD_loop , NewLoopID ) ; } if ( DebugLoc DL = BI -> getDebugLoc ( ) ) { DebugLoc IDL = inlineDebugLoc ( DL , InlinedAtNode , BI -> getContext ( ) , IANodes ) ; BI -> setDebugLoc ( IDL ) ; continue ; } if ( CalleeHasDebugInfo ) continue ; if ( auto * AI = dyn_cast < AllocaInst > ( BI ) ) if ( allocaWouldBeStaticInEntry ( AI ) ) continue ; BI -> setDebugLoc ( TheCallDL ) ; } } }
Update inlined instructions' line numbers to
to encode location where these instructions are inlined.
Update inlined instructions ' line numbers to to encode location where these instructions are inlined .
// Create a unique call site, not to be confused with any other call from the // same location. // Cache the inlined-at nodes as they're built so they are reused, without // this every instruction's inlined-at chain would become distinct from each // other. // Loop metadata needs to be updated so that the start and end locs // reference inlined-at locations. // If the inlined instruction has no line number, make it look as if it // originates from the call location. This is important for // ((__always_inline__, __nodebug__)) functions which must use caller // location for all instructions in their function body. // Don't update static allocas, as they may get moved later.