Fix obscure nasty bug with bytecode writing that could cause the last byte to be dropped.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1123 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-11-04 21:32:41 +00:00
parent b980e18066
commit 5cb17410f2

View File

@ -225,12 +225,15 @@ void WriteBytecodeToFile(const Module *C, ostream &Out) {
const unsigned char *LastPtr = ChunkPtr; const unsigned char *LastPtr = ChunkPtr;
while (I != E) { while (I != E) {
const unsigned char *ThisPtr = &*++I; const unsigned char *ThisPtr = &*++I;
if (LastPtr+1 != ThisPtr) break;// Advanced by more than a byte of memory? if (LastPtr+1 != ThisPtr) { // Advanced by more than a byte of memory?
++LastPtr;
break;
}
LastPtr = ThisPtr; LastPtr = ThisPtr;
} }
// Write out the chunk... // Write out the chunk...
Out.write(ChunkPtr, LastPtr-ChunkPtr+(I != E)); Out.write(ChunkPtr, LastPtr-ChunkPtr);
} }
Out.flush(); Out.flush();