Index: llvm/lib/Support/Unix/Path.inc =================================================================== --- llvm/lib/Support/Unix/Path.inc +++ llvm/lib/Support/Unix/Path.inc @@ -873,7 +873,16 @@ void mapped_file_region::dontNeedImpl() { assert(Mode == mapped_file_region::readonly); if (Mapping) +#if defined(__MVS__) || !defined(HAVE_SYS_MMAN_H) + // If we don't have either madvise or posix_madvise, treat this as a nop. + return; +#elif defined(_AIX) + // Prefer the POSIX implementation on AIX, since the signature for madvise is non-standardised + // and only exists with certain feature test macros. + ::posix_madvise(Mapping, Size, POSIX_MADV_DONTNEED); +#else ::madvise(Mapping, Size, MADV_DONTNEED); +#endif } int mapped_file_region::alignment() {