This is an archive of the discontinued LLVM Phabricator instance.

VirtRegMap: Preserve LiveDebugVariables
ClosedPublic

Authored by arsenm on Dec 5 2018, 9:06 AM.

Details

Reviewers
MatzeB
qcolombet
Summary

This avoids recomputing it between regalloc runs.

Diff Detail

Event Timeline

arsenm created this revision.Dec 5 2018, 9:06 AM
qcolombet added inline comments.Feb 25 2019, 8:35 AM
lib/CodeGen/VirtRegMap.cpp
274 ↗(On Diff #176842)

DebugVars may be nullptr IIRC what getAnalysisIfAvailable API does.

Make sure to test for it.

arsenm updated this revision to Diff 313459.Dec 22 2020, 5:50 PM

Rebase and fix null check

Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2020, 5:50 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
qcolombet added inline comments.Jan 7 2021, 9:50 AM
llvm/lib/CodeGen/VirtRegMap.cpp
273

I think we should push the test on DebugVars before this block.
Otherwise

  1. we won't clear the VRM and MRI when DebugVars are not present.
  2. we won't emit the debug values all the time (but maybe that's ok?)

I.e.,

if (DebugVars)
  DebugVars->emitDebugValues(VRM).

if (ClearVirtRegs) {
  VRM->clearAllVirt();
  MRI->clearAllVirt();
}
qcolombet added inline comments.Jan 7 2021, 9:53 AM
llvm/lib/CodeGen/VirtRegMap.cpp
273
  1. we won't emit the debug values all the time (but maybe that's ok?)

Looks like it would be okay, since you had:

if (!ClearVirtRegs)
   AU.addPreserved<LiveDebugVariables>();

Still, it is okay to assume ClearVirtRegs will be set eventually. E.g., what happens for WebAssembly?

arsenm added inline comments.Jan 7 2021, 4:32 PM
llvm/lib/CodeGen/VirtRegMap.cpp
273

I think this was to avoid double-emitting the debug values, since this will be run twice

arsenm updated this revision to Diff 342487.May 3 2021, 11:56 AM

Add comment and test for double emission

arsenm added inline comments.May 3 2021, 11:56 AM
llvm/lib/CodeGen/VirtRegMap.cpp
273

Without this, the debug values end up getting emitted twice. It doesn't matter for webassembly since the allocator passes are never run

qcolombet accepted this revision.May 24 2021, 5:32 PM
This revision is now accepted and ready to land.May 24 2021, 5:32 PM