This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InstrRef] Fix a tombstone-in-DenseMap crash from D117877
ClosedPublic

Authored by jmorse on Feb 1 2022, 10:32 AM.

Details

Summary

This is a follow up to D117877: variable assignments of DBG_VALUE $noreg, or DBG_INSTR_REFs where no value can be found, are represented as a DbgValue object with Kind "Undef". This explicitly represents "There is no value for this, and never can be". In D117877 I added a special-case to make some assignment accounting faster, without considering this scenario. It causes variables to be given the value ValueIDNum::EmptyValue, which would fail gracefully and wouldn't produce an illegal location, it'd just be discarded. However, recently that value began being entered into a DenseMap, where it's a tombstone value, causing assertions.

This patch handles that scenario and adds a regression test. The more general fix is to wrap DbgValue's ID field in Optional<>, just like the MachineOperand field is, but I'm aiming for the minimal fix right now :(

Diff Detail

Event Timeline

jmorse created this revision.Feb 1 2022, 10:32 AM
jmorse requested review of this revision.Feb 1 2022, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2022, 10:32 AM

Seems reasonable as a fix to me. Is there any particular reason that the undef value test couldn't exist within the original function, or are they separated to look cleaner? YMMV and I don't feel strongly either way, so LGTM.

StephenTozer accepted this revision.Feb 2 2022, 3:54 AM
This revision is now accepted and ready to land.Feb 2 2022, 3:54 AM
jmorse added a comment.Feb 2 2022, 6:39 AM

Is there any particular reason that the undef value test couldn't exist within the original function, or are they separated to look cleaner? YMMV and I don't feel strongly either way, so LGTM.

I suppose if the DBG_VALUE $noreg was given for a different variable then that would work, I just didn't think of that. It would indeed be slightly simpler, but IMO not simpler enough to revise.

This revision was landed with ongoing or failed builds.Feb 2 2022, 7:09 AM
This revision was automatically updated to reflect the committed changes.