[llvm] 82909f4 - [llvm-exegesis] Define SYS_mmap to be SYS_mmap2 on 32-bit ARM

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 26 13:54:35 PDT 2023


Author: Aiden Grossman
Date: 2023-06-26T20:54:15Z
New Revision: 82909f4e0529a0ac26adbd05eda7244b11d99cba

URL: https://github.com/llvm/llvm-project/commit/82909f4e0529a0ac26adbd05eda7244b11d99cba
DIFF: https://github.com/llvm/llvm-project/commit/82909f4e0529a0ac26adbd05eda7244b11d99cba.diff

LOG: [llvm-exegesis] Define SYS_mmap to be SYS_mmap2 on 32-bit ARM

llvm-exegesis currently isn't compiling on 32-bit ARM due to SYS_mmap
not being defined as 32-bit ARM instead uses SYS_mmap2. This patch
defines SYS_mmap to be SYS_mmap2 in the relevant places to allow for
compilation to succeed.

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 04e753b3e12c6..9be178b77f70e 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -46,7 +46,11 @@
 namespace llvm {
 namespace exegesis {
 
+#ifdef __arm__
+static constexpr const intptr_t VAddressSpaceCeiling = 0xC0000000;
+#else
 static constexpr const intptr_t VAddressSpaceCeiling = 0x0000800000000000;
+#endif
 
 // If a positive value is specified, we are going to use the LBR in
 // latency-mode.
@@ -1079,6 +1083,14 @@ 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__
+#define SYS_mmap SYS_mmap2
+#endif
+
 std::vector<MCInst>
 ExegesisX86Target::generateMmap(intptr_t Address, size_t Length,
                                 intptr_t FileDescriptorAddress) const {

diff  --git a/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
index baee336a9f00c..092feb164ed2d 100644
--- a/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
@@ -627,6 +627,14 @@ 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__
+#define SYS_mmap SYS_mmap2
+#endif
+
 TEST_F(X86Core2TargetTest, GenerateMmapTest) {
   EXPECT_THAT(State.getExegesisTarget().generateMmap(0x1000, 4096, 0x2000),
               ElementsAre(IsMovImmediate(X86::MOV64ri, X86::RDI, 0x1000),


        


More information about the llvm-commits mailing list