1//===- Msan.h - Utils related to the memory sanitizer ---------------------===//
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//===----------------------------------------------------------------------===//
8//
9// This file declares and defines macros related to msan.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_EXECUTIONENGINE_MSAN_H
14#define MLIR_EXECUTIONENGINE_MSAN_H
15
16// Memory sanitizer currently can't be enabled for the jit-compiled code, and
17// to suppress msan warnings we need to unpoison pointers and pointed-to
18// datastructures before they can be accessed.
19
20#ifndef __has_feature
21#define __has_feature(x) 0
22#endif
23
24#if __has_feature(memory_sanitizer) && !defined(MLIR_MEMORY_SANITIZER)
25#define MLIR_MEMORY_SANITIZER
26#endif
27
28#if defined(MLIR_MEMORY_SANITIZER)
29#include <sanitizer/msan_interface.h>
30#define MLIR_MSAN_MEMORY_IS_INITIALIZED(p, s) __msan_unpoison((p), (s))
31#else // Memory sanitizer: OFF
32#define MLIR_MSAN_MEMORY_IS_INITIALIZED(p, s)
33#endif // MLIR_MEMORY_SANITIZER
34
35#endif // MLIR_EXECUTIONENGINE_MSAN_H
36

source code of mlir/include/mlir/ExecutionEngine/Msan.h