This is an archive of the discontinued LLVM Phabricator instance.

Debug prefix map for machine code emission
ClosedPublic

Authored by starsid on Jul 5 2018, 12:14 PM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

starsid created this revision.Jul 5 2018, 12:14 PM
starsid updated this revision to Diff 154282.Jul 5 2018, 12:15 PM

Align comments

compnerd added inline comments.Jul 5 2018, 3:02 PM
include/llvm/MC/MCContext.h
503 ↗(On Diff #154282)

clang-format please - your & are bound to the wrong side

lib/MC/MCContext.cpp
538 ↗(On Diff #154282)

please clang-format this - your & are bound to the wrong side.

lib/MC/MCDwarf.cpp
405 ↗(On Diff #154282)

mmm, should this really apply to the compilation directory?

406 ↗(On Diff #154282)

Since you are changing the line, please make this const auto &.

starsid updated this revision to Diff 154331.Jul 5 2018, 4:11 PM
starsid marked 4 inline comments as done.

use LLVM style for clang-format

starsid added inline comments.Jul 5 2018, 4:11 PM
lib/MC/MCDwarf.cpp
405 ↗(On Diff #154282)

I think so, the point is to remap all paths so that the binary can be made to have the same digest irrespective of the source root.

I checked with gcc and they do the same for assembly files.

curl -O https://golang.org/src/runtime/cgo/gcc_amd64.S
gcc -g -c gcc_amd64.S -o gcc_amd64 && strings gcc_amd64 | grep $PWD 
gcc -g -c gcc_amd64.S -o gcc_amd64 -fdebug-prefix-map=$PWD= && strings gcc_amd64 | grep $PWD
starsid updated this revision to Diff 154352.Jul 5 2018, 10:22 PM

add flag to llvm-mc and test logic through llvm-mc

starsid updated this revision to Diff 154481.Jul 6 2018, 7:25 PM

Simplify code.

  • Remap DWARF dirs in place before calling Emit.
  • Remap compilation dir in place before calling Emit.

In-place editing ensures we did not miss a place, and simplifies lifecycle
management of the strings.

The option is available only through llvm-mc and cc1as.

All regression tests pass.

[100%] Running the LLVM regression tests
Testing Time: 171.72s
  Expected Passes    : 25615
  Expected Failures  : 149
  Unsupported Tests  : 667

Some minor things. clang-format-diff is your friend. :-)

include/llvm/MC/MCContext.h
497 ↗(On Diff #154481)

This looks longer than 80 columns. clang-format-diff will fix this kind of thing for you.
Or use a typedef for the map.

lib/MC/MCContext.cpp
538 ↗(On Diff #154481)

80-column violation?

test/MC/ELF/debug-prefix-map.s
5 ↗(On Diff #154481)

Can you omit the -dwarf-version 5 as I think this should work for any version.

starsid updated this revision to Diff 154668.Jul 9 2018, 11:58 AM
starsid marked 3 inline comments as done.

Line length limit to 80. Remove -dwarf-version from test.

starsid added inline comments.Jul 9 2018, 11:59 AM
include/llvm/MC/MCContext.h
497 ↗(On Diff #154481)

Oh I did not know about clang-format-diff. Thank you.

It could be useful to configure clang-format as a linter for arcanist, if most people use arcanist for code reviews. I can send in a patch for that if you want.

We started using 100 as the line length limit in my organization, so I tend to not notice the 80 column violations anymore. Thank you for pointing these out.

probinson accepted this revision.Jul 9 2018, 12:44 PM

LGTM.

If you have the interest and knowledge to automate clang-format-diff with arcanist, I'm sure there are many people who would be very happy to see a patch. I don't use arcanist but I know others do.

This revision is now accepted and ready to land.Jul 9 2018, 12:44 PM

LGTM.

If you have the interest and knowledge to automate clang-format-diff with arcanist, I'm sure there are many people who would be very happy to see a patch. I don't use arcanist but I know others do.

Thank you. I do not have write permissions for the repo, so will you please commit this for me.

For the linter, I have sent D49116 to you.

This revision was automatically updated to reflect the committed changes.