[Mlir-commits] [mlir] [mlir][llvm] Fix negative GEP crash in type consistency (PR #74859)
Tobias Gysi
llvmlistbot at llvm.org
Fri Dec 8 08:37:53 PST 2023
================
@@ -161,7 +161,10 @@ static std::optional<uint64_t> gepToByteOffset(DataLayout &layout, GEPOp gep) {
IntegerAttr indexInt = llvm::dyn_cast_if_present<IntegerAttr>(index);
if (!indexInt)
return std::nullopt;
- indices.push_back(indexInt.getInt());
+ int32_t gepIndex = indexInt.getInt();
+ if (gepIndex < 0)
+ return std::nullopt;
+ indices.push_back((uint32_t)gepIndex);
----------------
gysit wrote:
```suggestion
indices.push_back(static_cast<uint32_t>(gepIndex));
```
nit: can you use a C++ cast rather than a C style cast.
https://github.com/llvm/llvm-project/pull/74859
More information about the Mlir-commits
mailing list