[llvm-commits] [llvm] r47396 - /llvm/trunk/lib/VMCore/Instructions.cpp

Devang Patel dpatel at apple.com
Wed Feb 20 11:39:41 PST 2008


Author: dpatel
Date: Wed Feb 20 13:39:41 2008
New Revision: 47396

URL: http://llvm.org/viewvc/llvm-project?rev=47396&view=rev
Log:
getresult does not support nested aggregates.

Modified:
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=47396&r1=47395&r2=47396&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Feb 20 13:39:41 2008
@@ -2719,10 +2719,21 @@
 bool GetResultInst::isValidOperands(const Value *Aggregate, unsigned Index) {
   if (!Aggregate)
     return false;
-  if (const StructType *STy = dyn_cast<StructType>(Aggregate->getType())) 
-    if (Index < STy->getNumElements())
-      return true;
 
+  if (const StructType *STy = dyn_cast<StructType>(Aggregate->getType())) {
+    unsigned NumElements = STy->getNumElements();
+    if (Index >= NumElements)
+      return false;
+
+    // getresult aggregate value's element types are restricted to
+    // avoid nested aggregates.
+    for (unsigned i = 0; i < NumElements; ++i)
+      if (!STy->getElementType(i)->isFirstClassType())
+        return false;
+
+    // Otherwise, Aggregate is valid.
+    return true;
+  }
   return false;
 }
 





More information about the llvm-commits mailing list