teach Value::isDereferenceablePointer that byval arguments are always
authorChris Lattner <sabre@nondot.org>
Sun, 23 Jan 2011 21:15:29 +0000 (21:15 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 23 Jan 2011 21:15:29 +0000 (21:15 +0000)
dereferencable, noticed by inspection.

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

lib/VMCore/Value.cpp

index 38438265dd62fb2966e0b522db9d64f545d23801..29f6a8094f0bb258888e060b455c5e8ecc2e2538 100644 (file)
@@ -363,6 +363,10 @@ bool Value::isDereferenceablePointer() const {
   if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
     return !GV->hasExternalWeakLinkage();
 
+  // byval arguments are ok.
+  if (const Argument *A = dyn_cast<Argument>(this))
+    return A->hasByValAttr();
+  
   // For GEPs, determine if the indexing lands within the allocated object.
   if (const GEPOperator *GEP = dyn_cast<GEPOperator>(this)) {
     // Conservatively require that the base pointer be fully dereferenceable.