This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InstrRef] Fix a broken substitution method, add test coverage
ClosedPublic

Authored by jmorse on Jul 12 2021, 8:32 AM.

Details

Summary

This patch fixes a clearly-broken function that I absent-mindedly bodged many months ago.

Over in D85749 I landed the substituteDebugValuesForInst, that creates substitution records for all the def operands from one debug-labelled instruction to the new one. Unfortunately it would crash if the two instructions had different numbers of operands; I tried to fix this in 537f0fbe82 by adding a "max operand" parameter to the method, but then didn't actually change the loop bound to take account of this. It passed all the tests because.... well there wasn't any real test coverage of this method.

This patch fixes up the loop to be bounded by the MaxOperand bound; and adds test coverage for the x86-fixup-LEAs calls to this method, so that it's actually tested.

Ooops.

Diff Detail

Event Timeline

jmorse created this revision.Jul 12 2021, 8:32 AM
jmorse requested review of this revision.Jul 12 2021, 8:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2021, 8:32 AM
Orlando accepted this revision.Jul 20 2021, 1:17 AM
Orlando added a subscriber: Orlando.

The tests look good. LGTM!

llvm/test/DebugInfo/MIR/InstrRef/x86-lea-fixup-2.mir
4

nit: It loos like this file is just testing LEA => ADD (rather than LEA <=> ADD), or am I missing something?

41

What is this comment for?

llvm/test/DebugInfo/MIR/InstrRef/x86-lea-fixup.mir
6

I'm finding it difficult to understand this opening sentence and nit: labeles -> labels

This revision is now accepted and ready to land.Jul 20 2021, 1:17 AM
jmorse added inline comments.Jul 20 2021, 3:37 AM
llvm/test/DebugInfo/MIR/InstrRef/x86-lea-fixup-2.mir
4

I guess the comment is misleading; between the two files, all instances of eraseFromParent (and the substitute calls I put in at those sites) are covered. They're in two different files because we need to cover both i386 and x86_64. I'll fiddle with the comments to reflect this.

41

Reminding myself what flags were required to stimulate the substitution -- hence this file targets i386, but tunes the cpu to corei7. I'll delete this when committing.

llvm/test/DebugInfo/MIR/InstrRef/x86-lea-fixup.mir
6

Rewriting when landing.

This revision was landed with ongoing or failed builds.Jul 20 2021, 3:45 AM
This revision was automatically updated to reflect the committed changes.