[llvm-commits] [llvm] r44162 - /llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
Chris Lattner
sabre at nondot.org
Wed Nov 14 22:10:55 PST 2007
Author: lattner
Date: Thu Nov 15 00:10:55 2007
New Revision: 44162
URL: http://llvm.org/viewvc/llvm-project?rev=44162&view=rev
Log:
Fix PR1788 by taking the approach suggested by Richard Smith.
Thanks to him for his detailed analysis of the problem.
Modified:
llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=44162&r1=44161&r2=44162&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Thu Nov 15 00:10:55 2007
@@ -604,23 +604,28 @@
}
bool DAE::runOnModule(Module &M) {
- // First phase: loop through the module, determining which arguments are live.
- // We assume all arguments are dead unless proven otherwise (allowing us to
- // determine that dead arguments passed into recursive functions are dead).
- //
- DOUT << "DAE - Determining liveness\n";
+ bool Changed = false;
+ // First pass: Do a simple check to see if any functions can have their "..."
+ // removed. We can do this if they never call va_start. This loop cannot be
+ // fused with the next loop, because deleting a function invalidates
+ // information computed while surveying other functions.
+ DOUT << "DAE - Deleting dead varargs\n";
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
Function &F = *I++;
if (F.getFunctionType()->isVarArg())
- if (DeleteDeadVarargs(F))
- continue;
-
- SurveyFunction(F);
+ Changed |= DeleteDeadVarargs(F);
}
+
+ // Second phase:loop through the module, determining which arguments are live.
+ // We assume all arguments are dead unless proven otherwise (allowing us to
+ // determine that dead arguments passed into recursive functions are dead).
+ //
+ DOUT << "DAE - Determining liveness\n";
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
+ SurveyFunction(*I);
// Loop over the instructions to inspect, propagating liveness among arguments
// and return values which are MaybeLive.
-
while (!InstructionsToInspect.empty()) {
Instruction *I = InstructionsToInspect.back();
InstructionsToInspect.pop_back();
@@ -680,7 +685,7 @@
// to do.
if (MaybeLiveArguments.empty() && DeadArguments.empty() &&
MaybeLiveRetVal.empty() && DeadRetVal.empty())
- return false;
+ return Changed;
// Otherwise, compact into one set, and start eliminating the arguments from
// the functions.
More information about the llvm-commits
mailing list