Teach FunctionAttrs about the VAArg instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118627 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index fcdc5f1..8bdf5d7 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -195,6 +195,13 @@
           if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
             continue;
         }
+      } else if (VAArgInst *VI = dyn_cast<VAArgInst>(I)) {
+        // Ignore vaargs on local memory.
+        AliasAnalysis::Location Loc(VI->getPointerOperand(),
+                                    AliasAnalysis::UnknownSize,
+                                    VI->getMetadata(LLVMContext::MD_tbaa));
+        if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
+          continue;
       }
 
       // Any remaining instructions need to be taken seriously!  Check if they