From: Rafael Espindola Date: Fri, 5 Dec 2014 21:04:36 +0000 (+0000) Subject: Simplify the loop linking function bodies. NFC. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28a2451b35bde35c09a28ef608a73c6da2bd8333;p=platform%2Fupstream%2Fllvm.git Simplify the loop linking function bodies. NFC. llvm-svn: 223512 --- diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 1d4dae4..c7cf9f6 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -1514,48 +1514,32 @@ bool ModuleLinker::run() { linkGlobalInits(); // Process vector of lazily linked in functions. - bool LinkedInAnyFunctions; - do { - LinkedInAnyFunctions = false; - - for(std::vector::iterator I = LazilyLinkFunctions.begin(), - E = LazilyLinkFunctions.end(); I != E; ++I) { - Function *SF = *I; - if (!SF) - continue; - - Function *DF = cast(ValueMap[SF]); - if (SF->hasPrefixData()) { - // Link in the prefix data. - DF->setPrefixData(MapValue(SF->getPrefixData(), - ValueMap, - RF_None, - &TypeMap, - &ValMaterializer)); - } + while (!LazilyLinkFunctions.empty()) { + Function *SF = LazilyLinkFunctions.back(); + LazilyLinkFunctions.pop_back(); - // Materialize if needed. - if (std::error_code EC = SF->materialize()) - return emitError(EC.message()); + if (!SF) + continue; - // Skip if no body (function is external). - if (SF->isDeclaration()) - continue; + Function *DF = cast(ValueMap[SF]); + if (SF->hasPrefixData()) { + // Link in the prefix data. + DF->setPrefixData(MapValue(SF->getPrefixData(), ValueMap, RF_None, + &TypeMap, &ValMaterializer)); + } - // Erase from vector *before* the function body is linked - linkFunctionBody could - // invalidate I. - LazilyLinkFunctions.erase(I); + // Materialize if needed. + if (std::error_code EC = SF->materialize()) + return emitError(EC.message()); - // Link in function body. - linkFunctionBody(DF, SF); - SF->Dematerialize(); + // Skip if no body (function is external). + if (SF->isDeclaration()) + continue; - // Set flag to indicate we may have more functions to lazily link in - // since we linked in a function. - LinkedInAnyFunctions = true; - break; - } - } while (LinkedInAnyFunctions); + // Link in function body. + linkFunctionBody(DF, SF); + SF->Dematerialize(); + } return false; }