Fix an abort on a store of an empty struct member. getValue returns

null in the case of an empty struct, so don't try to call getNumValues
on it.

llvm-svn: 81180
This commit is contained in:
Dan Gohman 2009-09-08 01:44:02 +00:00
parent b2b0467e18
commit f4a0f0f033
2 changed files with 18 additions and 0 deletions

View File

@ -861,6 +861,10 @@ SDValue SelectionDAGLowering::getValue(const Value *V) {
for (User::const_op_iterator OI = C->op_begin(), OE = C->op_end();
OI != OE; ++OI) {
SDNode *Val = getValue(*OI).getNode();
// If the operand is an empty aggregate, there are no values.
if (!Val) continue;
// Add each leaf value from the operand to the Constants list
// to form a flattened list of all the values.
for (unsigned i = 0, e = Val->getNumValues(); i != e; ++i)
Constants.push_back(SDValue(Val, i));
}

View File

@ -0,0 +1,14 @@
; RUN: llvm-as < %s | llc -march=x86 | FileCheck %s
; Don't crash on an empty struct member.
; CHECK: movl $2, 4(%esp)
; CHECK: movl $1, (%esp)
%testType = type {i32, [0 x i32], i32}
define void @foo() nounwind {
%1 = alloca %testType
volatile store %testType {i32 1, [0 x i32] zeroinitializer, i32 2}, %testType* %1
ret void
}