[all-commits] [llvm/llvm-project] de0c36: [llvm][SPIRV] Add pass to lower Ctors/Dtors for SP...

Alex Duran via All-commits all-commits at lists.llvm.org
Tue Mar 24 14:47:33 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: de0c366e4b7224f33d2945194035d21501e3d636
      https://github.com/llvm/llvm-project/commit/de0c366e4b7224f33d2945194035d21501e3d636
  Author: Alex Duran <alejandro.duran at intel.com>
  Date:   2026-03-24 (Tue, 24 Mar 2026)

  Changed paths:
    M llvm/lib/Target/SPIRV/CMakeLists.txt
    M llvm/lib/Target/SPIRV/SPIRV.h
    A llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.cpp
    A llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.h
    M llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
    A llvm/test/CodeGen/SPIRV/ctor-dtor-lowering-ir.ll
    A llvm/test/CodeGen/SPIRV/ctor-dtor-lowering.ll
    A llvm/test/CodeGen/SPIRV/ctor-dtor-no-openmp-ir.ll
    M llvm/test/CodeGen/SPIRV/llc-pipeline.ll

  Log Message:
  -----------
  [llvm][SPIRV] Add pass to lower Ctors/Dtors for SPIRV (#187509)

This PR adds a new SPIRV pass that generates a kernel named
"spirv$device$init" that iterates the pointers in the table pointed by
__init_array_start and __init_array_end and executes them. It also
generates symbols for each constructor with the form
__init_array_object_NAME_PRIORITY.

These symbols will be used by the Level Zero plugin in the liboffload
runtime (with the support introduced by #187510) to generate the
aforementioned table as spirv-link cannot create the table itself.

It also does the same thing for destructors, with the kernel name being
"spirv$device$fini", the table pointers __fini_array_start and
__fini_array_end, and the generated symbols prefix __fini_array_object.

The code was mostly generated by Claude 4.5 and has been reviewed by me
to the best of my ability.



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