Skip to content

[BUG] Regression in CDNA2 AMDGPU kernel compilation between 0.26.3.0.dev2026041605 and 0.26.3.0.dev2026041716: empty kernel crashes with target-incompatible DataLayout #6451

@BenWibking

Description

@BenWibking

Bug description

Summary

Compiling a minimal GPU kernel with DeviceContext.compile_function() crashes in LLVM AMDGPU codegen with:

LLVM ERROR: Can't create a MachineFunction using a Module with a Target-incompatible DataLayout attached

This is a regression in the Mojo nightly compiler.

Regression range

Bisected on the same machine and environment.

  • Last good: Mojo 0.26.3.0.dev2026041605 (418f4e71)
  • First bad: Mojo 0.26.3.0.dev2026041716 (11668061)

Also confirmed bad:

  • Mojo 0.26.3.0.dev2026042005 (32e188d3)
  • Mojo 0.26.3.0.dev2026042205 (3d57fbb2)
  • Mojo 0.26.3.0.dev2026042305 (d2fb2839)
  • Mojo 1.0.0b1.dev2026042317 (3d4362b4)

Expected behavior

The empty GPU kernel should compile successfully.

Actual behavior

Compilation crashes during AMDGPU instruction selection:

Stack dump:

  1. Running pass 'CallGraph Pass Manager' on module 'empty_kernel.mojo'.
  2. Running pass 'AMDGPU DAG->DAG Pattern Instruction Selection' on function '@empty_kernel_kernel_empty6A6AoApA'
  LLVM ERROR: Can't create a MachineFunction using a Module with a Target-incompatible DataLayout attached
    Target DataLayout: e-m:e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-
  p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9
    Module DataLayout: e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-
  i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9

Steps to reproduce

Minimal reproducer

Single-file reproducer:

  from std.gpu.host import DeviceContext


  def kernel_empty():
      pass


  def main() raises:
      var ctx = DeviceContext()
      _ = ctx.compile_function[kernel_empty, kernel_empty]()

Repro command

mojo build amdgpu_empty_kernel.mojo -o /tmp/amdgpu_empty_kernel

This same reproducer:

  • succeeds on 0.26.3.0.dev2026041605
  • crashes on 0.26.3.0.dev2026041716

Notes

  • An empty kernel compiled via DeviceContext.compile_function() is sufficient to trigger the crash.
  • The failure appears specific to AMDGPU codegen.

System information

Pixi env:

System
------------
       Pixi version: 0.63.2
        TLS backend: rustls
           Platform: linux-64
   Virtual packages: __unix=0=0
                   : __linux=6.4.0=0
                   : __glibc=2.38=0
                   : __archspec=1=zen3
          Cache dir: /ccs/home/wibking/.cache/rattler/cache
       Auth storage: /ccs/home/wibking/.rattler/credentials.json
   Config locations: No config files found

Global
------------
            Bin dir: /ccs/home/wibking/.pixi/bin
    Environment dir: /ccs/home/wibking/.pixi/envs
       Manifest dir: /ccs/home/wibking/.pixi/manifests/pixi-global.toml

Workspace
------------
               Name: mojo-amrex
            Version: 0.1.0
      Manifest file: /autofs/nccs-svm1_home1/wibking/mojo-amrex/pixi.toml
       Last updated: 23-04-2026 14:46:49

Environments
------------
        Environment: default
           Features: default
           Channels: https://conda.modular.com/max-nightly, conda-forge
   Dependency count: 7
       Dependencies: mojo, openmpi, jupyterlab, ipykernel, sidecar, matplotlib, ipympl
   Target platforms: linux-64, osx-arm64, linux-aarch64
    Prefix location: /autofs/nccs-svm1_home1/wibking/mojo-amrex/.pixi/envs/default
              Tasks: run-multifab-smoke-mojo-gpu, test-mojo-multifab-mpi, configure, test-mpi, build-multifab-smoke, build-capi-mpi, install-amrex, run-multifab-smoke, install-capi, build-multifab-smoke-mojo-gpu, test-mojo-runtime-mpi, test-mojo-runtime, run-multifab-mpi-exchange, package-mojo, test-capi, run-multifab-smoke-script, configure-mpi, build-capi, test, format-mojo, configure-cray-mpich, install-amrex-cray-mpich, bootstrap-cray-mpich, test-mojo, bootstrap, mojo, build-tests, build-capi-cray-mpich, test-mojo-multifab, install-mojo-package, build-tests-cray-mpich, test-capi-mpi, build-tests-mpi, run-multifab-smoke-mojo-gpu-script

Mojo version:

Name           Version                Build         Size  Kind   Source
mojo           1.0.0b1.dev2026042317  release  89.59 MiB  conda  https://conda.modular.com/max-nightly
mojo-compiler  1.0.0b1.dev2026042317  release  84.94 MiB  conda  https://conda.modular.com/max-nightly
mojo-python    1.0.0b1.dev2026042317  release  22.64 KiB  conda  https://conda.modular.com/max-nightly

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmojoIssues that are related to mojo

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions