diff options
| author | Kostya Serebryany <kcc@google.com> | 2019-01-30 06:15:52 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2019-01-30 06:15:52 +0000 |
| commit | 6fd4d8ab9c6e6ddb67df5d822f855de980d1eea6 (patch) | |
| tree | 2c8a5abe1b8570871d9c337d2e3998a2d98c6898 /compiler-rt/lib/fuzzer/FuzzerUtil.h | |
| parent | c437f310a503b17bdb479dc4f518b8da7dbeb283 (diff) | |
| download | bcm5719-llvm-6fd4d8ab9c6e6ddb67df5d822f855de980d1eea6.tar.gz bcm5719-llvm-6fd4d8ab9c6e6ddb67df5d822f855de980d1eea6.zip | |
[libFuzzer] refactor the handling of instrumentation counters so that they are grouped in regions one full page each. Needed for future optimization. NFC
llvm-svn: 352603
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerUtil.h')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerUtil.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtil.h b/compiler-rt/lib/fuzzer/FuzzerUtil.h index 74fa5bc3107..85c5571d684 100644 --- a/compiler-rt/lib/fuzzer/FuzzerUtil.h +++ b/compiler-rt/lib/fuzzer/FuzzerUtil.h @@ -87,6 +87,20 @@ size_t SimpleFastHash(const uint8_t *Data, size_t Size); inline uint32_t Log(uint32_t X) { return 32 - Clz(X) - 1; } +inline size_t PageSize() { return 4096; } +inline uint8_t *RoundUpByPage(uint8_t *P) { + uintptr_t X = reinterpret_cast<uintptr_t>(P); + size_t Mask = PageSize() - 1; + X = (X + Mask) & ~Mask; + return reinterpret_cast<uint8_t *>(X); +} +inline uint8_t *RoundDownByPage(uint8_t *P) { + uintptr_t X = reinterpret_cast<uintptr_t>(P); + size_t Mask = PageSize() - 1; + X = X & ~Mask; + return reinterpret_cast<uint8_t *>(X); +} + } // namespace fuzzer #endif // LLVM_FUZZER_UTIL_H |

