BitcodeReader: Fix non-determinism in use-list order

`BasicBlockFwdRefs` (and `BlockAddrFwdRefs` before it) was being emptied
in a non-deterministic order.  When predicting use-list order I've
worked around this another way, but even when parsing lazily (and we
can't recreate use-list order) use-lists should be deterministic.

Make them so by using a side-queue of functions with forward-referenced
blocks that gets visited in order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214899 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2014-08-05 17:49:48 +00:00
parent b835f3446f
commit 7f2cd21ddd
2 changed files with 15 additions and 3 deletions

View File

@@ -22,6 +22,7 @@
#include "llvm/IR/OperandTraits.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/ValueHandle.h"
#include <deque>
#include <system_error>
#include <vector>
@@ -183,6 +184,7 @@ class BitcodeReader : public GVMaterializer {
/// inserted lazily into functions when they're loaded.
typedef std::pair<unsigned, BasicBlock *> BasicBlockRefTy;
DenseMap<Function *, std::vector<BasicBlockRefTy>> BasicBlockFwdRefs;
std::deque<Function *> BasicBlockFwdRefQueue;
/// UseRelativeIDs - Indicates that we are using a new encoding for
/// instruction operands where most operands in the current