[PATCH] D61867: [GWP-ASan] Initial build files, implementation of PRNG [1].

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 14:02:30 PDT 2019


morehouse accepted this revision.
morehouse added inline comments.
This revision is now accepted and ready to land.


================
Comment at: compiler-rt/lib/gwp_asan/random.cpp:28
+                                                 xorShift32(), xorShift32(),
+                                                 xorShift32(), xorShift32()};
+  uint32_t Temp = RandomState[0] ^ (RandomState[0] >> 2);
----------------
hctim wrote:
> morehouse wrote:
> > This seems like a lot of state to keep.  Not a big deal, but is there a simpler RNG we can use?  What about just xorshift32?
> `xorwow` has a period of `2 ** 192 - 2**32`, versus `xorshift32` having a period of `2 ** 32`. Also, surprisingly, it's about 1.2x faster than `xorshift32` (http://quick-bench.com/mYmSCp5jJ_NLo3yyPXt-2N3TuHg) on my x86_64.
> 
> I personally think the 20B extra TLS/thread is worth it (given that it's likely zero overhead anyway unless the 20B pushes someone to alloc a new page for TLS). WDYT?
2^32 seems plenty large to me.  Speed isn't a huge concern since we're on the slow path, so I personally would prefer simpler.  In fact if the RNG func is small enough, it might be simpler to put it directly in GPA.cc instead and reduce the number of files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61867





More information about the llvm-commits mailing list