[PATCH] D34089: [llvm-stress] Ensure that the C++11 random device respects its min/max values (PR32585)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 11 05:45:22 PDT 2017


RKSimon created this revision.

As noted on PR32585, the change in https://reviews.llvm.org/D29780/https://reviews.llvm.org/rL295325 resulted in calls to Rand32() (values 0 -> 0xFFFFFFFF) but the min()/max() operators indicated it would be (0 -> 0x7FFFF).

This patch changes the random operator to call Rand() instead which does respect the 0 -> 0x7FFFF range.

Not sure the best way to test this - would an assert in the operator be enough?


Repository:
  rL LLVM

https://reviews.llvm.org/D34089

Files:
  tools/llvm-stress/llvm-stress.cpp


Index: tools/llvm-stress/llvm-stress.cpp
===================================================================
--- tools/llvm-stress/llvm-stress.cpp
+++ tools/llvm-stress/llvm-stress.cpp
@@ -1,4 +1,4 @@
-//===-- llvm-stress.cpp - Generate random LL files to stress-test LLVM ----===//
+//===-- llvm-stress.cpp - Generate random LL files to stress-test LLVM ----===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -116,7 +116,7 @@
 
   /// Make this like a C++11 random device
   typedef uint32_t result_type;
-  uint32_t operator()() { return Rand32(); }
+  uint32_t operator()() { return Rand(); }
   static constexpr result_type min() { return 0; }
   static constexpr result_type max() { return 0x7ffff; }
   


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34089.102133.patch
Type: text/x-patch
Size: 749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170611/158a51ff/attachment.bin>


More information about the llvm-commits mailing list