Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / scudo / standalone / bytemap.h
blob248e096d07b6d2b0abfe7ea719392e9dfb5525d1
1 //===-- bytemap.h -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef SCUDO_BYTEMAP_H_
10 #define SCUDO_BYTEMAP_H_
12 #include "atomic_helpers.h"
13 #include "common.h"
14 #include "mutex.h"
16 namespace scudo {
18 template <uptr Size> class FlatByteMap {
19 public:
20 void init() { DCHECK(Size == 0 || Map[0] == 0); }
22 void unmapTestOnly() { memset(Map, 0, Size); }
24 void set(uptr Index, u8 Value) {
25 DCHECK_LT(Index, Size);
26 DCHECK_EQ(0U, Map[Index]);
27 Map[Index] = Value;
29 u8 operator[](uptr Index) {
30 DCHECK_LT(Index, Size);
31 return Map[Index];
34 void disable() {}
35 void enable() {}
37 private:
38 u8 Map[Size] = {};
41 } // namespace scudo
43 #endif // SCUDO_BYTEMAP_H_