Example #1
0
// Insert a ComparableFunction into the FnSet, or merge it away if equal to one
// that was already inserted.
bool MergeFunctions::insert(ComparableFunction &NewF) {
  std::pair<FnSetType::iterator, bool> Result = FnSet.insert(NewF);
  if (Result.second) {
    DEBUG(dbgs() << "Inserting as unique: " << NewF.getFunc()->getName() << '\n');
    return false;
  }

  const ComparableFunction &OldF = *Result.first;

  // Don't merge tiny functions, since it can just end up making the function
  // larger.
  // FIXME: Should still merge them if they are unnamed_addr and produce an
  // alias.
  if (NewF.getFunc()->size() == 1) {
    if (NewF.getFunc()->front().size() <= 2) {
      DEBUG(dbgs() << NewF.getFunc()->getName()
            << " is to small to bother merging\n");
      return false;
    }
  }

  // Never thunk a strong function to a weak function.
  assert(!OldF.getFunc()->mayBeOverridden() ||
         NewF.getFunc()->mayBeOverridden());

  DEBUG(dbgs() << "  " << OldF.getFunc()->getName() << " == "
               << NewF.getFunc()->getName() << '\n');

  Function *DeleteF = NewF.getFunc();
  NewF.release();
  mergeTwoFunctions(OldF.getFunc(), DeleteF);
  return true;
}
Example #2
0
// Insert - Insert a ComparableFunction into the FnSet, or merge it away if
// equal to one that's already inserted.
bool MergeFunctions::Insert(FnSetType &FnSet, ComparableFunction &NewF) {
  std::pair<FnSetType::iterator, bool> Result = FnSet.insert(NewF);
  if (Result.second)
    return false;

  const ComparableFunction &OldF = *Result.first;

  // Never thunk a strong function to a weak function.
  assert(!OldF.getFunc()->mayBeOverridden() ||
         NewF.getFunc()->mayBeOverridden());

  DEBUG(dbgs() << "  " << OldF.getFunc()->getName() << " == "
               << NewF.getFunc()->getName() << '\n');

  Function *DeleteF = NewF.getFunc();
  NewF.release();
  MergeTwoFunctions(OldF.getFunc(), DeleteF);
  return true;
}
Example #3
0
bool DenseMapInfo<ComparableFunction>::isEqual(const ComparableFunction &LHS,
                                               const ComparableFunction &RHS) {
  if (LHS.getFunc() == RHS.getFunc() &&
      LHS.getHash() == RHS.getHash())
    return true;
  if (!LHS.getFunc() || !RHS.getFunc())
    return false;

  // One of these is a special "underlying pointer comparison only" object.
  if (LHS.getDataLayout() == ComparableFunction::LookupOnly ||
      RHS.getDataLayout() == ComparableFunction::LookupOnly)
    return false;

  assert(LHS.getDataLayout() == RHS.getDataLayout() &&
         "Comparing functions for different targets");

  return FunctionComparator(LHS.getDataLayout(), LHS.getFunc(),
                            RHS.getFunc()).compare();
}
Example #4
0
 static unsigned getHashValue(const ComparableFunction &CF) {
   return CF.getHash();
 }
Example #5
0
bool DenseMapInfo<ComparableFunction>::isEqual(const ComparableFunction &LHS,
                                               const ComparableFunction &RHS) {
  if (LHS.getFunc() == RHS.getFunc() &&
      LHS.getHash() == RHS.getHash())
    return true;
  if (!LHS.getFunc() || !RHS.getFunc())
    return false;
  assert(LHS.getTD() == RHS.getTD() &&
         "Comparing functions for different targets");
  return FunctionComparator(LHS.getTD(),
                            LHS.getFunc(), RHS.getFunc()).Compare();
}