[JITLink] Fix Wtype-limits gcc warning (NFC)
authorYang Fan <nullptr.cpp@gmail.com>
Fri, 5 Mar 2021 07:27:10 +0000 (15:27 +0800)
committerYang Fan <nullptr.cpp@gmail.com>
Fri, 5 Mar 2021 07:28:01 +0000 (15:28 +0800)
GCC warning:
```
In file included from /usr/include/c++/9/cassert:44,
from /home/vsts/work/1/llvm-project/llvm/include/llvm/ADT/BitVector.h:21,
from /home/vsts/work/1/llvm-project/llvm/include/llvm/Support/Program.h:17,
from /home/vsts/work/1/llvm-project/llvm/include/llvm/Support/Process.h:32,
from /home/vsts/work/1/llvm-project/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp:11:
/home/vsts/work/1/llvm-project/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp: In member function ‘virtual llvm::Expected<std::unique_ptr<llvm::jitlink::JITLinkMemoryManager::Allocation> > llvm::jitlink::InProcessMemoryManager::allocate(const llvm::jitlink::JITLinkDylib*, const SegmentsRequestMap&)’:
/home/vsts/work/1/llvm-project/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp:129:40: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
129 |   assert(SlabRemaining.allocatedSize() >= 0 && "Mapping exceeds allocation");
    |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
```

The return type of `allocatedSize()` is `size_t`, thus the expression
`SlabRemaining.allocatedSize() >= 0` always evaluate to `true`.

llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp

index 7a5d36a..63a9b7b 100644 (file)
@@ -126,7 +126,6 @@ InProcessMemoryManager::allocate(const JITLinkDylib *JD,
     Blocks[KV.first] = std::move(SegMem);
   }
 
-  assert(SlabRemaining.allocatedSize() >= 0 && "Mapping exceeds allocation");
   return std::unique_ptr<InProcessMemoryManager::Allocation>(
       new IPMMAlloc(std::move(Blocks)));
 }