From: Chris Lattner Date: Tue, 16 Jun 2009 05:15:21 +0000 (+0000) Subject: Fix PR4336: Iterating over use-def chains doesn't seem to be deterministic. X-Git-Tag: android-x86-6.0-r1~1003^2~19983 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=714fa95d01ce1a646b52bc529f3dbcf6a06fa29b;p=android-x86%2Fexternal-llvm.git 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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73470 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 3b44f56421f..6b9606c5d14 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2040,14 +2040,13 @@ void BitcodeReader::dematerializeFunction(Function *F) { Module *BitcodeReader::materializeModule(std::string *ErrInfo) { - for (DenseMap >::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 @@ Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg){ // is run. if (M) M = R->releaseModule(ErrMsg); - + delete R; return M; }