See D60593 for further information.
This patch slices off the PRNG implementation and the initial build files for GWP-ASan.
Details
- Reviewers
vlad.tsyrklevich morehouse vitalybuka - Commits
- rZORGfca7884310ac: [GWP-ASan] Initial build files, implementation of PRNG [1].
rZORG2d3fa7b73eeb: [GWP-ASan] Initial build files, implementation of PRNG [1].
rGfca7884310ac: [GWP-ASan] Initial build files, implementation of PRNG [1].
rG2d3fa7b73eeb: [GWP-ASan] Initial build files, implementation of PRNG [1].
rCRT360710: [GWP-ASan] Initial build files, implementation of PRNG [1].
rGc9dd299736ad: [GWP-ASan] Initial build files, implementation of PRNG [1].
rL360710: [GWP-ASan] Initial build files, implementation of PRNG [1].
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 31898 Build 31897: arc lint + arc unit
Event Timeline
Note that the empty compiler-rt/test/gwp_asan/CMakeLists.txt is required, as there are automatic build rules that build the tests for all sanitizers which fail if there is no test directory for gwp_asan.
function-static vs global-static TLS variables: http://quick-bench.com/te2xYFbzDW0dqt-ql0fOQMieFEM
Looks like the optimiser has a hard time with both of these instances (TLS check on the load and subsequent save vs. excessive register spills). Turns out the perf is about even though, with the implemented version here just nudging it out (but within the noise).
compiler-rt/lib/gwp_asan/random.cpp | ||
---|---|---|
30 | I thought we switched to __thread? |
compiler-rt/lib/gwp_asan/CMakeLists.txt | ||
---|---|---|
11 | mutex.h doesn't exist yet. | |
compiler-rt/lib/gwp_asan/random.cpp | ||
18 | We have double-initialization if getRandomUnsigned64 is called before these initializers run. | |
compiler-rt/lib/gwp_asan/random.h | ||
18 | A random namespace might be overkill. | |
21 | 1 in 2 billion is very rare. I don't see a use case for less frequent sampling than that. |
compiler-rt/lib/gwp_asan/random.cpp | ||
---|---|---|
18 | I think static is actually implicit in this context. So static thread_local is equivalent to thread_local. | |
26 | Since this is a compile-time constant, static doesn't do anything. | |
29 | 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? |
compiler-rt/lib/gwp_asan/random.cpp | ||
---|---|---|
18 | Fixed w/ function-local statics. | |
29 | 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? | |
30 | As discussed offline, the slow path + guaranteed always-correct PRNG. | |
compiler-rt/lib/gwp_asan/random.h | ||
18 | Removed. | |
21 | Changed to 32-bit (using a slightly different algorithm). |
compiler-rt/lib/gwp_asan/random.cpp | ||
---|---|---|
29 | 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. |
mutex.h doesn't exist yet.