The GitHub Actions job "tvm-bot" on tvm.git/main has succeeded.
Run started by GitHub user tqchen (triggered by tqchen).

Head commit for run:
665362007552268547526b78d20e2b304e9ef278 / llpan 
<[email protected]>
[ROCm] Fix some ROCm codegen bugs (#15518)

## Problem

`CodeGenLLVM::AllocateSharedMemory` calls `llvm::Align(alignment)` (for
LLVM >= 10), but `llvm::Align` requires a non-zero, power-of-2 value and
will trigger an assertion failure if given `0`.

This crash can be triggered on ROCm when allocating dynamic shared
memory. In `codegen_amdgpu.cc`, the dynamic shared memory path calls:

```cpp
buf = AllocateSharedMemory(op->dtype, 0, 3, std::min(info.alignment, 16),
                           llvm::GlobalValue::ExternalLinkage);
```

`info.alignment` is looked up from `alloc_storage_info_`, which defaults
to `0` if no alignment annotation has been set on the buffer. So
`std::min(0, 16) = 0` is passed as the alignment argument, leading to:

```cpp
global->setAlignment(llvm::Align(0));  // assertion failure: alignment must be 
non-zero
```

## Fix

Replace `llvm::Align(alignment)` with `llvm::MaybeAlign(alignment)`.
`llvm::MaybeAlign` treats `0` as "no explicit alignment specified"
(equivalent to `std::nullopt`), which is safe and correct — LLVM will
use the type's ABI alignment instead.

```cpp
// Before
global->setAlignment(llvm::Align(alignment));
// After
global->setAlignment(llvm::MaybeAlign(alignment));
```

Report URL: https://github.com/apache/tvm/actions/runs/22492227861

With regards,
GitHub Actions via GitBox


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

Reply via email to