[llvm-commits] CVS: llvm/lib/Transforms/IPO/FunctionResolution.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Nov 9 21:38:02 PST 2002
Changes in directory llvm/lib/Transforms/IPO:
FunctionResolution.cpp updated: 1.15 -> 1.16
---
Log message:
Fix testcase: FunctionResolve/2002-11-09-ExternFn.ll
---
Diffs of the changes:
Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.15 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.16
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.15 Thu Nov 7 18:38:20 2002
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp Sat Nov 9 21:36:55 2002
@@ -130,8 +130,8 @@
//
for (unsigned i = 0; i < OldMT->getParamTypes().size(); ++i)
if (OldMT->getParamTypes()[i] != ConcreteMT->getParamTypes()[i]) {
- cerr << "Parameter types conflict for" << OldMT
- << " and " << ConcreteMT;
+ cerr << "Parameter types conflict for: '" << OldMT
+ << "' and '" << ConcreteMT << "'\n";
return Changed;
}
@@ -231,31 +231,24 @@
return false; // Don't know how to handle this, bail out!
}
- // Ignore globals that are never used so they don't cause spurious
- // warnings... here we will actually DCE the function so that it isn't used
- // later.
- //
- if (Globals[i]->isExternal() && Globals[i]->use_empty()) {
- if (isFunction) {
- M.getFunctionList().erase(cast<Function>(Globals[i]));
- ++NumResolved;
- } else {
- M.getGlobalList().erase(cast<GlobalVariable>(Globals[i]));
- ++NumGlobals;
- }
-
- Globals.erase(Globals.begin()+i);
- Changed = true;
- } else if (isFunction) {
+ if (isFunction) {
// For functions, we look to merge functions definitions of "int (...)"
// to 'int (int)' or 'int ()' or whatever else is not completely generic.
//
Function *F = cast<Function>(Globals[i]);
if (!F->isExternal()) {
- if (Concrete)
+ if (Concrete && !Concrete->isExternal())
return false; // Found two different functions types. Can't choose!
Concrete = Globals[i];
+ } else if (Concrete) {
+ if (Concrete->isExternal()) // If we have multiple external symbols...x
+ if (F->getFunctionType()->getNumParams() >
+ cast<Function>(Concrete)->getFunctionType()->getNumParams())
+ Concrete = F; // We are more concrete than "Concrete"!
+
+ } else {
+ Concrete = F;
}
++i;
} else {
@@ -341,6 +334,31 @@
for (std::map<string, vector<GlobalValue*> >::iterator I = Globals.begin(),
E = Globals.end(); I != E; ++I)
Changed |= ProcessGlobalsWithSameName(M, I->second);
+
+ // Now loop over all of the globals, checking to see if any are trivially
+ // dead. If so, remove them now.
+
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; )
+ if (I->isExternal() && I->use_empty()) {
+ Function *F = I;
+ ++I;
+ M.getFunctionList().erase(F);
+ ++NumResolved;
+ Changed = true;
+ } else {
+ ++I;
+ }
+
+ for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; )
+ if (I->isExternal() && I->use_empty()) {
+ GlobalVariable *GV = I;
+ ++I;
+ M.getGlobalList().erase(GV);
+ ++NumGlobals;
+ Changed = true;
+ } else {
+ ++I;
+ }
return Changed;
}
More information about the llvm-commits
mailing list