diff options
author | Chris Lattner <sabre@nondot.org> | 2003-05-22 18:35:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-05-22 18:35:38 +0000 |
commit | 4a207910495b419a724dadf1a23ecf9a6e2a6f5d (patch) | |
tree | 30b97697decfc6b34b339500ef5c517df9db7db5 /llvm/lib/Bytecode/Writer/Writer.cpp | |
parent | c56bdc5520ae014aff90886ed9521e67e45d97a8 (diff) | |
download | bcm5719-llvm-4a207910495b419a724dadf1a23ecf9a6e2a6f5d.tar.gz bcm5719-llvm-4a207910495b419a724dadf1a23ecf9a6e2a6f5d.zip |
Fix bug: Assembler/2003-05-03-BytecodeReaderProblem.llx
by emitting the type planes before any constants (which could be constant
expressions involving undefined types!)
llvm-svn: 6285
Diffstat (limited to 'llvm/lib/Bytecode/Writer/Writer.cpp')
-rw-r--r-- | llvm/lib/Bytecode/Writer/Writer.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp index f97d7e232b5..ad13eef734d 100644 --- a/llvm/lib/Bytecode/Writer/Writer.cpp +++ b/llvm/lib/Bytecode/Writer/Writer.cpp @@ -125,25 +125,34 @@ void BytecodeWriter::outputConstants(bool isFunction) { BytecodeBlock CPool(BytecodeFormat::ConstantPool, Out); unsigned NumPlanes = Table.getNumPlanes(); - - for (unsigned pno = 0; pno != NumPlanes; pno++) { - const std::vector<const Value*> &Plane = Table.getPlane(pno); - if (!Plane.empty()) { // Skip empty type planes... - unsigned ValNo = 0; - if (isFunction) // Don't reemit module constants - ValNo += Table.getModuleLevel(pno); - else if (pno == Type::TypeTyID) // If type plane wasn't written out above - continue; - - if (pno >= Type::FirstDerivedTyID) { - // Skip zero initializer - if (ValNo == 0) - ValNo = 1; - } - outputConstantsInPlane(Plane, ValNo); // Write out constants in the plane + // Output the type plane before any constants! + if (isFunction && NumPlanes > Type::TypeTyID) { + const std::vector<const Value*> &Plane = Table.getPlane(Type::TypeTyID); + if (!Plane.empty()) { // Skip empty type planes... + unsigned ValNo = Table.getModuleLevel(Type::TypeTyID); + outputConstantsInPlane(Plane, ValNo); } } + + for (unsigned pno = 0; pno != NumPlanes; pno++) + if (pno != Type::TypeTyID) { // Type plane handled above. + const std::vector<const Value*> &Plane = Table.getPlane(pno); + if (!Plane.empty()) { // Skip empty type planes... + unsigned ValNo = 0; + if (isFunction) // Don't reemit module constants + ValNo += Table.getModuleLevel(pno); + + if (pno >= Type::FirstDerivedTyID) { + // Skip zero initializer + if (ValNo == 0) + ValNo = 1; + } + + // Write out constants in the plane + outputConstantsInPlane(Plane, ValNo); + } + } } void BytecodeWriter::outputModuleInfoBlock(const Module *M) { |