From 5d3c145d4ed614db56de4c1cb03d16b3202e4eea Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 18 Jun 2003 16:25:51 +0000 Subject: [PATCH] Handle arguments passed in through the va_arg area llvm-svn: 6769 --- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index f1599c361ff5..ad4e0e2b8158 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -79,7 +79,13 @@ static ArgumentLiveness getArgumentLiveness(const Argument &A) { Function *Callee = CS.getCalledFunction(); if (!Callee) return Alive; - // FIXME: check to see if it's passed through a va_arg area + // Check to see if it's passed through a va_arg area: if so, we cannot + // remove it. + unsigned NumFixedArgs = Callee->getFunctionType()->getNumParams(); + for (CallSite::arg_iterator AI = CS.arg_begin()+NumFixedArgs; + AI != CS.arg_end(); ++AI) + if (AI->get() == &A) // If passed through va_arg area, we cannot remove it + return Alive; } return MaybeLive; // It must be used, but only as argument to a function