liberty/lib/Utilities/InlineFunctionWithVmap.cpp
/// Returns the LoopID for a loop which has has been cloned from another
/// function for inlining with the new inlined-at start and end locs.
Returns the LoopID for a loop which has has been cloned from another
function for inlining with the new inlined-at start and end locs.
Returns the LoopID for a loop which has has been cloned from another function for inlining with the new inlined - at start and end locs .
static MDNode *inlineLoopID(const MDNode *OrigLoopId, DILocation *InlinedAt,
                            LLVMContext &Ctx,
                            DenseMap<const MDNode *, MDNode *> &IANodes) {
  assert(OrigLoopId && OrigLoopId->getNumOperands() > 0 &&
         "Loop ID needs at least one operand");
  assert(OrigLoopId && OrigLoopId->getOperand(0).get() == OrigLoopId &&
         "Loop ID should refer to itself");
  SmallVector<Metadata *, 4> MDs = {nullptr};
  for (unsigned i = 1; i < OrigLoopId->getNumOperands(); ++i) {
    Metadata *MD = OrigLoopId->getOperand(i);
    if (DILocation *DL = dyn_cast<DILocation>(MD))
      MDs.push_back(inlineDebugLoc(DL, InlinedAt, Ctx, IANodes));
    else
      MDs.push_back(MD);
  }
  MDNode *NewLoopID = MDNode::getDistinct(Ctx, MDs);
  NewLoopID->replaceOperandWith(0, NewLoopID);
  return NewLoopID;
}
static MDNode * inlineLoopID ( const MDNode * OrigLoopId , DILocation * InlinedAt , LLVMContext & Ctx , DenseMap < const MDNode * , MDNode * > & IANodes ) { assert ( OrigLoopId && OrigLoopId -> getNumOperands ( ) > 0 && " " ) ; assert ( OrigLoopId && OrigLoopId -> getOperand ( 0 ) . get ( ) == OrigLoopId && " " ) ; SmallVector < Metadata * , 4 > MDs = { nullptr } ; for ( unsigned i = 1 ; i < OrigLoopId -> getNumOperands ( ) ; ++ i ) { Metadata * MD = OrigLoopId -> getOperand ( i ) ; if ( DILocation * DL = dyn_cast < DILocation > ( MD ) ) MDs . push_back ( inlineDebugLoc ( DL , InlinedAt , Ctx , IANodes ) ) ; else MDs . push_back ( MD ) ; } MDNode * NewLoopID = MDNode :: getDistinct ( Ctx , MDs ) ; NewLoopID -> replaceOperandWith ( 0 , NewLoopID ) ; return NewLoopID ; }
Returns the LoopID for a loop which has has been cloned from another
function for inlining with the new inlined-at start and end locs.
Returns the LoopID for a loop which has has been cloned from another function for inlining with the new inlined - at start and end locs .
// Save space for the self-referential LoopID. // Update the DILocations to encode the inlined-at metadata. // Insert the self-referential LoopID.