diff options
| author | David Spickett <david.spickett@linaro.org> | 2021-09-03 12:27:05 +0000 |
|---|---|---|
| committer | David Spickett <david.spickett@linaro.org> | 2021-09-03 12:30:56 +0000 |
| commit | 02b462034875dcf8f73b80d746e1fe40cdb22fd6 (patch) | |
| tree | 24ca395ca4a7470d9d86002a432816b242cb8c0b | |
| parent | 6fe2beba7d2a41964af658c8c59dd172683ef739 (diff) | |
[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.
| -rw-r--r-- | llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp | 8 | ||||
| -rw-r--r-- | llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp index 2925660207b3..012ff73fc8e5 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 @@ 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>( diff --git a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp index 4d9b01b0c2d6..186aa75b4966 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) |
