[llvm] 73713f3 - RNG: Take pass name as argument instead of pass pointer.
Dominic Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 11:22:02 PST 2020
Author: Dominic Chen
Date: 2020-01-31T14:21:40-05:00
New Revision: 73713f3e5ef2ecf1e5afafa89f76ab89cc06b18e
URL: https://github.com/llvm/llvm-project/commit/73713f3e5ef2ecf1e5afafa89f76ab89cc06b18e
DIFF: https://github.com/llvm/llvm-project/commit/73713f3e5ef2ecf1e5afafa89f76ab89cc06b18e.diff
LOG: RNG: Take pass name as argument instead of pass pointer.
Summary: With the new pass manager, it is not possible to obtain a pointer to the pass.
Reviewers: jfb, rinon, yln
Subscribers: hiraditya, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73390
Added:
Modified:
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
llvm/unittests/IR/ModuleTest.cpp
Removed:
################################################################################
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 @@ class Module {
/// 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.
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<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 @@ std::unique_ptr<RandomNumberGenerator> Module::createRNG(const Pass* P) const {
// 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
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<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); });
}
More information about the llvm-commits
mailing list