Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -425,6 +425,12 @@ set(LLVM_USE_SANITIZER "" CACHE STRING "Define the sanitizer used to build binaries and tests.") +option(LLVM_SANITIZERS_TO_USE_SOFTWARE_MEMORY_MANAGER + "Experimental: Do not rely on availability of mmap() in sanitizers." OFF) +if(LLVM_SANITIZERS_TO_USE_SOFTWARE_MEMORY_MANAGER) + add_definitions(-DLLVM_SANITIZERS_TO_USE_SOFTWARE_MEMORY_MANAGER) +endif() + option(LLVM_USE_SPLIT_DWARF "Use -gsplit-dwarf when compiling llvm." OFF) Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -137,6 +137,14 @@ static const unsigned kAllocaRzSize = 32; +// With the software memory manager enabled we need the RTL to handle all +// shadow memory accesses. +#ifdef LLVM_SANITIZERS_TO_USE_SOFTWARE_MEMORY_MANAGER +static const bool kUseSoftwareMemoryManager = true; +#else +static const bool kUseSoftwareMemoryManager = false; +#endif + // Command-line flags. static cl::opt ClEnableKasan( "asan-kernel", cl::desc("Enable KernelAddressSanitizer instrumentation"), @@ -2210,7 +2218,7 @@ } bool UseCalls = - CompileKernel || + CompileKernel || kUseSoftwareMemoryManager || (ClInstrumentationWithCallsThreshold >= 0 && ToInstrument.size() > (unsigned)ClInstrumentationWithCallsThreshold); const DataLayout &DL = F.getParent()->getDataLayout();