This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Use MBB.begin() instead MBB.front() in NVPTXFrameLowering::emitPrologue
ClosedPublic

Authored by xgupta on Aug 25 2022, 7:59 AM.

Details

Summary

The second argument of NVPTXFrameLowering::emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) is the first MBB of the MF. In that function, it assumes the first MBB always contains instructions, so it gets the first instruction by MachineInstr *MI = &MBB.front();. However, with the reproducer/test case attached, all instructions in the first MBB is cleared in a previous pass for stack coloring. As a consequence, MBB.front() triggers the assertion that the first node is actually a sentinel node. Hence we are using MachineBasicBlock::iterator to iterate over MBB.

Fix #52623.

Diff Detail

Event Timeline

xgupta created this revision.Aug 25 2022, 7:59 AM
xgupta requested review of this revision.Aug 25 2022, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 7:59 AM

I will have to reduce the test case attached in bug report and add that here, so patch is WIP, any suggestion on that would be very helpful. Thanks.

tra added a comment.Aug 25 2022, 10:25 AM

The changes look reasonable to me.

xgupta updated this revision to Diff 459301.Sep 10 2022, 12:02 PM

Add reduced test case of crash

xgupta updated this revision to Diff 459303.Sep 10 2022, 12:30 PM

Add CHECK line in test case

tra accepted this revision.Sep 12 2022, 11:39 AM

LGTM with a test nit.

llvm/test/CodeGen/NVPTX/bug52623.ll
10

Considering that there are no meaningful CHECK lines in the test, it may be worth adding a comment describing what it is that we're testing for here.

This revision is now accepted and ready to land.Sep 12 2022, 11:39 AM
llvm/test/CodeGen/NVPTX/bug52623.ll
2

Do we need to run the FileCheck here?

xgupta updated this revision to Diff 459646.Sep 12 2022, 10:25 PM

Add descriptive comment about the issue in test case and remove FileCheck.

xgupta marked 2 inline comments as done.Sep 12 2022, 10:26 PM