Use use_iterator::getOperandNo instead of CallSite::hasArgument to check if a
authorMatthijs Kooijman <matthijs@stdin.nl>
Thu, 5 Jun 2008 08:34:25 +0000 (08:34 +0000)
committerMatthijs Kooijman <matthijs@stdin.nl>
Thu, 5 Jun 2008 08:34:25 +0000 (08:34 +0000)
function is passed as an argument instead of called. Also do this check a bit
earlier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51990 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/DeadArgumentElimination.cpp

index 2f075ba30dc99c1b278fff0d89e0cf52b71560c0..604a1483c45412bab3a7650648ee25fd98989772 100644 (file)
@@ -302,6 +302,12 @@ void DAE::SurveyFunction(Function &F) {
     FunctionIntrinsicallyLive = true;
   else
     for (Value::use_iterator I = F.use_begin(), E = F.use_end(); I != E; ++I) {
+      // If the function is PASSED IN as an argument, its address has been taken
+      if (I.getOperandNo() != 0) {
+        FunctionIntrinsicallyLive = true;
+        break;
+      }
+
       // If this use is anything other than a call site, the function is alive.
       CallSite CS = CallSite::get(*I);
       Instruction *TheCall = CS.getInstruction();
@@ -329,13 +335,6 @@ void DAE::SurveyFunction(Function &F) {
             RetValLiveness = Live;
             break;
           }
-
-      // If the function is PASSED IN as an argument, its address has been taken
-      
-      if (CS.hasArgument(&F)) {
-        FunctionIntrinsicallyLive = true;
-        break;
-      }
     }
 
   if (FunctionIntrinsicallyLive) {