This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix debug values in scheduler not placed correctly when reverting
ClosedPublic

Authored by vangthao on Feb 4 2022, 10:44 AM.

Details

Summary

Debug position data is cleared after ScheduleDAGMILive::schedule() due to it also calling placeDebugValues(). Make it so the data is not cleared after initial call to placeDebugValues since we will call it again after reverting a schedule.

Secondly, since we skip debug instructions when reverting the schedule on AMDGPU, all debug instructions are now moved to the end of the scheduling region. RegionEnd points to the beginning of this chunk of debug instructions since it was not incremented when a debug instruction was skipped. RegionBegin may also point to the same debug instruction if Unsched.front() is a debug instruction thus shrinking the region to 1. Fix RegionBegin and RegionEnd so that they point to the current beginning and ending before calling placeDebugValues() since both vars will be used as reference points to move debug instructions back.

Diff Detail

Event Timeline

vangthao created this revision.Feb 4 2022, 10:44 AM
vangthao requested review of this revision.Feb 4 2022, 10:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2022, 10:44 AM
rampitec added inline comments.Feb 4 2022, 11:35 AM
llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
469

Formatting.

vangthao updated this revision to Diff 406070.Feb 4 2022, 12:31 PM

Fix formatting.

This revision is now accepted and ready to land.Feb 4 2022, 12:50 PM
This revision was landed with ongoing or failed builds.Feb 7 2022, 11:04 AM
This revision was automatically updated to reflect the committed changes.
kerbowa added inline comments.Feb 10 2022, 4:38 PM
llvm/lib/CodeGen/MachineScheduler.cpp
927

Does this mean the machine schedule will now iterate through all debug instructions for the function when scheduling each region?

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
469

Do we need to specifically track the number of skipped debug instructions, or can we just advance RegionEnd until we stop seeing debug instructions?

vangthao added inline comments.Feb 14 2022, 9:05 AM
llvm/lib/CodeGen/MachineScheduler.cpp
927

These two variables are only used when moving debug instructions back after scheduling is finished. This does not change the way the machine scheduler handle debug instructions.

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
469

I think skipping pass debug instructions until you reach a non-debug or the end of the block may also work.