This is an archive of the discontinued LLVM Phabricator instance.

[SPIRV] fix several issues in builds with expensive checks
ClosedPublic

Authored by iliya-diyachkov on Feb 27 2023, 10:52 AM.

Details

Summary

The patch fixes "Virtual register does not match instruction constraint" and partly "Illegal virtual register for instruction" fails in SPIRV backend builds with LLVM_ENABLE_EXPENSIVE_CHECKS enabled. As a result the number of passed LIT tests with the enabled checks is increased from 59 to 120.

Also, support for ndrange_1D/ndrange_2D/ndrange_3D builtins is placed in a separate function.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 10:52 AM
iliya-diyachkov requested review of this revision.Feb 27 2023, 10:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 10:52 AM
iliya-diyachkov edited the summary of this revision. (Show Details)Feb 27 2023, 10:58 AM
arsenm added inline comments.Feb 27 2023, 12:14 PM
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
392

I'd expect the class to never be set at this point (if not, I'd expect it to be always set)

llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
392

18 LIT tests will fail if I remove this setRegClass(). On other hand, I found calls with register classes already set here in 27 LIT tests.
So I suppose it makes sense to leave this check and setting.

zuban32 added inline comments.Mar 1 2023, 4:17 AM
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
392

@arsenm could you pls elaborate? Is it supposed to be set later (if so, where)? I thought CallLowering being a part of IRTranslator is a perfect place to set reg classes as vregs have just been created

arsenm added inline comments.Mar 1 2023, 4:34 AM
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
392

If the instruction had a register constraint it should have been set to begin with. You are fixing up invalid mir after the fact

@iliya-diyachkov I checked the half / vstore_half_rtn test manually and it seems to work just fine. Looks like we just got one flaky run for some reason.

iliya-diyachkov marked an inline comment as done.Mar 7 2023, 4:18 PM
iliya-diyachkov added inline comments.
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
392

I removed this fixing and added the required setRegClasss in SPIRVBuiltins.cpp. Now we set reg classes only when replacing calls with machine instructions.

iliya-diyachkov marked an inline comment as done.Mar 7 2023, 4:21 PM

@iliya-diyachkov I checked the half / vstore_half_rtn test manually and it seems to work just fine. Looks like we just got one flaky run for some reason.

Thanks, Michal. However we need to retest the patch since changes in buildScopeReg and buildMemSemanticsReg can affect some tests.

mpaszkowski accepted this revision.Mar 9 2023, 4:37 PM

Let's wait for the CTS testing results before pushing, but the patch LGTM! Thank you @iliya-diyachkov!

This revision is now accepted and ready to land.Mar 9 2023, 4:37 PM
This revision was landed with ongoing or failed builds.Mar 16 2023, 1:19 PM
This revision was automatically updated to reflect the committed changes.