aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-05-22 18:35:38 +0000
committerChris Lattner <sabre@nondot.org>2003-05-22 18:35:38 +0000
commitf69315bd79c3cc8f92f3b003b2cdab57aba3a20e (patch)
treeca3e8b4eb52372d0e70259826b1604859b6aff13 /lib/Bytecode
parenta2602f3dfd0561bf5825e301c173628c35525db8 (diff)
downloadexternal_llvm-f69315bd79c3cc8f92f3b003b2cdab57aba3a20e.zip
external_llvm-f69315bd79c3cc8f92f3b003b2cdab57aba3a20e.tar.gz
external_llvm-f69315bd79c3cc8f92f3b003b2cdab57aba3a20e.tar.bz2
Fix bug: Assembler/2003-05-03-BytecodeReaderProblem.llx
by emitting the type planes before any constants (which could be constant expressions involving undefined types!) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Writer/Writer.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index f97d7e2..ad13eef 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/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) {