Exemple #1
0
void ModuleLinker::linkAliasBodies() {
  for (Module::alias_iterator I = SrcM->alias_begin(), E = SrcM->alias_end();
       I != E; ++I) {
    if (DoNotLinkFromSource.count(I))
      continue;
    if (Constant *Aliasee = I->getAliasee()) {
      GlobalAlias *DA = cast<GlobalAlias>(ValueMap[I]);
      DA->setAliasee(MapValue(Aliasee, ValueMap, RF_None, &TypeMap));
    }
  }
}
Exemple #2
0
//
// Method: runOnModule()
//
// Description:
//  Entry point for this LLVM pass.
//  Replace all internal aliases with the
//  aliasee value
//
// Inputs:
//  M - A reference to the LLVM module to transform
//
// Outputs:
//  M - The transformed LLVM module.
//
// Return value:
//  true  - The module was modified.
//  false - The module was not modified.
//
bool FuncSimplify::runOnModule(Module& M) {

  std::vector<GlobalAlias*> toDelete;
  for (Module::alias_iterator I = M.alias_begin(); I != M.alias_end(); ++I) {
    if(!I->hasInternalLinkage())
      continue;
    I->replaceAllUsesWith(I->getAliasee());
    toDelete.push_back(I);
  }
  numChanged += toDelete.size();

  while(!toDelete.empty()) {
    GlobalAlias *I = toDelete.back();
    toDelete.pop_back();
    I->eraseFromParent();
  }


  return true;
}