Skip to content

Commit

Permalink
[llvm-jitlink] Fix detectStubKind() for big endian systems (#79970)
Browse files Browse the repository at this point in the history
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 8a5bdd8)
  • Loading branch information
weliveindetail authored and tstellar committed Feb 1, 2024
1 parent 0eb163c commit 284570a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 284570a

Please sign in to comment.