diff options
author | Chris Lattner <sabre@nondot.org> | 2001-11-03 10:04:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-11-03 10:04:22 +0000 |
commit | 055c963f5888bd7dc6241f84791abf2146df06d6 (patch) | |
tree | edf25732a8fb392cf59f4450efbfa315b1cd42ec | |
parent | b6b26921e3a6e0375b76e17e67d8a87dc34bda58 (diff) | |
download | external_llvm-055c963f5888bd7dc6241f84791abf2146df06d6.zip external_llvm-055c963f5888bd7dc6241f84791abf2146df06d6.tar.gz external_llvm-055c963f5888bd7dc6241f84791abf2146df06d6.tar.bz2 |
Changes to compile the TSP benchmark successfully. Favor warning instead of assertion failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1103 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index a8f6470..13cc8d9 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -150,13 +150,17 @@ static bool PatchUpMethodReferences(SymbolTable *ST) { Method *Concrete = 0; for (unsigned i = 0; i < Methods.size(); ++i) { if (!Methods[i]->isExternal()) { // Found an implementation - assert(Concrete == 0 && "Multiple definitions of the same method. " - "Case not handled yet!"); + assert(Implementation == 0 && "Multiple definitions of the same" + " method. Case not handled yet!"); Implementation = Methods[i]; } - if (!Methods[i]->getMethodType()->isVarArg()) { - assert(Concrete == 0 && "Multiple concrete method types!"); + if (!Methods[i]->getMethodType()->isVarArg() || + Methods[i]->getMethodType()->getParamTypes().size()) { + if (Concrete) { // Found two different methods types. Can't choose + Concrete = 0; + break; + } Concrete = Methods[i]; } } @@ -165,44 +169,53 @@ static bool PatchUpMethodReferences(SymbolTable *ST) { // probably the implementation. Change all of the method definitions // and uses to use it instead. // - assert(Concrete && "Multiple varargs defns found?"); - for (unsigned i = 0; i < Methods.size(); ++i) - if (Methods[i] != Concrete) { - Method *Old = Methods[i]; - assert(Old->getReturnType() == Concrete->getReturnType() && - "Differing return types not handled yet!"); - assert(Old->getMethodType()->getParamTypes().size() == 0 && - "Cannot handle varargs fn's with specified element types!"); - - // Attempt to convert all of the uses of the old method to the - // concrete form of the method. If there is a use of the method that - // we don't understand here we punt to avoid making a bad - // transformation. - // - // At this point, we know that the return values are the same for our - // two functions and that the Old method has no varargs methods - // specified. In otherwords it's just <retty> (...) - // - for (unsigned i = 0; i < Old->use_size(); ) { - User *U = *(Old->use_begin()+i); - if (CastInst *CI = dyn_cast<CastInst>(U)) { - // Convert casts directly - assert(CI->getOperand(0) == Old); - CI->setOperand(0, Concrete); - Changed = true; - } else if (CallInst *CI = dyn_cast<CallInst>(U)) { - // Can only fix up calls TO the argument, not args passed in. - if (CI->getCalledValue() == Old) { - ConvertCallTo(CI, Concrete); + if (!Concrete) { + cerr << "Warning: Found methods types that are not compatible:\n"; + for (unsigned i = 0; i < Methods.size(); ++i) { + cerr << "\t" << Methods[i]->getType()->getDescription() << " %" + << Methods[i]->getName() << endl; + } + cerr << " No linkage of methods named '" << Methods[0]->getName() + << "' performed!\n"; + } else { + for (unsigned i = 0; i < Methods.size(); ++i) + if (Methods[i] != Concrete) { + Method *Old = Methods[i]; + assert(Old->getReturnType() == Concrete->getReturnType() && + "Differing return types not handled yet!"); + assert(Old->getMethodType()->getParamTypes().size() == 0 && + "Cannot handle varargs fn's with specified element types!"); + + // Attempt to convert all of the uses of the old method to the + // concrete form of the method. If there is a use of the method + // that we don't understand here we punt to avoid making a bad + // transformation. + // + // At this point, we know that the return values are the same for + // our two functions and that the Old method has no varargs methods + // specified. In otherwords it's just <retty> (...) + // + for (unsigned i = 0; i < Old->use_size(); ) { + User *U = *(Old->use_begin()+i); + if (CastInst *CI = dyn_cast<CastInst>(U)) { + // Convert casts directly + assert(CI->getOperand(0) == Old); + CI->setOperand(0, Concrete); Changed = true; + } else if (CallInst *CI = dyn_cast<CallInst>(U)) { + // Can only fix up calls TO the argument, not args passed in. + if (CI->getCalledValue() == Old) { + ConvertCallTo(CI, Concrete); + Changed = true; + } else { + cerr << "Couldn't cleanup this function call, must be an" + << " argument or something!" << CI; + ++i; + } } else { - cerr << "Couldn't cleanup this function call, must be an" - << " argument or something!" << CI; + cerr << "Cannot convert use of method: " << U << endl; ++i; } - } else { - cerr << "Cannot convert use of method: " << U << endl; - ++i; } } } |