Fix a bug where calling materializeModule could corrupt the module, reading
authorChris Lattner <sabre@nondot.org>
Mon, 9 Apr 2007 20:28:40 +0000 (20:28 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 9 Apr 2007 20:28:40 +0000 (20:28 +0000)
multiple copies of the function into the Function*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35831 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/Reader.cpp

index ffb731f3141d58fa573677cbaec1b1f495763d55..fd4a54920f476d2fe1deae4b783f3a7f42eb3a06 100644 (file)
@@ -1672,15 +1672,14 @@ bool BytecodeReader::ParseAllFunctionBodies(std::string* ErrMsg) {
     return true;
   }
 
-  LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin();
-  LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end();
-
-  while (Fi != Fe) {
-    Function* Func = Fi->first;
-    BlockStart = At = Fi->second.Buf;
-    BlockEnd = Fi->second.EndBuf;
-    ParseFunctionBody(Func);
-    ++Fi;
+  for (LazyFunctionMap::iterator I = LazyFunctionLoadMap.begin(),
+       E = LazyFunctionLoadMap.end(); I != E; ++I) {
+    Function *Func = I->first;
+    if (Func->hasNotBeenReadFromBytecode()) {
+      BlockStart = At = I->second.Buf;
+      BlockEnd = I->second.EndBuf;
+      ParseFunctionBody(Func);
+    }
   }
   return false;
 }