This is an archive of the discontinued LLVM Phabricator instance.

[MIR] Fix out of bounds access in MIRPrinter.
ClosedPublic

Authored by dfukalov on Oct 27 2020, 8:23 AM.

Details

Summary

Fixes: SWDEV-256460

Diff Detail

Event Timeline

dfukalov created this revision.Oct 27 2020, 8:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2020, 8:23 AM
dfukalov requested review of this revision.Oct 27 2020, 8:23 AM
arsenm added inline comments.Oct 27 2020, 9:11 AM
llvm/lib/CodeGen/MIRPrinter.cpp
91–92

Why does the index need to be stored? It seems like the problem is the printer/parser implicitly deleting dead objects

llvm/test/CodeGen/MIR/AMDGPU/stack-id-assert.mir
15–21

Don't need the IR section

117–181

Most of the mir fields can be eliminated

221

You should only need a single block with the spill instructions

dfukalov updated this revision to Diff 301352.Oct 28 2020, 11:22 AM

Addressed comments.

dfukalov marked 4 inline comments as done.Oct 28 2020, 11:29 AM
dfukalov added inline comments.
llvm/lib/CodeGen/MIRPrinter.cpp
91–92

The issue was that IDs stored in FrameIndexOperand are not the same numbers as offsets in YMF.StackObjects and YMF.FixedStackObjects vectors, since they doesn't contain dead objects.

So I added mapping ID -> storage offset. They are stored in temporary FixedStackObjectsIdx and StackObjectsIdx within MIRPrinter::convertStackObjects.

arsenm accepted this revision.Oct 28 2020, 11:31 AM
arsenm added inline comments.
llvm/test/CodeGen/MIR/AMDGPU/stack-id-assert.mir
3

Should mention why with dead objects

This revision is now accepted and ready to land.Oct 28 2020, 11:31 AM
dfukalov updated this revision to Diff 301569.Oct 29 2020, 4:34 AM
dfukalov marked an inline comment as done.

Addressed comments.

dfukalov marked an inline comment as done.Oct 29 2020, 4:34 AM
This revision was landed with ongoing or failed builds.Oct 29 2020, 4:35 AM
This revision was automatically updated to reflect the committed changes.