Skip to content

Commit

Permalink
fix asmwriting of ConstantDataArray to use the right element count,
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lattner committed Jan 31, 2012
1 parent c8d75c7 commit 8b10b69
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions lib/VMCore/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << ']';
}
Expand All @@ -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;
}

Expand Down

0 comments on commit 8b10b69

Please sign in to comment.