[llvm] 02b4620 - [ORC] Static cast more uint64_t to size_t
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 3 05:31:23 PDT 2021
Author: David Spickett
Date: 2021-09-03T12:30:56Z
New Revision: 02b462034875dcf8f73b80d746e1fe40cdb22fd6
URL: https://github.com/llvm/llvm-project/commit/02b462034875dcf8f73b80d746e1fe40cdb22fd6
DIFF: https://github.com/llvm/llvm-project/commit/02b462034875dcf8f73b80d746e1fe40cdb22fd6.diff
LOG: [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.
Added:
Modified:
llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
index 2925660207b39..012ff73fc8e5b 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
@@ -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 @@ class EPCGenericJITLinkMemoryManager::Alloc
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 @@ class EPCGenericJITLinkMemoryManager::Alloc
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>(
diff --git a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
index 4d9b01b0c2d6d..186aa75b4966c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
@@ -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)
More information about the llvm-commits
mailing list