llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Improve Debug instruction support in SIFrameLowering

Open VladimirMedic opened this issue 6 months ago • 6 comments

Summary

This PR improves debug information (DI) handling in SIFrameLowering to ensure proper metadata preservation during register spilling operations.

Changes

  • Enhanced debug info tracking for spill operations
  • Common code moved from SILowerSGPRSpills.cpp to SISpillUtils.cpp and SISpillUtils.h
  • Existing test case improved

VladimirMedic avatar May 19 '26 11:05 VladimirMedic

PSDB Build Link: http://mlse-bdc-20dd129:8065/#/builders/6/builds/189

z1-cciauto avatar May 19 '26 11:05 z1-cciauto

@slinder1 @mariusz-sikora-at-amd Could you please review this PR when you have a chance?

VladimirMedic avatar May 19 '26 11:05 VladimirMedic

PSDB Build Link: http://mlse-bdc-20dd129:8065/#/builders/6/builds/192

z1-cciauto avatar May 20 '26 08:05 z1-cciauto

PSDB Build Link: http://mlse-bdc-20dd129:8065/#/builders/6/builds/193

z1-cciauto avatar May 20 '26 12:05 z1-cciauto

PSDB Build Link: http://mlse-bdc-20dd129:8065/#/builders/6/builds/204

rocm-cciapp[bot] avatar Jun 05 '26 07:06 rocm-cciapp[bot]

PSDB Build Link: http://mlse-bdc-20dd129:8065/#/builders/6/builds/207

rocm-cciapp[bot] avatar Jun 09 '26 13:06 rocm-cciapp[bot]

Hi @VladimirMedic, thank you for looking into this! I'm sorry, but I actually ended up doing something really similar here: #3423 (I didn't see this PR before now). My version also handles dwarf ops for the vpgr->agpr spill case, so I think it makes more sense to move forward with that one. Maybe you could review it if you have the time?

epilk avatar Jul 31 '26 19:07 epilk

Hi @VladimirMedic, thank you for looking into this! I'm sorry, but I actually ended up doing something really similar here: #3423 (I didn't see this PR before now). My version also handles dwarf ops for the vpgr->agpr spill case, so I think it makes more sense to move forward with that one. Maybe you could review it if you have the time?

Hi @epilk , My change was basically just moving the code from SILowerSGPRSpills to SISpillUtils, plus one change which fixes assertion when Lane * 8 exceeds int8 value, while your goes further and actually fixes the problems in implementation. So, it does make more sense to continue with your change. I am looking into it and will comment if I find anything during review. Also, I made changes in dead-frame-index-dbg-value.ll as the initial test was actually never hitting the breakpoint in clearDebugInfoForSpillFIs(and updateDbgValueInstsForSpillFIs consequently) and it was introduced as a test case for that implementation in a first place. In my PR it was extended to actually make a spill and enter it. I see that it was also changed in the amd-debug branch, so it may be worth checking if it actually reaches the desired function.

VladimirMedic avatar Aug 03 '26 11:08 VladimirMedic

Sorry for the delay in reviewing here, I had intended to compare with Emma's work and give a recommendation on how to merge the two, but didn't get to it in a timely fashion (I'm still trying to get a workflow with GitHub that actually works, I feel like I'm perpetually unorganized since GH doesn't let you control the "viewed" status)

I think I agree that anything covered here which is not in Emma's change should be adapted to work there.

slinder1 avatar Aug 03 '26 16:08 slinder1

There is nothing that this patch does more in functional sense than Emma's, only the dead-frame-index-dbg-value.ll test might be considered for merging there. Everything else can be stated as a review comment in #3423 since we started from the same code.

VladimirMedic avatar Aug 04 '26 14:08 VladimirMedic

There is nothing that this patch does more in functional sense than Emma's, only the dead-frame-index-dbg-value.ll test might be considered for merging there. Everything else can be stated as a review comment in #3423 since we started from the same code.

I think the changes to dead-frame-index-dbg-value.ll should go to llvm-project main, since the test is there too. Agree that it isn't actually testing anything without your updates though.

epilk avatar Aug 04 '26 18:08 epilk

I think the changes to dead-frame-index-dbg-value.ll should go to llvm-project main, since the test is there too. Agree that >it isn't actually testing anything without your updates though. Not sure it can go there, these changes rely on SIFrameLowering calling updateDbgValueInstsForSpillFIs instead of clearDebugInfoForSpillFIs, so if move test only it would probably fail.

VladimirMedic avatar Aug 05 '26 07:08 VladimirMedic

@slinder1 @epilk I would like to close this PR, so would it make sense to merge dead-frame-index-dbg-value.ll in another one? Would be easier than rebasing this.

VladimirMedic avatar Aug 06 '26 15:08 VladimirMedic

Closing this PR as the code is committed in https://github.com/ROCm/llvm-project/pull/3423. Still need to decide what happens with test and how will that be merged.

VladimirMedic avatar Aug 14 '26 08:08 VladimirMedic