diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /lib/Transforms/IPO/DeadArgumentElimination.cpp | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'lib/Transforms/IPO/DeadArgumentElimination.cpp')
-rw-r--r-- | lib/Transforms/IPO/DeadArgumentElimination.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index ac3853d..4045c09 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -199,10 +199,15 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { return false; // Okay, we know we can transform this function if safe. Scan its body - // looking for calls to llvm.vastart. + // looking for calls marked musttail or calls to llvm.vastart. for (Function::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { - if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) { + CallInst *CI = dyn_cast<CallInst>(I); + if (!CI) + continue; + if (CI->isMustTailCall()) + return false; + if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI)) { if (II->getIntrinsicID() == Intrinsic::vastart) return false; } @@ -297,8 +302,14 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { // Patch the pointer to LLVM function in debug info descriptor. auto DI = FunctionDIs.find(&Fn); - if (DI != FunctionDIs.end()) - DI->second.replaceFunction(NF); + if (DI != FunctionDIs.end()) { + DISubprogram SP = DI->second; + SP.replaceFunction(NF); + // Ensure the map is updated so it can be reused on non-varargs argument + // eliminations of the same function. + FunctionDIs.erase(DI); + FunctionDIs[NF] = SP; + } // Fix up any BlockAddresses that refer to the function. Fn.replaceAllUsesWith(ConstantExpr::getBitCast(NF, Fn.getType())); @@ -1088,8 +1099,8 @@ bool DAE::runOnModule(Module &M) { // determine that dead arguments passed into recursive functions are dead). // DEBUG(dbgs() << "DAE - Determining liveness\n"); - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - SurveyFunction(*I); + for (auto &F : M) + SurveyFunction(F); // Now, remove all dead arguments and return values from each function in // turn. @@ -1102,11 +1113,8 @@ bool DAE::runOnModule(Module &M) { // Finally, look for any unused parameters in functions with non-local // linkage and replace the passed in parameters with undef. - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { - Function& F = *I; - + for (auto &F : M) Changed |= RemoveDeadArgumentsFromCallers(F); - } return Changed; } |