[llvm-branch-commits] [llvm] a734685 - [llvm-exegesis] Use mmap2 when mmap is unavailable to fix riscv32 build
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 30 08:08:16 PDT 2023
Author: Khem Raj
Date: 2023-08-30T16:57:34+02:00
New Revision: a7346857934d6cecb21ddbd4100bbac1ce73cafc
URL: https://github.com/llvm/llvm-project/commit/a7346857934d6cecb21ddbd4100bbac1ce73cafc
DIFF: https://github.com/llvm/llvm-project/commit/a7346857934d6cecb21ddbd4100bbac1ce73cafc.diff
LOG: [llvm-exegesis] Use mmap2 when mmap is unavailable to fix riscv32 build
Some 32-bit architectures don't have mmap and define mmap2 instead.
E.g. on riscv32 we may get
```
| /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1116:19: error: use of undeclared identifier 'SYS_mmap'
| 1116 | generateSyscall(SYS_mmap, MmapCode);
| | ^
| /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1134:19: error: use of undeclared identifier 'SYS_mmap'
| 1134 | generateSyscall(SYS_mmap, GeneratedCode); | | ^
| 1 warning and 2 errors generated.
```
Co-Authored-By: Fangrui Song <i at maskray.me>
Differential Revision: https://reviews.llvm.org/D158375
(cherry picked from commit 01a92f06f23585f15b3e83b7c378d0df2d91e06b)
Added:
Modified:
llvm/tools/llvm-exegesis/lib/X86/Target.cpp
llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
index e690089fec5656..b3d40800aef632 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -1083,11 +1083,11 @@ ExegesisX86Target::generateExitSyscall(unsigned ExitCode) const {
#define MAP_FIXED_NOREPLACE MAP_FIXED
#endif
-// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only
diff erence
-// 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__
+// Some 32-bit architectures don't have mmap and define mmap2 instead. The only
+//
diff erence 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(SYS_mmap2) && !defined(SYS_mmap)
#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
index aa5d525f24eb7e..c001c693cc1461 100644
--- a/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
@@ -635,11 +635,11 @@ TEST_F(X86Core2TargetTest, GenerateExitSyscallTest) {
#define MAP_FIXED_NOREPLACE MAP_FIXED
#endif
-// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only
diff erence
-// 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__
+// Some 32-bit architectures don't have mmap and define mmap2 instead. The only
+//
diff erence 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(SYS_mmap2) && !defined(SYS_mmap)
#define SYS_mmap SYS_mmap2
#endif
More information about the llvm-branch-commits
mailing list