[all-commits] [llvm/llvm-project] 6b85e6: [CIR][CUDA] Read fat binary in CIRGen and store it...

Konstantinos Parasyris via All-commits all-commits at lists.llvm.org
Sat Sep 26 07:17:32 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6b85e67a473ebe127aa31b742adc1fe2d53cb5bf
      https://github.com/llvm/llvm-project/commit/6b85e67a473ebe127aa31b742adc1fe2d53cb5bf
  Author: Konstantinos Parasyris <koparasy at gmail.com>
  Date:   2026-09-26 (Sat, 26 Sep 2026)

  Changed paths:
    M clang/include/clang/CIR/Dialect/IR/CIRCUDAAttrs.td
    M clang/include/clang/CIR/Dialect/IR/CIRDialect.td
    M clang/lib/CIR/CodeGen/CIRGenCUDANV.cpp
    M clang/lib/CIR/CodeGen/CIRGenModule.cpp
    M clang/lib/CIR/Dialect/IR/CIRDialect.cpp
    M clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
    M clang/test/CIR/CodeGenCUDA/device-stub.cu
    A clang/test/CIR/CodeGenCUDA/missing-gpubinary.cu
    A clang/test/CIR/Diagnostics/mlir-error-routing.cpp
    R clang/test/CIR/Diagnostics/mlir-error-routing.cu
    A clang/test/CIR/IR/invalid-cuda-device-binary.cir

  Log Message:
  -----------
  [CIR][CUDA] Read fat binary in CIRGen and store its bytes on the module (#225971)

Two problems with the current implementation of GPU CIR:

1. `LoweringPrepare` read the fat binary from disk, via
`astCtx->getSourceManager().getFileManager().getVirtualFileSystem()`. A
   transform pass should not do I/O, and this is one of the `ASTContext`
   dependencies that keeps the post-CIRGen pipeline from being IR-to-IR.
Some of the related discussion on this has been done
[here](https://discourse.llvm.org/t/rfc-clangir-making-cir-pipeline-boundaries-first-class-driver-artifacts/90998)
and PR: #219048
2. `#cir.cu.binary_handle` stored the *file path*. That's a build input,
not a
property of the program: it bakes one machine's directory layout into a
   `.cir`.

The PR removes the file path and adds an attribute
CIRGen now reads the file in and records the contents 
as `#cir.cu.device_binary`, a `StringAttr` of raw bytes. The
attribute is deleted once LoweringPrepare "consumes" it. 

A couple of notes:
1. The GPU dialect has a similar representation. We may want to move
towards that direction slowly, but I don't see any value doing this now.
It will confuse the direction of this PR. 
2. The test `clang/test/CIR/Diagnostics/mlir-error-routing.cu` has
completely
changed, because it relied on an error occurring when the file attribute
was missing.
Since we deleted that attribute completely, the test was failing.

---------

Co-authored-by: Claude Opus 5 <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list