fix asmwriting of ConstantDataArray to use the right element count,

simplify ConstantArray handling, since they can never be empty.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149341 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2012-01-31 03:15:40 +00:00
parent c8d75c78ec
commit 8b10b69ba2

View File

@ -837,19 +837,17 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
Out << '"';
} else { // Cannot output in string format...
Out << '[';
if (CA->getNumOperands()) {
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getOperand(0),
&TypePrinter, Machine,
Context);
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
Out << ", ";
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getOperand(0),
&TypePrinter, Machine,
WriteAsOperandInternal(Out, CA->getOperand(i), &TypePrinter, Machine,
Context);
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
Out << ", ";
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getOperand(i), &TypePrinter, Machine,
Context);
}
}
Out << ']';
}
@ -868,21 +866,19 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
Type *ETy = CA->getType()->getElementType();
Out << '[';
if (CA->getNumOperands()) {
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getElementAsConstant(0),
&TypePrinter, Machine,
Context);
for (unsigned i = 1, e = CA->getNumElements(); i != e; ++i) {
Out << ", ";
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getElementAsConstant(0),
&TypePrinter, Machine,
Context);
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
Out << ", ";
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getElementAsConstant(i), &TypePrinter,
Machine, Context);
}
Out << ']';
WriteAsOperandInternal(Out, CA->getElementAsConstant(i), &TypePrinter,
Machine, Context);
}
Out << ']';
return;
}