Random Number Generator Refactoring (removing from Module)

This patch removes the RNG from Module. Passes should instead create a new RNG for their use as needed.

Patch by Stephen Crane @rinon.

Differential revision: http://reviews.llvm.org/D4377

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
JF Bastien
2014-12-17 18:12:10 +00:00
parent 9830b459be
commit 544f63e84a
4 changed files with 61 additions and 52 deletions

View File

@ -219,8 +219,6 @@ private:
std::string TargetTriple; ///< Platform target triple Module compiled on
///< Format: (arch)(sub)-(vendor)-(sys0-(abi)
void *NamedMDSymTab; ///< NamedMDNode names.
// Allow lazy initialization in const method.
mutable RandomNumberGenerator *RNG; ///< The random number generator for this module.
// We need to keep the string because the C API expects us to own the string
// representation.
@ -269,10 +267,16 @@ public:
/// @returns a string containing the module-scope inline assembly blocks.
const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
/// Get the RandomNumberGenerator for this module. The RNG can be
/// seeded via -rng-seed=<uint64> and is salted with the ModuleID.
/// The returned RNG should not be shared across threads.
RandomNumberGenerator &getRNG() const;
/// Get a RandomNumberGenerator salted for use with this module. The
/// RNG can be seeded via -rng-seed=<uint64> and is salted with the
/// ModuleID and the provided pass salt. The returned RNG should not
/// be shared across threads or passes.
///
/// A unique RNG per pass ensures a reproducible random stream even
/// when other randomness consuming passes are added or removed. In
/// addition, the random stream will be reproducible across LLVM
/// versions when the pass does not change.
RandomNumberGenerator *createRNG(const Pass* P) const;
/// @}
/// @name Module Level Mutators