diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index d47d82a57bf..196e32e3615 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -249,7 +249,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. - RandomNumberGenerator *createRNG(const Pass* P) const; + std::unique_ptr createRNG(const Pass* P) const; /// @} /// @name Module Level Mutators diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index f8853ed169c..fdc7de6eaa3 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -88,7 +88,7 @@ Module::~Module() { delete static_cast *>(NamedMDSymTab); } -RandomNumberGenerator *Module::createRNG(const Pass* P) const { +std::unique_ptr Module::createRNG(const Pass* P) const { SmallString<32> Salt(P->getPassName()); // This RNG is guaranteed to produce the same random stream only @@ -103,7 +103,7 @@ RandomNumberGenerator *Module::createRNG(const Pass* P) const { // store salt metadata from the Module constructor. Salt += sys::path::filename(getModuleIdentifier()); - return new RandomNumberGenerator(Salt); + return std::unique_ptr{new RandomNumberGenerator(Salt)}; } /// getNamedValue - Return the first global value in the module with diff --git a/unittests/IR/ModuleTest.cpp b/unittests/IR/ModuleTest.cpp index d93d036bb11..af55a098add 100644 --- a/unittests/IR/ModuleTest.cpp +++ b/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); std::generate(RandomStream.begin(), RandomStream.end(), [&]() { return dist(*RNG); }); }