This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Unify MBB reference format in both MIR and debug output
ClosedPublic

Authored by thegameg on Nov 24 2017, 3:33 AM.

Details

Summary

As part of the unification of the debug format and the MIR format, print MBB references as '%bb.5'.

The MIR printer prints the IR name of a MBB only for block definitions.

  • find . \( -name "*.cpp" -o -name "*.h" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#" << ([a-zA-Z0-9_]+)->getNumber\(\)/" << printMBBReference(*\1)/g'
  • find . \( -name "*.cpp" -o -name "*.h" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#" << ([a-zA-Z0-9_]+)\.getNumber\(\)/" << printMBBReference(\1)/g'
  • find . \( -name "*.txt" -o -name "*.s" -o -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#([0-9]+)/%bb.\1/g'
  • grep -nr 'BB#' and fix

This patch des not include tests because it exceeds the 8MB limit (even without context).

Diff Detail

Repository
rL LLVM

Event Timeline

thegameg created this revision.Nov 24 2017, 3:33 AM
MatzeB edited edge metadata.Nov 27 2017, 11:24 AM

One thing I always found odd with the MIR format is that all the MBB references repeated the IR name of the basic block. Even though it would be perfectly fine to only print the IR reference once where the block is defined and not for every reference.

How about changing printMBBReference() to never print the .name suffix and change the MI parser to optionally accept it to accomodate old .mir files, but new .mir files would not print it anymore in MBB references?

lib/CodeGen/BranchFolding.cpp
616–617 ↗(On Diff #124153)

Use printMBBReference()? The same applies to various other debug printers below.

thegameg updated this revision to Diff 125342.Dec 4 2017, 7:45 AM
thegameg edited the summary of this revision. (Show Details)
thegameg marked an inline comment as done.Dec 4 2017, 7:45 AM
MatzeB accepted this revision.Dec 4 2017, 7:56 AM

Thanks, LGTM.

lib/CodeGen/MachineScheduler.cpp
101 ↗(On Diff #125342)

I think you can leave the MBB# here to make it more clear that the argument is a number.

This revision is now accepted and ready to land.Dec 4 2017, 7:56 AM
This revision was automatically updated to reflect the committed changes.
thegameg marked an inline comment as done.