This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] GPUToSPIRVPass: support case when `TargetEnv` attribute attached to the `gpu.module`
ClosedPublic

Authored by Hardcode84 on Oct 13 2022, 12:18 PM.

Details

Summary

Previously, only case when TargetEnv was attached to the top level ModuleOp was supported.

Diff Detail

Event Timeline

Hardcode84 created this revision.Oct 13 2022, 12:18 PM
Hardcode84 requested review of this revision.Oct 13 2022, 12:18 PM

fix use-after-free bug

antiagainst requested changes to this revision.Oct 13 2022, 11:35 PM

Thanks! Generally LGTM; I just have one question actually.

mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
342

The spirv.target_env should only be needed when _converting to_ SPIR-V? Once that's done we are in SPIR-V land already; it should not be necessary anymore. So curious why would you need to copy it over?

This revision now requires changes to proceed.Oct 13 2022, 11:35 PM
Hardcode84 added inline comments.Oct 14 2022, 1:42 AM
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
342

Some of the patterns (specifically GPUFuncOpConversion) calls lookupTargetEnvOrDefault themselves during conversion and they won't find it if they run after GPUModuleConversion. Also we will need to preserve it if we ever decide to switch to progressive lowering.

antiagainst accepted this revision.Oct 14 2022, 2:43 AM
antiagainst added inline comments.
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
342

Good points. Would mind to put the above as comments so later we know why this is needed? Thanks!

This revision is now accepted and ready to land.Oct 14 2022, 2:43 AM

update comment