aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-06 00:00:00 +0000
committerChris Lattner <sabre@nondot.org>2007-05-06 00:00:00 +0000
commitdf1233dfbba87a43dfbc796d2e7aac3950783fe1 (patch)
tree3b1d8f1a86aa76fee854d2166dcc41b6009cefe8 /llvm/lib/Bitcode/Reader/BitcodeReader.h
parentc2d05300307a5896731b4ee40687492af2b0d6ac (diff)
downloadllvm-df1233dfbba87a43dfbc796d2e7aac3950783fe1.zip
llvm-df1233dfbba87a43dfbc796d2e7aac3950783fe1.tar.gz
llvm-df1233dfbba87a43dfbc796d2e7aac3950783fe1.tar.bz2
stop encoding type/value pairs when the type is implied by the value.
This shrinks the function block of kc++ from 1055K to 906K llvm-svn: 36816
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h
index 44d69a6..2dcce0b 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.h
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h
@@ -147,6 +147,34 @@ private:
return ParamAttrs[i-1];
return 0;
}
+
+ /// getValueTypePair - Read a value/type pair out of the specified record from
+ /// slot 'Slot'. Increment Slot past the number of slots used in the record.
+ /// Return true on failure.
+ bool getValueTypePair(SmallVector<uint64_t, 64> &Record, unsigned &Slot,
+ unsigned InstNum, Value *&ResVal) {
+ if (Slot == Record.size()) return true;
+ unsigned ValNo = Record[Slot++];
+ if (ValNo < InstNum) {
+ // If this is not a forward reference, just return the value we already
+ // have.
+ ResVal = getFnValueByID(ValNo, 0);
+ return ResVal == 0;
+ } else if (Slot == Record.size()) {
+ return true;
+ }
+
+ unsigned TypeNo = Record[Slot++];
+ ResVal = getFnValueByID(ValNo, getTypeByID(TypeNo));
+ return ResVal == 0;
+ }
+ bool getValue(SmallVector<uint64_t, 64> &Record, unsigned &Slot,
+ const Type *Ty, Value *&ResVal) {
+ if (Slot == Record.size()) return true;
+ unsigned ValNo = Record[Slot++];
+ ResVal = getFnValueByID(ValNo, Ty);
+ return ResVal == 0;
+ }
bool ParseModule(const std::string &ModuleID);