This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] fix crash in IRTranslator, MachineIRBuilder when translating @llvm.dbg.value intrinsic and using -debug
ClosedPublic

Authored by gargaroff on Mar 27 2020, 9:13 AM.

Details

Summary

Fix crash when using -debug caused by the GlobalISel observer trying to print
an incomplete DBG_VALUE instruction. This was caused by the MachineIRBuilder
using buildInstr, which immediately inserts the instruction causing print,
instead of using BuildMI to first build up the instruction and using
insertInstr when finished.

Add RUN-line to existing debug-insts.ll test with -debug flag set to make sure
no crash is happening.

Also fixed a missing %s in the 2nd RUN-line of the same test.

Diff Detail

Event Timeline

gargaroff created this revision.Mar 27 2020, 9:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2020, 9:13 AM
arsenm added a subscriber: arsenm.Mar 27 2020, 9:33 AM
arsenm added inline comments.
llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
100

buildInstrNoInsert?

use buildInstrNoInsert instead of BuildMI

gargaroff marked 2 inline comments as done.Mar 30 2020, 12:11 AM
gargaroff added inline comments.
llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
100

Thanks! Didn't realize that there is such a helper.

gargaroff marked an inline comment as done.Apr 7 2020, 12:40 AM

Ping

I've updated the reviewers, since this is obviously not going forward otherwise. Hope it's ok with all of you!

arsenm accepted this revision.Jun 10 2020, 10:08 AM
This revision is now accepted and ready to land.Jun 10 2020, 10:08 AM
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.
llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
3

-debug needs REQUIRES: asserts

I fixed it.

gargaroff marked an inline comment as done.Jun 11 2020, 11:37 PM
gargaroff added inline comments.
llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
3

Thank you very much! I wasn't aware of this.