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 | cf193b83204199e1621b2bf17e4ca322bc54e3e2 (patch) | |
tree | d20d8b4ee3122157b6fc8a2611f32a30ecb7fafa /llvm/lib/VMCore/Instructions.cpp | |
parent | cf2d1aa485e1164e28eb1aa2e258659f69b6b173 (diff) | |
download | bcm5719-llvm-cf193b83204199e1621b2bf17e4ca322bc54e3e2.tar.gz bcm5719-llvm-cf193b83204199e1621b2bf17e4ca322bc54e3e2.zip |
getresult does not support nested aggregates.
llvm-svn: 47396
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index c1e583375a2..4197f80c922 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/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; } |