This is an archive of the discontinued LLVM Phabricator instance.

Track globals promoted to coalesced const pool entries
ClosedPublic

Authored by rinon on Jun 22 2017, 5:03 PM.

Details

Summary

Globals that are promoted to an ARM constant pool may alias with another
existing constant pool entry. We need to keep a reference to all globals that
were promoted to each constant pool value so that we can emit a distinct label
for each promoted global. These labels are necessary so that debug info can
refer to the promoted global without an undefined reference during linking.

Event Timeline

rinon created this revision.Jun 22 2017, 5:03 PM
rinon retitled this revision from Summary: Track globals promoted to coalesced const pool entries to Summary:Track globals promoted to coalesced const pool entries.Jun 22 2017, 5:04 PM
rinon edited the summary of this revision. (Show Details)
rinon retitled this revision from Summary:Track globals promoted to coalesced const pool entries to Track globals promoted to coalesced const pool entries.
rinon set the repository for this revision to rL LLVM.

Didn't realize llvm-commits needed to be added as a sub. Done now.

I just wanted to ping this patch and see if someone had time to review it. The bug seems fairly hard to trigger, but I have real code that can't build with LTO because of this problem (libXML2 linked statically into another lib, all built with LTO). I also have a reduced C test case, but the IR test is simpler.

Thanks in advance!

compnerd edited edge metadata.Jul 4 2017, 11:27 AM

Please trim down the test. I dont think that any of the debug info metadata is needed to validate the CPE is coalesced nor are the attributes.

lib/Target/ARM/ARMAsmPrinter.cpp
868–873

Shouldn't this be const auto *GV?

lib/Target/ARM/ARMConstantPoolValue.cpp
196

Please use C++ style casts (static_cast). Renaming the type doesn't offer much here, why not use auto?

211

This should probably be const auto * or const auto &.

lib/Target/ARM/ARMConstantPoolValue.h
179–180

If these aren't used right now, we could just inline them into the promotedGlobals call.

rinon updated this revision to Diff 105351.Jul 5 2017, 3:47 PM
rinon edited the summary of this revision. (Show Details)

Address review comments

  • Mark auto pointers explicitly const
  • Remove unncessary iterator begin and end functions
  • Remove debug info from IR test
rinon marked 3 inline comments as done.Jul 5 2017, 3:51 PM

Thanks for the review. I think I've addressed all comments.

I originally had the debug info in the IR test because I was also testing compiling the IR with clang to make sure the output binary could be linked. I've removed it now since it's not needed for the regression test.

rinon marked an inline comment as done.Jul 5 2017, 3:52 PM
rinon added a comment.Aug 7 2017, 5:33 PM

Just wanted to ping this review and see if it's ready for commit.

rinon added a comment.Aug 31 2017, 4:47 PM

Ping? Should be all ready to go.

compnerd accepted this revision.Aug 31 2017, 10:48 PM

LG with the further test changes.

test/CodeGen/ARM/constantpool-promote-duplicate.ll
2

Please add an explicit triple. It makes debugging things easier (when the test fails, the command itself is printed, and the host may be different).

4–5

I think that you can drop these. I dont think that there is anything Linux specific about this. I think that thumbv7-unknown-none-eabi is a better target.

27–28

Are the attributes really necessary? Im pretty sure that you should be able to drop them and the annotations.

This revision is now accepted and ready to land.Aug 31 2017, 10:48 PM
rinon updated this revision to Diff 114107.Sep 6 2017, 5:36 PM
  • Address review points
  • Remove debug info from IR test
  • Fix up test
rinon marked 3 inline comments as done.Sep 6 2017, 5:38 PM

Thanks, addressed test changes. Can someone commit this patch?

test/CodeGen/ARM/constantpool-promote-duplicate.ll
4–5

I used arm-eabi since it seems to be used in other ARM tests and this test doesn't depend on any thumb behavior. Is that alright?

Sure, I can commit it on your behalf.

test/CodeGen/ARM/constantpool-promote-duplicate.ll
4–5

The other tests using it isn't the best argument. However, armv7-eabi is as good as thumbv7-eabi in this case.

compnerd closed this revision.Sep 6 2017, 9:01 PM

SVN r312692