Skip to content

Adjust addKernelEntryPoint after https://github.com/llvm/llvm-project/pull/115821 #3115

Open
@MrSidims

Description

@MrSidims

After this change clang generates for this OpenCL code:

kernel void Test() {}

following LLVM IR:

; Function Attrs: convergent noinline norecurse nounwind optnone
define dso_local spir_kernel void @Test() #0 !kernel_arg_addr_space !5 !kernel_arg_access_qual !5 !kernel_arg_type !5 !kernel_arg_base_type !5 !kernel_arg_type_qual !5 {
  call spir_func void @__clang_ocl_kern_imp_Test() #1
  ret void
}

; Function Attrs: convergent noinline norecurse nounwind optnone
define dso_local spir_func void @__clang_ocl_kern_imp_Test() #0 !kernel_arg_addr_space !5 !kernel_arg_access_qual !5 !kernel_arg_type !5 !kernel_arg_base_type !5 !kernel_arg_type_qual !5 {
  ret void
}

which means, that the translator will translate it to this (note that now module contains 3 functions):

; SPIR-V
; Version: 1.0
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 12
; Schema: 0
               OpCapability Addresses
               OpCapability Linkage
               OpCapability Kernel
          %1 = OpExtInstImport "OpenCL.std"
               OpMemoryModel Physical32 OpenCL
               OpEntryPoint Kernel %9 "Test"
               OpSource OpenCL_C 300000
               OpName %Test "Test"
               OpName %__clang_ocl_kern_imp_Test "__clang_ocl_kern_imp_Test"
               OpDecorate %Test LinkageAttributes "Test" Export
               OpDecorate %__clang_ocl_kern_imp_Test LinkageAttributes "__clang_ocl_kern_imp_Test" Export
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
       %Test = OpFunction %void DontInline %3
          %5 = OpLabel
          %7 = OpFunctionCall %void %__clang_ocl_kern_imp_Test
               OpReturn
               OpFunctionEnd
%__clang_ocl_kern_imp_Test = OpFunction %void DontInline %3
          %8 = OpLabel
               OpReturn
               OpFunctionEnd
          %9 = OpFunction %void DontInline %3
         %10 = OpLabel
         %11 = OpFunctionCall %void %Test
               OpReturn
               OpFunctionEnd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions