[PATCH] D73390: RNG: Take pass name as argument instead of pass pointer.

Dominic Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 11:22:28 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG73713f3e5ef2: RNG: Take pass name as argument instead of pass pointer. (authored by ddcc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73390/new/

https://reviews.llvm.org/D73390

Files:
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Module.cpp
  llvm/unittests/IR/ModuleTest.cpp


Index: llvm/unittests/IR/ModuleTest.cpp
===================================================================
--- llvm/unittests/IR/ModuleTest.cpp
+++ llvm/unittests/IR/ModuleTest.cpp
@@ -63,7 +63,7 @@
 
   std::array<int, NBCheck> RandomStreams[2];
   for (auto &RandomStream : RandomStreams) {
-    std::unique_ptr<RandomNumberGenerator> RNG = M.createRNG(&DP);
+    std::unique_ptr<RandomNumberGenerator> RNG = M.createRNG(DP->getPassName());
     std::generate(RandomStream.begin(), RandomStream.end(),
                   [&]() { return dist(*RNG); });
   }
Index: llvm/lib/IR/Module.cpp
===================================================================
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -86,8 +86,9 @@
   IFuncList.clear();
 }
 
-std::unique_ptr<RandomNumberGenerator> Module::createRNG(const Pass* P) const {
-  SmallString<32> Salt(P->getPassName());
+std::unique_ptr<RandomNumberGenerator>
+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 @@
   // store salt metadata from the Module constructor.
   Salt += sys::path::filename(getModuleIdentifier());
 
-  return std::unique_ptr<RandomNumberGenerator>(new RandomNumberGenerator(Salt));
+  return std::unique_ptr<RandomNumberGenerator>(
+      new RandomNumberGenerator(Salt));
 }
 
 /// getNamedValue - Return the first global value in the module with
Index: llvm/include/llvm/IR/Module.h
===================================================================
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -259,7 +259,7 @@
   /// 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<RandomNumberGenerator> createRNG(const Pass* P) const;
+  std::unique_ptr<RandomNumberGenerator> createRNG(const StringRef Name) const;
 
   /// Return true if size-info optimization remark is enabled, false
   /// otherwise.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73390.241780.patch
Type: text/x-patch
Size: 2147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200131/550576bd/attachment.bin>


More information about the llvm-commits mailing list