diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index c65113a6f3e9..3895e99c10d2 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -259,7 +259,7 @@ public: /// 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. - std::unique_ptr createRNG(const Pass* P) const; + std::unique_ptr createRNG(const StringRef Name) const; /// Return true if size-info optimization remark is enabled, false /// otherwise. diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index c2083f5db897..f1acf4653de6 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -86,8 +86,9 @@ Module::~Module() { IFuncList.clear(); } -std::unique_ptr Module::createRNG(const Pass* P) const { - SmallString<32> Salt(P->getPassName()); +std::unique_ptr +Module::createRNG(const StringRef Name) const { + SmallString<32> Salt(Name); // This RNG is guaranteed to produce the same random stream only // when the Module ID and thus the input filename is the same. This @@ -101,7 +102,8 @@ std::unique_ptr Module::createRNG(const Pass* P) const { // store salt metadata from the Module constructor. Salt += sys::path::filename(getModuleIdentifier()); - return std::unique_ptr(new RandomNumberGenerator(Salt)); + return std::unique_ptr( + new RandomNumberGenerator(Salt)); } /// getNamedValue - Return the first global value in the module with diff --git a/llvm/unittests/IR/ModuleTest.cpp b/llvm/unittests/IR/ModuleTest.cpp index 12eba7025eec..15180bcc729a 100644 --- a/llvm/unittests/IR/ModuleTest.cpp +++ b/llvm/unittests/IR/ModuleTest.cpp @@ -63,7 +63,7 @@ TEST(ModuleTest, randomNumberGenerator) { std::array RandomStreams[2]; for (auto &RandomStream : RandomStreams) { - std::unique_ptr RNG = M.createRNG(&DP); + std::unique_ptr RNG = M.createRNG(DP->getPassName()); std::generate(RandomStream.begin(), RandomStream.end(), [&]() { return dist(*RNG); }); }