summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-11-15 06:10:55 +0000
committerChris Lattner <sabre@nondot.org>2007-11-15 06:10:55 +0000
commit0841c3b560c5bab842fb4ee552ad8ecafe199376 (patch)
treebbd05f4904bbabe344275e1774f835ba7346fded /llvm/lib/Transforms
parent820c1447b4b04a3e0039f5fe3348aa3c858860dc (diff)
downloadbcm5719-llvm-0841c3b560c5bab842fb4ee552ad8ecafe199376.tar.gz
bcm5719-llvm-0841c3b560c5bab842fb4ee552ad8ecafe199376.zip
Fix PR1788 by taking the approach suggested by Richard Smith.
Thanks to him for his detailed analysis of the problem. llvm-svn: 44162
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 8dd09256136..3d345eefaa1 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -604,23 +604,28 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
}
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 @@ bool DAE::runOnModule(Module &M) {
// 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.
OpenPOWER on IntegriCloud