This is an archive of the discontinued LLVM Phabricator instance.

Reverse order in which base and derived pointers are lowered in the statepoint StackMap section
ClosedPublic

Authored by igor-laevsky on May 6 2015, 6:21 AM.

Details

Summary

According to the documentation in StackMap section for the statepoint we should have:

The first Location in each pair describes the base pointer for the object. The second is the derived pointer actually being relocated.

But actually in the code we emit them in reverse order - derived pointer first, base pointer second.

This change fixes this problem and updates test cases to check ordering.

Diff Detail

Repository
rL LLVM

Event Timeline

igor-laevsky retitled this revision from to Reverse order in which base and derived pointers are lowered in the statepoint StackMap section.
igor-laevsky updated this object.
igor-laevsky edited the test plan for this revision. (Show Details)
igor-laevsky set the repository for this revision to rL LLVM.
igor-laevsky added a subscriber: Unknown Object (MLST).
reames edited edge metadata.May 6 2015, 11:30 AM

I generally approve of the intent of the change. Comments inline.

p.s. Once we LGTM this, please hold off on submission until at least Monday of next week. I want interested parties to have a chance to see this.

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
480–481

I would prefer to see this loop structured analogously to the other one you changed. As this change illustrates, the modulo trick here is unnecessarily complex and subject to mistakes.

test/CodeGen/X86/statepoint-stackmap-format.ll
11–12

This is an invalid test. An argument can not be a derived pointer. This is currently utterly unsupported.

You should create ptr_derived by bitcasting or gepping from the existing argument.

reames requested changes to this revision.May 6 2015, 11:30 AM
reames edited edge metadata.
This revision now requires changes to proceed.May 6 2015, 11:30 AM
igor-laevsky edited edge metadata.

Restructured spill slot reserve loop and fixed test.

igor-laevsky added inline comments.May 7 2015, 9:41 AM
test/CodeGen/X86/statepoint-stackmap-format.ll
11–12

I fixed this test, but I am still not clear what do you mean by unsupported? It is true that in code generated with RewriteStatepointForGC pass we can not have such derived pointers. But from the lowering standpoint it does not make any difference how derived pointer were made. Also from the quick glance at the documentation I have not found that such cases are not supported. What am I missing?

reames added inline comments.May 11 2015, 1:22 PM
test/CodeGen/X86/statepoint-stackmap-format.ll
11–12

Hm, you're completely right here. I was confusing what RewriteStatepointsForGC knows how to handle with what the lowering code is required to handle. There's no reason the lowering code shouldn't handle this case correctly.

Can you add another test (copying what you had originally is fine) with a comment that explicitly says that? If I or someone else try to implement something under my broken assumption above, it would be good to have a test case to catch that.

reames accepted this revision.May 11 2015, 1:22 PM
reames edited edge metadata.

LGTM

This revision is now accepted and ready to land.May 11 2015, 1:22 PM
igor-laevsky closed this revision.May 12 2015, 6:15 AM

Committed revision 237126.