[ORC] Make a narrowing conversion explicit.
authorLang Hames <lhames@gmail.com>
Fri, 13 Nov 2020 09:09:38 +0000 (20:09 +1100)
committerLang Hames <lhames@gmail.com>
Fri, 13 Nov 2020 09:11:19 +0000 (20:11 +1100)
llvm/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h

index f63dcd0..b498661 100644 (file)
@@ -59,7 +59,7 @@ public:
       auto I = HostAllocs.find(Seg);
       assert(I != HostAllocs.end() && "No host allocation for segment");
       auto &HA = I->second;
-      return {HA.Mem.get(), HA.Size};
+      return {HA.Mem.get(), static_cast<size_t>(HA.Size)};
     }
 
     JITTargetAddress getTargetMemory(ProtectionFlags Seg) override {
@@ -153,6 +153,9 @@ public:
     HostAllocMap HostAllocs;
 
     for (auto &KV : Request) {
+      assert(KV.second.getContentSize() <= std::numeric_limits<size_t>::max() &&
+             "Content size is out-of-range for host");
+
       RMR.push_back({orcrpctpc::toWireProtectionFlags(
                          static_cast<sys::Memory::ProtectionFlags>(KV.first)),
                      KV.second.getContentSize() + KV.second.getZeroFillSize(),