diff options
author | Chris Lattner <sabre@nondot.org> | 2012-02-05 02:41:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2012-02-05 02:41:35 +0000 |
commit | bb8278a10ae5a02a6e80bcfba7fa2750910f6dfa (patch) | |
tree | 2b4d179194bcb00c3c7c3527d0ac56596c750e3c /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | c96605461cddc640730fcbe93f35059a444a335c (diff) | |
download | bcm5719-llvm-bb8278a10ae5a02a6e80bcfba7fa2750910f6dfa.tar.gz bcm5719-llvm-bb8278a10ae5a02a6e80bcfba7fa2750910f6dfa.zip |
Improve the bitcode reader's handling of constant strings to use
ConstantDataArray::getString direction, instead of "boxing" each
byte into a ConstantInt and using ConstantArray::get.
llvm-svn: 149805
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 672acd3daec..6f887f6ecaf 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1092,33 +1092,17 @@ bool BitcodeReader::ParseConstants() { } break; } - case bitc::CST_CODE_STRING: { // STRING: [values] - if (Record.empty()) - return Error("Invalid CST_AGGREGATE record"); - - ArrayType *ATy = cast<ArrayType>(CurTy); - Type *EltTy = ATy->getElementType(); - - unsigned Size = Record.size(); - SmallVector<Constant*, 16> Elts; - for (unsigned i = 0; i != Size; ++i) - Elts.push_back(ConstantInt::get(EltTy, Record[i])); - V = ConstantArray::get(ATy, Elts); - break; - } + case bitc::CST_CODE_STRING: // STRING: [values] case bitc::CST_CODE_CSTRING: { // CSTRING: [values] if (Record.empty()) - return Error("Invalid CST_AGGREGATE record"); - - ArrayType *ATy = cast<ArrayType>(CurTy); - Type *EltTy = ATy->getElementType(); + return Error("Invalid CST_STRING record"); unsigned Size = Record.size(); - SmallVector<Constant*, 16> Elts; + SmallString<16> Elts; for (unsigned i = 0; i != Size; ++i) - Elts.push_back(ConstantInt::get(EltTy, Record[i])); - Elts.push_back(Constant::getNullValue(EltTy)); - V = ConstantArray::get(ATy, Elts); + Elts.push_back(Record[i]); + V = ConstantDataArray::getString(Context, Elts, + BitCode == bitc::CST_CODE_CSTRING); break; } case bitc::CST_CODE_DATA: {// DATA: [n x value] |