[llvm-commits] [llvm] r73470 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Chris Lattner sabre at nondot.org
Mon Jun 15 22:15:24 PDT 2009


Author: lattner
Date: Tue Jun 16 00:15:21 2009
New Revision: 73470

URL: http://llvm.org/viewvc/llvm-project?rev=73470&view=rev
Log:
Fix PR4336: Iterating over use-def chains doesn't seem to be deterministic.

The problem was that BitcodeReader::materializeModule would read functions
from the bc file in densemap pointer key order (doubly non-deterministic!),
which would cause the use-def chains to be set up for globals in
non-determinstic order.  Non-determinstic use/def chains can cause 
nondeterminism in many places down-stream.

Many thanks to Julien Lerouge for putting together the pass in the PR that
shows the issue!

Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=73470&r1=73469&r2=73470&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jun 16 00:15:21 2009
@@ -2040,14 +2040,13 @@
 
 
 Module *BitcodeReader::materializeModule(std::string *ErrInfo) {
-  for (DenseMap<Function*, std::pair<uint64_t, unsigned> >::iterator I = 
-       DeferredFunctionInfo.begin(), E = DeferredFunctionInfo.end(); I != E;
-       ++I) {
-    Function *F = I->first;
+  // Iterate over the module, deserializing any functions that are still on
+  // disk.
+  for (Module::iterator F = TheModule->begin(), E = TheModule->end();
+       F != E; ++F)
     if (F->hasNotBeenReadFromBitcode() &&
         materializeFunction(F, ErrInfo))
       return 0;
-  }
 
   // Upgrade any intrinsic calls that slipped through (should not happen!) and 
   // delete the old functions to clean up. We can't do this unless the entire 
@@ -2123,7 +2122,7 @@
   // is run.
   if (M)
     M = R->releaseModule(ErrMsg);
-  
+   
   delete R;
   return M;
 }





More information about the llvm-commits mailing list