[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp BitcodeReader.h
Chris Lattner
sabre at nondot.org
Mon Apr 23 17:18:38 PDT 2007
Changes in directory llvm/lib/Bitcode/Reader:
BitcodeReader.cpp updated: 1.4 -> 1.5
BitcodeReader.h updated: 1.4 -> 1.5
---
Log message:
track global inits
---
Diffs of the changes: (+9 -3)
BitcodeReader.cpp | 10 +++++++---
BitcodeReader.h | 2 ++
2 files changed, 9 insertions(+), 3 deletions(-)
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.4 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.5
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.4 Mon Apr 23 16:26:05 2007
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 23 19:18:21 2007
@@ -243,7 +243,7 @@
switch (Stream.ReadRecord(Code, Record)) {
default: // Default behavior: unknown type.
break;
- case bitc::TST_ENTRY_CODE: // TST_ENTRY: [typeid, namelen, namechar x N]
+ case bitc::TST_CODE_ENTRY: // TST_ENTRY: [typeid, namelen, namechar x N]
if (ConvertToString(Record, 1, TypeName))
return Error("Invalid TST_ENTRY record");
unsigned TypeID = Record[0];
@@ -288,7 +288,7 @@
switch (Stream.ReadRecord(Code, Record)) {
default: // Default behavior: unknown type.
break;
- case bitc::VST_ENTRY_CODE: // VST_ENTRY: [valueid, namelen, namechar x N]
+ case bitc::TST_CODE_ENTRY: // VST_ENTRY: [valueid, namelen, namechar x N]
if (ConvertToString(Record, 1, ValueName))
return Error("Invalid TST_ENTRY record");
unsigned ValueID = Record[0];
@@ -358,6 +358,8 @@
case bitc::MODULE_CODE_VERSION: // VERSION: [version#]
if (Record.size() < 1)
return Error("Malformed MODULE_CODE_VERSION");
+ if (!GlobalInits.empty())
+ return Error("Malformed global initializer set");
// Only version #0 is supported so far.
if (Record[0] != 0)
return Error("Unknown bitstream version!");
@@ -431,7 +433,9 @@
ValueList.push_back(NewGV);
- // TODO: remember initializer/global pair for later substitution.
+ // Remember which value to use for the global initializer.
+ if (unsigned InitID = Record[2])
+ GlobalInits.push_back(std::make_pair(NewGV, InitID-1));
break;
}
// FUNCTION: [type, callingconv, isproto, linkage, alignment, section,
Index: llvm/lib/Bitcode/Reader/BitcodeReader.h
diff -u llvm/lib/Bitcode/Reader/BitcodeReader.h:1.4 llvm/lib/Bitcode/Reader/BitcodeReader.h:1.5
--- llvm/lib/Bitcode/Reader/BitcodeReader.h:1.4 Mon Apr 23 16:26:05 2007
+++ llvm/lib/Bitcode/Reader/BitcodeReader.h Mon Apr 23 19:18:21 2007
@@ -22,12 +22,14 @@
namespace llvm {
class BitstreamReader;
class Value;
+ class GlobalValue;
class BitcodeReader : public ModuleProvider {
const char *ErrorString;
std::vector<PATypeHolder> TypeList;
std::vector<Value*> ValueList;
+ std::vector<std::pair<GlobalValue*, unsigned> > GlobalInits;
public:
virtual ~BitcodeReader() {}
More information about the llvm-commits
mailing list