diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp --- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp @@ -1087,11 +1087,11 @@ #define MAP_FIXED_NOREPLACE MAP_FIXED #endif -// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only difference -// between the two syscalls is that mmap2's offset parameter is in terms 4096 -// byte offsets rather than individual bytes, so for our purposes they are -// effectively the same as all ofsets here are set to 0. -#ifdef __arm__ +// 32 bit ARM and RISCV doesn't have mmap and uses mmap2 instead. The only +// difference between the two syscalls is that mmap2's offset parameter is in +// terms 4096 byte offsets rather than individual bytes, so for our purposes +// they are effectively the same as all ofsets here are set to 0. +#if defined(__arm__) || (defined(__riscv) && (__riscv_xlen == 32)) #define SYS_mmap SYS_mmap2 #endif diff --git a/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp --- a/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp +++ b/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp @@ -635,11 +635,11 @@ #define MAP_FIXED_NOREPLACE MAP_FIXED #endif -// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only difference -// between the two syscalls is that mmap2's offset parameter is in terms 4096 -// byte offsets rather than individual bytes, so for our purposes they are -// effectively the same as all ofsets here are set to 0. -#ifdef __arm__ +// 32 bit ARM and RISCV doesn't have mmap and uses mmap2 instead. The only +// difference between the two syscalls is that mmap2's offset parameter is in +// terms 4096 byte offsets rather than individual bytes, so for our purposes +// they are effectively the same as all ofsets here are set to 0. +#if defined(__arm__) || (defined(__riscv) && (__riscv_xlen == 32)) #define SYS_mmap SYS_mmap2 #endif