diff options
author | Devang Patel <dpatel@apple.com> | 2008-02-20 19:39:41 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-02-20 19:39:41 +0000 |
commit | dd4d45337b80ce73926e7a9ffc3b668da6d008f0 (patch) | |
tree | d444d2d4f1b081d770d27e11d3a6ac8495e4de4c | |
parent | 55574c2ceab1b7c4dd1cc47d2fb328bc3728d29c (diff) | |
download | external_llvm-dd4d45337b80ce73926e7a9ffc3b668da6d008f0.zip external_llvm-dd4d45337b80ce73926e7a9ffc3b668da6d008f0.tar.gz external_llvm-dd4d45337b80ce73926e7a9ffc3b668da6d008f0.tar.bz2 |
getresult does not support nested aggregates.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47396 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Instructions.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index c1e5833..4197f80 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2719,10 +2719,21 @@ GetResultInst::GetResultInst(Value *Aggregate, unsigned Index, 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; } |