llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[NVPTX] Integer kernel parameters between 65 and 127 bits hit llvm_unreachable

Open snarang181 opened this issue 2 months ago • 2 comments

Summary

An integer kernel parameter wider than 64 bits and narrower than 128 crashes llc with llvm_unreachable("Integer too large") in NVPTXAsmPrinter::getPTXFundamentalTypeStr . i128 parameters, and globals or non-kernel arguments of the same widths, are handled.

Reproducer

target triple = "nvptx64-nvidia-cuda"

define ptx_kernel void @k(i96 %p, ptr %o) {
  store i96 %p, ptr %o
  ret void
}

At 620a9e9afaae:

$ llc -mcpu=sm_80 repro.ll -o /dev/null
UNREACHABLE executed at llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp:1805

Agent Analysis

shouldPassAsArray (NVPTXUtilities.h:71-74) routes scalars to the byte-array parameter form only when getScalarSizeInBits() >= 128, so 65–127-bit kernel parameters fall through to getPTXFundamentalTypeStr, which can only spell widths up to 64 and asserts. Either widen the array threshold to > 64, passing them like i128 as an aligned .b8[N] of the alloc size (which is what the surrounding emitFunctionParamList code already does for the ≥128 case), or reject them with a diagnostic instead of crashing.

follow-up to #225261 / #226113, which fixes the ≤64-bit case

snarang181 avatar Sep 24 '26 18:09 snarang181

Is anyone working on it or can i work on it??

Joeljm1 avatar Sep 24 '26 20:09 Joeljm1

Opened #226328 — routes scalar params wider than 64 bits through the byte-array param form already used for i128+, which closes the 65–127-bit gap that hits llvm_unreachable("Integer too large").

iliasabk avatar Sep 24 '26 23:09 iliasabk