This is an archive of the discontinued LLVM Phabricator instance.

[AsmPrinter] Print aliases in topological order
ClosedPublic

Authored by timshen on Mar 31 2016, 10:35 AM.

Details

Reviewers
echristo
kbarton
Summary

Print aliases in topological order, that is, for any alias a = b,
b must be printed before a. This is because on some targets (e.g. PowerPC)
linker expects aliases in such an order to generate correct TOC information.

For example, on PowerPC, GCC will produce following symbol:

~ % readelf -s tcmalloc_gcc.pic.o|grep '_Znam\b'
  1057: 00000000000001e4   100 FUNC    GLOBAL DEFAULT [<localentry>: 8]   508 _Znam

But LLVM without this change will produce:

~ % readelf -s tcmalloc_llvm.pic.o|grep '_Znam\b'
   870: 0000000000000000   100 FUNC    GLOBAL DEFAULT   94 _Znam

I'm not sure if it's the right change, since I don't know who is supposed to do this ordering.

Diff Detail

Event Timeline

timshen updated this revision to Diff 52236.Mar 31 2016, 10:35 AM
timshen retitled this revision from to [AsmPrinter] Print aliases in topological order.
timshen updated this object.
timshen added a reviewer: kbarton.
timshen updated this object.
echristo accepted this revision.Mar 31 2016, 2:51 PM
echristo added a reviewer: echristo.

This seems to be as good as anywhere else to do this.

It's also crazy, but well spotted. One inline nit.

-eric

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
1199

Nit: No braces around single conditionals.

This revision is now accepted and ready to land.Mar 31 2016, 2:51 PM
timshen updated this revision to Diff 52296.Mar 31 2016, 3:11 PM
timshen marked an inline comment as done.
timshen edited edge metadata.

Removed unnecessary braces.

timshen closed this revision.Mar 31 2016, 3:14 PM

Thanks!