From 44d0eebc1371b431396a84153159b326c7d4e1f9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 15 Jan 2004 17:55:01 +0000 Subject: [PATCH] Fix PR73 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10875 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/Reader.cpp | 11 ++++++++++- lib/Bytecode/Reader/ReaderInternals.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 508fb7730a9..bc84135a96f 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -499,7 +499,8 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf, BCR_TRACE(2, "Function of type: " << Ty << "\n"); } - align32(Buf, End); + if (hasInconsistentModuleGlobalInfo) + align32(Buf, End); // Now that the function signature list is set up, reverse it so that we can // remove elements efficiently from the back of the vector. @@ -530,6 +531,7 @@ void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf, hasExtendedLinkageSpecs = true; hasOldStyleVarargs = false; hasVarArgCallPadding = false; + hasInconsistentModuleGlobalInfo = false; FirstDerivedTyID = 14; switch (RevisionNum) { @@ -539,15 +541,22 @@ void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf, hasExtendedLinkageSpecs = false; hasOldStyleVarargs = true; hasVarArgCallPadding = true; + hasInconsistentModuleGlobalInfo = true; + break; 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; case 1: // LLVM 1.2 release version // LLVM 1.2 added explicit support for emitting strings efficiently. + + // Also, it fixed the problem where the size of the ModuleGlobalInfo block + // included the size for the alignment at the end, where the rest of the + // blocks did not. break; default: diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index deb120672a1..d6a934da077 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -97,6 +97,10 @@ private: bool usesOldStyleVarargs; // Does this module USE old style varargs? + // LLVM 1.0 & 1.1 had an explicit alignment of data only for the + // ModuleGlobalInfo block. This was fixed to be like all other blocks in 1.2 + bool hasInconsistentModuleGlobalInfo; + typedef std::vector ValueTable; ValueTable Values; ValueTable ModuleValues; -- 2.34.1