[llvm-branch-commits] [llvm] 284570a - [llvm-jitlink] Fix detectStubKind() for big endian systems (#79970)

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 1 13:43:56 PST 2024


Author: Stefan Gränitz
Date: 2024-02-01T13:42:56-08:00
New Revision: 284570a985e95e3d8118cde2b0198bbbdc9b19ad

URL: https://github.com/llvm/llvm-project/commit/284570a985e95e3d8118cde2b0198bbbdc9b19ad
DIFF: https://github.com/llvm/llvm-project/commit/284570a985e95e3d8118cde2b0198bbbdc9b19ad.diff

LOG: [llvm-jitlink] Fix detectStubKind() for big endian systems (#79970)

This function is used in `jitlink-check` lines in LIT tests. In #78371 I
missed to swap initial instruction bytes for systems that store the
constants as big-endian.

(cherry picked from commit 8a5bdd899f3cb57024d92b96c16e805ca9924ac7)

Added: 
    

Modified: 
    llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index b2a133860197d..769ed17ac4cbd 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1294,10 +1294,11 @@ class MemoryMatcher {
 };
 
 static StringRef detectStubKind(const Session::MemoryRegionInfo &Stub) {
-  constexpr uint32_t Armv7MovWTle = 0xe300c000;
-  constexpr uint32_t Armv7BxR12le = 0xe12fff1c;
-  constexpr uint32_t Thumbv7MovWTle = 0x0c00f240;
-  constexpr uint16_t Thumbv7BxR12le = 0x4760;
+  using namespace support::endian;
+  auto Armv7MovWTle = byte_swap<uint32_t, endianness::little>(0xe300c000);
+  auto Armv7BxR12le = byte_swap<uint32_t, endianness::little>(0xe12fff1c);
+  auto Thumbv7MovWTle = byte_swap<uint32_t, endianness::little>(0x0c00f240);
+  auto Thumbv7BxR12le = byte_swap<uint16_t, endianness::little>(0x4760);
 
   MemoryMatcher M(Stub.getContent());
   if (M.matchMask(Thumbv7MovWTle)) {


        


More information about the llvm-branch-commits mailing list