fallenmi opened a new pull request, #20141:
URL: https://github.com/apache/tvm/pull/20141

   Fixes #20125.
   
   ## What changed
   
   LLVM CPU code generation now keeps constant `AllocBuffer` extents as signed 
64-bit values through stack allocation emission instead of narrowing them to 
`int32_t`. The temporary-allocation alignment helper accepts the same width and 
avoids multiplying when a large allocation cannot reduce the requested 
alignment, preventing overflow in that calculation.
   
   This change is intentionally limited to the CPU `CodeGenLLVM` path. The 
separate NVPTX and AMDGPU overrides described in the issue remain out of scope.
   
   ## Why
   
   An extent of `2**32 + 1` previously wrapped to one before `CreateAlloca`, 
producing a one-element stack allocation followed by an `i64 4294967296` 
element access in unoptimized TIR-X LLVM IR. The generated module could 
therefore contain an out-of-bounds access even though the original extent was 
valid as an `int64_t`.
   
   The regression test only compiles and inspects LLVM IR; it does not execute 
or materialize the very large allocation. It covers extents that previously 
wrapped to one and four elements.
   
   ## Validation
   
   - New regression on the unmodified base: 2 failures
   - New regression after the fix: 2 passed
   - `tests/python/codegen/test_target_codegen_llvm.py`: 380 passed
   - Rebuilt all 65 affected C++ units, including the NVPTX and AMDGPU callers 
of the alignment helper
   - Changed-file pre-commit hooks and `git diff --check`: passed
   - Compile-only boundary probes through `INT64_MAX - 3`: exact `i64` 
allocation counts, with no allocation executed
   
   ## AI assistance
   
   This Draft PR was prepared with OpenAI Codex. The patch was derived from the 
repository and the issue's documented failure mode; no external third-party 
code was copied into the change.
   
   Generated-by: OpenAI Codex
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to