mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-13 09:26:43 +00:00
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
This commit is contained in:
parent
f465b1aff4
commit
73713f3e5e
@ -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<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.
|
||||
|
@ -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
|
||||
|
@ -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); });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user