summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-17 23:25:43 +0000
committerChris Lattner <sabre@nondot.org>2004-01-17 23:25:43 +0000
commit677af4a1cbc3e300bcb84cacb76ed7618b128ada (patch)
tree06537551d3e0492cd0b2c89d5b16e319d8eee6cc /llvm/lib/Bytecode/Reader/Reader.cpp
parent4533ba592b0e3e0bf26e62a2afa4a6f62a1c2394 (diff)
downloadbcm5719-llvm-677af4a1cbc3e300bcb84cacb76ed7618b128ada.tar.gz
bcm5719-llvm-677af4a1cbc3e300bcb84cacb76ed7618b128ada.zip
Bytecode format for LLVM 1.2 no longer explicitly encodes zeros in primitive
type planes. This saves about 5k on 176.gcc, and is needed for a subsequent patch of mine I'm working on. llvm-svn: 10908
Diffstat (limited to 'llvm/lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/Reader.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index 9cc24b32cda..16b4ee06ebe 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/lib/Bytecode/Reader/Reader.cpp
@@ -66,10 +66,17 @@ const Type *BytecodeParser::getType(unsigned ID) {
throw std::string("Illegal type reference!");
}
+static inline bool hasImplicitNull(unsigned TyID, bool EncodesPrimitiveZeros) {
+ if (!EncodesPrimitiveZeros)
+ return TyID != Type::LabelTyID && TyID != Type::TypeTyID &&
+ TyID != Type::VoidTyID;
+ return TyID >= Type::FirstDerivedTyID;
+}
+
unsigned BytecodeParser::insertValue(Value *Val, unsigned type,
ValueTable &ValueTab) {
- assert((!isa<Constant>(Val) || Val->getType()->isPrimitiveType() ||
- !cast<Constant>(Val)->isNullValue()) &&
+ assert((!isa<Constant>(Val) || !cast<Constant>(Val)->isNullValue()) ||
+ !hasImplicitNull(type, hasExplicitPrimitiveZeros) &&
"Cannot read null values from bytecode!");
assert(type != Type::TypeTyID && "Types should never be insertValue'd!");
@@ -88,13 +95,12 @@ unsigned BytecodeParser::insertValue(Value *Val, unsigned type,
return ValueTab[type]->size()-1 + HasOffset;
}
-
Value *BytecodeParser::getValue(unsigned type, unsigned oNum, bool Create) {
assert(type != Type::TypeTyID && "getValue() cannot get types!");
assert(type != Type::LabelTyID && "getValue() cannot get blocks!");
unsigned Num = oNum;
- if (type >= FirstDerivedTyID) {
+ if (hasImplicitNull(type, hasExplicitPrimitiveZeros)) {
if (Num == 0)
return Constant::getNullValue(getType(type));
--Num;
@@ -536,6 +542,7 @@ void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
hasOldStyleVarargs = false;
hasVarArgCallPadding = false;
hasInconsistentModuleGlobalInfo = false;
+ hasExplicitPrimitiveZeros = false;
FirstDerivedTyID = 14;
switch (RevisionNum) {
@@ -545,16 +552,15 @@ void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
hasExtendedLinkageSpecs = false;
hasOldStyleVarargs = true;
hasVarArgCallPadding = true;
- hasInconsistentModuleGlobalInfo = true;
-
- break;
+ // FALL THROUGH
case 0: // LLVM 1.0, 1.1 release version
// Compared to rev #2, we added support for weak linkage, a more dense
// encoding, and better varargs support.
// Base LLVM 1.0 bytecode format.
hasInconsistentModuleGlobalInfo = true;
- break;
+ hasExplicitPrimitiveZeros = true;
+ // FALL THROUGH
case 1: // LLVM 1.2 release version
// LLVM 1.2 added explicit support for emitting strings efficiently.
OpenPOWER on IntegriCloud