aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-06-18 16:25:51 +0000
committerChris Lattner <sabre@nondot.org>2003-06-18 16:25:51 +0000
commit97f4b664cd8a537cd2bf37b6a9d06a174078e947 (patch)
tree1a85440017033d7d85eabd4ddeab1ae20097f4ca
parentc8621e6f28c1ebd026e0931ed9afeffdbe5eb04d (diff)
Handle arguments passed in through the va_arg area
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6769 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index f1599c361f..ad4e0e2b81 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/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