Repository navigation
Conversation
allocation should not be done in int unify between GPU and CPU Signed-off-by: Tobias Fuchs <[email protected]>
dimp-pl
added a commit
to dimp-pl/iree
that referenced
this pull request
Jul 23, 2026
`checkStackAllocationSize` accumulates the allocation size in a plain int64_t. Allocas sized by the upper bound of an unbounded dynamic dimension (the util.assume.int default, 2^53-1) overflow it, the wrapped value passes the limit check and the alloca reaches ConvertToLLVM, where its element count folds to llvm.mlir.poison and the program loads and stores through a garbage pointer at runtime. The reproduction was reduced from the quantized ResNet downsample construct: an ONNX model with a dynamic batch doing DequantizeLinear -> 1x1 stride-2 Conv compiles without diagnostics and returns completely wrong results. Move `getStaticShapeSizeInBits` to Codegen/Utils (taken from iree-org#24684) and use it from both LLVMCPUCheckIRBeforeLLVMConversion and GPUCheckResourceUsage. Callers supply the leaf element bit width, which lets the GPU check keep its index-bitwidth handling and the recursion into shaped element types. On the CPU side the remaining scalar steps are overflow-checked in place with `llvm::MulOverflow` / `llvm::AddOverflow`. The pre-existing `checkedAdd`/`checkedMul`/ `checkedAlignTo` wrappers in LLVMCPUAssignWorkgroupLocalMemory.cpp are likewise replaced with `llvm::MulOverflow` / `llvm::AddOverflow`. Signed-off-by: Zmicier Prybysh <[email protected]>
AGindinson
pushed a commit
that referenced
this pull request
Sep 4, 2026
…cks (#24745) `checkStackAllocationSize` accumulates the allocation size in a plain int64_t. Allocas sized by the upper bound of an unbounded dynamic dimension (the util.assume.int default, 2^53-1) overflow it, the wrapped value passes the limit check and the alloca reaches ConvertToLLVM, where its element count folds to llvm.mlir.poison and the program loads and stores through a garbage pointer at runtime. The reproduction was reduced from the quantized ResNet downsample construct: an ONNX model with a dynamic batch doing DequantizeLinear -> 1x1 stride-2 Conv compiles without diagnostics and returns completely wrong results. Move `getStaticShapeSizeInBits` to Codegen/Utils (taken from #24684) and use it from both LLVMCPUCheckIRBeforeLLVMConversion and GPUCheckResourceUsage. Callers supply the leaf element bit width, which lets the GPU check keep its index-bitwidth handling and the recursion into shaped element types. On the CPU side the remaining scalar steps are overflow-checked in place with `llvm::MulOverflow` / `llvm::AddOverflow`. The pre-existing `checkedAdd`/`checkedMul`/`checkedAlignTo` wrappers in LLVMCPUAssignWorkgroupLocalMemory.cpp are replaced with `llvm::MulOverflow` / `llvm::AddOverflow`. --------- Signed-off-by: Zmicier Prybysh <[email protected]>
Contributor
Author
|
fixed in a more general PR collab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
allocation size calculation should not be done in int
unify between GPU and CPU
Co-authored: Claude (which apprently loves lambdas)
needs a bit of cleanup