Commit 02b46203 authored by David Spickett's avatar David Spickett
Browse files

[ORC] Static cast more uint64_t to size_t

These instances don't have an obvious way to fail
nicely so I've just asserted they are within range.

Fixes the Arm 32 bit builds.
parent 6fe2beba
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@
#include "llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/LookupAndRecordAddrs.h"

#include <limits>

namespace llvm {
namespace orc {

@@ -32,7 +34,8 @@ public:
  MutableArrayRef<char> getWorkingMemory(ProtectionFlags Seg) override {
    auto I = Segs.find(Seg);
    assert(I != Segs.end() && "No allocation for seg");
    return {I->second.WorkingMem, I->second.ContentSize};
    assert(I->second.ContentSize <= std::numeric_limits<size_t>::max());
    return {I->second.WorkingMem, static_cast<size_t>(I->second.ContentSize)};
  }

  JITTargetAddress getTargetMemory(ProtectionFlags Seg) override {
@@ -45,13 +48,14 @@ public:
    char *WorkingMem = WorkingBuffer.get();
    tpctypes::FinalizeRequest FR;
    for (auto &KV : Segs) {
      assert(KV.second.ContentSize <= std::numeric_limits<size_t>::max());
      FR.push_back(tpctypes::SegFinalizeRequest{
          tpctypes::toWireProtectionFlags(
              static_cast<sys::Memory::ProtectionFlags>(KV.first)),
          KV.second.TargetAddr,
          alignTo(KV.second.ContentSize + KV.second.ZeroFillSize,
                  Parent.EPC.getPageSize()),
          {WorkingMem, KV.second.ContentSize}});
          {WorkingMem, static_cast<size_t>(KV.second.ContentSize)}});
      WorkingMem += KV.second.ContentSize;
    }
    Parent.EPC.callSPSWrapperAsync<shared::SPSOrcTargetProcessFinalize>(
+4 −1
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
#include "llvm/Support/Memory.h"
#include "llvm/Testing/Support/Error.h"

#include <limits>

using namespace llvm;
using namespace llvm::orc;
using namespace llvm::orc::shared;
@@ -44,8 +46,9 @@ testFinalize(const char *ArgData, size_t ArgSize) {
                 memcpy(Mem, Seg.Content.data(), Seg.Content.size());
                 memset(Mem + Seg.Content.size(), 0,
                        Seg.Size - Seg.Content.size());
                 assert(Seg.Size <= std::numeric_limits<size_t>::max());
                 if (auto EC = sys::Memory::protectMappedMemory(
                         {Mem, Seg.Size},
                         {Mem, static_cast<size_t>(Seg.Size)},
                         tpctypes::fromWireProtectionFlags(Seg.Prot)))
                   return errorCodeToError(EC);
                 if (Seg.Prot & tpctypes::WPF_Exec)