LLVM Discussion Forums

Parent operation for spv.EntryPoint

Hi all,

I am trying to get a corresponding spv.Module from the given spv.EntryPoint. For example:

module {
  spv.module Logical GLSL450 {
    spv.func @empty() "None" {
      spv.Return
    }
    spv.EntryPoint "GLCompute" @empty
    spv.ExecutionMode @empty "LocalSize", 1, 1, 1
  }
}

However, I found out that running

spirv::EntryPointOp entryPointOp = ...
auto p = entryPointOp.getParentOp();

yields p to be MLIR module op, rather than SPIR-V module. Based on the documentation

/// Return the parent operation this region is attached to.
Operation *getParentOp();

it seems that spv.EntryPoint is attached to the region of MLIR module? Why is it so?

Thanks,
George

It would be surprising to me that getParentOp is broken given it’s used by so many places. I don’t think we have special treatment regarding getParentOp in spv.EntryPoint either… Could you double check that the IR is actually as expected (for example, during some transformation procedure, etc.) and there is no accidental typo or something (like double getting parent ops, etc.)?

Indeed it was a transformation that was changing spv.module :upside_down_face:, so I was getting a module instead. Thanks!