lib/Analysis/BasicAliasAnalysis.cpp
void BasicAAResult::GetIndexDifference(
    SmallVectorImpl<VariableGEPIndex> &Dest,
    const SmallVectorImpl<VariableGEPIndex> &Src) {
  if (Src.empty())
    return;

  for (unsigned i = 0, e = Src.size(); i != e; ++i) {
    const Value *V = Src[i].V;
    unsigned ZExtBits = Src[i].ZExtBits, SExtBits = Src[i].SExtBits;
    APInt Scale = Src[i].Scale;

    // Find V in Dest.  This is N^2, but pointer indices almost never have more
    // than a few variable indexes.
    for (unsigned j = 0, e = Dest.size(); j != e; ++j) {
      if (!isValueEqualInPotentialCycles(Dest[j].V, V) ||
          Dest[j].ZExtBits != ZExtBits || Dest[j].SExtBits != SExtBits)
        continue;

      // If we found it, subtract off Scale V's from the entry in Dest.  If it
      // goes to zero, remove the entry.
      if (Dest[j].Scale != Scale)
        Dest[j].Scale -= Scale;
      else
        Dest.erase(Dest.begin() + j);
      Scale = 0;
      break;
    }

    // If we didn't consume this entry, add it to the end of the Dest list.
    if (!!Scale) {
      VariableGEPIndex Entry = {V, ZExtBits, SExtBits, -Scale, Src[i].CxtI};
      Dest.push_back(Entry);
    }
  }
}
/// Computes the symbolic difference between two de-composed GEPs.
///
/// Dest and Src are the variable indices from two decomposed GetElementPtr
/// instructions GEP1 and GEP2 which have common base pointers.
Computes the symbolic difference between two de-composed GEPs.
Dest and Src are the variable indices from two decomposed GetElementPtr
instructions GEP1 and GEP2 which have common base pointers.
Computes the symbolic difference between two de - composed GEPs . Dest and Src are the variable indices from two decomposed GetElementPtr instructions GEP1 and GEP2 which have common base pointers .
void BasicAAResult::GetIndexDifference(
    SmallVectorImpl<VariableGEPIndex> &Dest,
    const SmallVectorImpl<VariableGEPIndex> &Src) {
  if (Src.empty())
    return;
  for (unsigned i = 0, e = Src.size(); i != e; ++i) {
    const Value *V = Src[i].V;
    unsigned ZExtBits = Src[i].ZExtBits, SExtBits = Src[i].SExtBits;
    APInt Scale = Src[i].Scale;
    for (unsigned j = 0, e = Dest.size(); j != e; ++j) {
      if (!isValueEqualInPotentialCycles(Dest[j].V, V) ||
          Dest[j].ZExtBits != ZExtBits || Dest[j].SExtBits != SExtBits)
        continue;
      if (Dest[j].Scale != Scale)
        Dest[j].Scale -= Scale;
      else
        Dest.erase(Dest.begin() + j);
      Scale = 0;
      break;
    }
    if (!!Scale) {
      VariableGEPIndex Entry = {V, ZExtBits, SExtBits, -Scale, Src[i].CxtI};
      Dest.push_back(Entry);
    }
  }
}
void BasicAAResult :: GetIndexDifference ( SmallVectorImpl < VariableGEPIndex > & Dest , const SmallVectorImpl < VariableGEPIndex > & Src ) { if ( Src . empty ( ) ) return ; for ( unsigned i = 0 , e = Src . size ( ) ; i != e ; ++ i ) { const Value * V = Src [ i ] . V ; unsigned ZExtBits = Src [ i ] . ZExtBits , SExtBits = Src [ i ] . SExtBits ; APInt Scale = Src [ i ] . Scale ; for ( unsigned j = 0 , e = Dest . size ( ) ; j != e ; ++ j ) { if ( ! isValueEqualInPotentialCycles ( Dest [ j ] . V , V ) || Dest [ j ] . ZExtBits != ZExtBits || Dest [ j ] . SExtBits != SExtBits ) continue ; if ( Dest [ j ] . Scale != Scale ) Dest [ j ] . Scale -= Scale ; else Dest . erase ( Dest . begin ( ) + j ) ; Scale = 0 ; break ; } if ( ! ! Scale ) { VariableGEPIndex Entry = { V , ZExtBits , SExtBits , - Scale , Src [ i ] . CxtI } ; Dest . push_back ( Entry ) ; } } }
Computes the symbolic difference between two de-composed GEPs.
Computes the symbolic difference between two de - composed GEPs .
// Find V in Dest.  This is N^2, but pointer indices almost never have more // than a few variable indexes. // If we found it, subtract off Scale V's from the entry in Dest.  If it // goes to zero, remove the entry. // If we didn't consume this entry, add it to the end of the Dest list.