[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Chris Lattner sabre at nondot.org
Sat May 5 17:35:48 PDT 2007



Changes in directory llvm/lib/Bitcode/Reader:

BitcodeReader.cpp updated: 1.41 -> 1.42
---
Log message:

implement the 'string constant' optimization.  This shrinks kc.bit from
2878544 to 2815788


---
Diffs of the changes:  (+15 -1)

 BitcodeReader.cpp |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.41 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.42
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.41	Sat May  5 19:21:25 2007
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp	Sat May  5 19:35:24 2007
@@ -642,7 +642,21 @@
       }
       break;
     }
-
+    case bitc::CST_CODE_STRING: { // STRING: [values]
+      if (Record.empty())
+        return Error("Invalid CST_AGGREGATE record");
+
+      const ArrayType *ATy = cast<ArrayType>(CurTy);
+      const Type *EltTy = ATy->getElementType();
+      
+      unsigned Size = Record.size();
+      std::vector<Constant*> 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_CE_BINOP: {  // CE_BINOP: [opcode, opval, opval]
       if (Record.size() < 3) return Error("Invalid CE_BINOP record");
       int Opc = GetDecodedBinaryOpcode(Record[0], CurTy);






More information about the llvm-commits mailing list