using namespace llvm;
namespace {
- Statistic<>NumResolved("funcresolve", "Number of varargs functions resolved");
- Statistic<> NumGlobals("funcresolve", "Number of global variables resolved");
+ Statistic NumResolved("funcresolve", "Number of varargs functions resolved");
+ Statistic NumGlobals("funcresolve", "Number of global variables resolved");
struct FunctionResolvingPass : public ModulePass {
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
bool runOnModule(Module &M);
};
- RegisterOpt<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
+ RegisterPass<FunctionResolvingPass> X("funcresolve", "Resolve Functions");
}
ModulePass *llvm::createFunctionResolvingPass() {
for (unsigned i = 0; i != Globals.size(); ++i)
if (Globals[i] != Concrete) {
Function *Old = cast<Function>(Globals[i]);
- const FunctionType *OldMT = Old->getFunctionType();
- const FunctionType *ConcreteMT = Concrete->getFunctionType();
+ const FunctionType *OldFT = Old->getFunctionType();
+ const FunctionType *ConcreteFT = Concrete->getFunctionType();
- if (OldMT->getNumParams() > ConcreteMT->getNumParams() &&
- !ConcreteMT->isVarArg())
+ if (OldFT->getNumParams() > ConcreteFT->getNumParams() &&
+ !ConcreteFT->isVarArg())
if (!Old->use_empty()) {
- std::cerr << "WARNING: Linking function '" << Old->getName()
- << "' is causing arguments to be dropped.\n";
- std::cerr << "WARNING: Prototype: ";
- WriteAsOperand(std::cerr, Old);
- std::cerr << " resolved to ";
- WriteAsOperand(std::cerr, Concrete);
- std::cerr << "\n";
+ cerr << "WARNING: Linking function '" << Old->getName()
+ << "' is causing arguments to be dropped.\n";
+ cerr << "WARNING: Prototype: ";
+ WriteAsOperand(*cerr.stream(), Old);
+ cerr << " resolved to ";
+ WriteAsOperand(*cerr.stream(), Concrete);
+ cerr << "\n";
}
// Check to make sure that if there are specified types, that they
// match...
//
- unsigned NumArguments = std::min(OldMT->getNumParams(),
- ConcreteMT->getNumParams());
+ unsigned NumArguments = std::min(OldFT->getNumParams(),
+ ConcreteFT->getNumParams());
if (!Old->use_empty() && !Concrete->use_empty())
for (unsigned i = 0; i < NumArguments; ++i)
- if (OldMT->getParamType(i) != ConcreteMT->getParamType(i))
- if (OldMT->getParamType(i)->getTypeID() !=
- ConcreteMT->getParamType(i)->getTypeID()) {
- std::cerr << "WARNING: Function [" << Old->getName()
- << "]: Parameter types conflict for: '";
- WriteTypeSymbolic(std::cerr, OldMT, &M);
- std::cerr << "' and '";
- WriteTypeSymbolic(std::cerr, ConcreteMT, &M);
- std::cerr << "'\n";
+ if (OldFT->getParamType(i) != ConcreteFT->getParamType(i))
+ if (OldFT->getParamType(i)->getTypeID() !=
+ ConcreteFT->getParamType(i)->getTypeID()) {
+ cerr << "WARNING: Function [" << Old->getName()
+ << "]: Parameter types conflict for: '";
+ WriteTypeSymbolic(*cerr.stream(), OldFT, &M);
+ cerr << "' (in "
+ << Old->getParent()->getModuleIdentifier() << ") and '";
+ WriteTypeSymbolic(*cerr.stream(), ConcreteFT, &M);
+ cerr << "'(in "
+ << Concrete->getParent()->getModuleIdentifier() << ")\n";
return Changed;
}
for (unsigned i = 0; i != Globals.size(); ) {
if (isa<Function>(Globals[i]) != isFunction) {
- std::cerr << "WARNING: Found function and global variable with the "
- << "same name: '" << Globals[i]->getName() << "'.\n";
+ cerr << "WARNING: Found function and global variable with the "
+ << "same name: '" << Globals[i]->getName() << "'.\n";
return false; // Don't know how to handle this, bail out!
}
GlobalVariable *GV = cast<GlobalVariable>(Globals[i]);
if (!GV->isExternal()) {
if (Concrete) {
- std::cerr << "WARNING: Two global variables with external linkage"
- << " exist with the same name: '" << GV->getName()
- << "'!\n";
+ cerr << "WARNING: Two global variables with external linkage"
+ << " exist with the same name: '" << GV->getName()
+ << "'!\n";
return false;
}
Concrete = GV;
}
if (0 && !DontPrintWarning) {
- std::cerr << "WARNING: Found global types that are not compatible:\n";
+ cerr << "WARNING: Found global types that are not compatible:\n";
for (unsigned i = 0; i < Globals.size(); ++i) {
- std::cerr << "\t";
- WriteTypeSymbolic(std::cerr, Globals[i]->getType(), &M);
- std::cerr << " %" << Globals[i]->getName() << "\n";
+ cerr << "\t";
+ WriteTypeSymbolic(*cerr.stream(), Globals[i]->getType(), &M);
+ cerr << " %" << Globals[i]->getName() << "\n";
}
}
Globals[F->getName()].push_back(F);
}
- for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ) {
+ for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+ I != E; ) {
GlobalVariable *GV = I++;
if (GV->use_empty() && GV->isExternal()) {
M.getGlobalList().erase(GV);
++I;
}
- for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; )
+ for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+ I != E; )
if (I->isExternal() && I->use_empty()) {
GlobalVariable *GV = I;
++I;