Bitcode: Fix reading and writing of ConstantDataVectors of halfs
In r254991 I allowed ConstantDataVectors to contain elements of HalfTy, but I missed updating the bitcode reader and writer to handle this, so now we crash if we try to emit bitcode on programs that have constant vectors of half. This fixes the issue and adds test coverage for reading and writing constant sequences in bitcode. llvm-svn: 256982
This commit is contained in:
@@ -1630,19 +1630,10 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
|
||||
if (isa<IntegerType>(EltTy)) {
|
||||
for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
|
||||
Record.push_back(CDS->getElementAsInteger(i));
|
||||
} else if (EltTy->isFloatTy()) {
|
||||
for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
|
||||
union { float F; uint32_t I; };
|
||||
F = CDS->getElementAsFloat(i);
|
||||
Record.push_back(I);
|
||||
}
|
||||
} else {
|
||||
assert(EltTy->isDoubleTy() && "Unknown ConstantData element type");
|
||||
for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
|
||||
union { double F; uint64_t I; };
|
||||
F = CDS->getElementAsDouble(i);
|
||||
Record.push_back(I);
|
||||
}
|
||||
for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
|
||||
Record.push_back(
|
||||
CDS->getElementAsAPFloat(i).bitcastToAPInt().getLimitedValue());
|
||||
}
|
||||
} else if (isa<ConstantArray>(C) || isa<ConstantStruct>(C) ||
|
||||
isa<ConstantVector>(C)) {
|
||||
|
||||
Reference in New Issue
Block a user