This is an archive of the discontinued LLVM Phabricator instance.

Introduce an example statepoint GC strategy
ClosedPublic

Authored by reames on Dec 29 2014, 9:41 PM.

Details

Summary

This change includes the most basic possible GCStrategy for a GC which is using the statepoint lowering code. At the moment, this GCStrategy doesn't really do much - aside from actually generate correct stackmaps that is - but I went ahead and added a few extra correctness checks as proof of concept. It's mostly here to provide documentation on how to do one, and to provide a point for various optimization legality hooks I'd like to add going forward. (For context, see the TODOs in InstCombine around gc.relocate.)

Note that I am deliberately not making a GCStrategy required to use gc.statepoints with this change. I want to give folks out of tree - including myself - a chance to migrate. In a week or two, I'll make having a GCStrategy be required for gc.statepoints. To this end, I added the gc tag to one of the test cases but not others.

Diff Detail

Event Timeline

reames updated this revision to Diff 17706.Dec 29 2014, 9:41 PM
reames retitled this revision from to Introduce an example statepoint GC strategy.
reames updated this object.
reames edited the test plan for this revision. (Show Details)
reames added reviewers: whitequark, sanjoy.
reames added a subscriber: Unknown Object (MLST).
whitequark accepted this revision.Dec 29 2014, 10:02 PM
whitequark edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 29 2014, 10:02 PM
reames updated this revision to Diff 17708.Dec 29 2014, 10:38 PM
reames edited edge metadata.

Previous diff did not include added file.

majnemer added inline comments.
include/llvm/CodeGen/GCStrategy.h
71–73

The other comments are formatted using ///<

Also, the layout of GCStrategy might be a little more compact if you shifted this field down.

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
429

There should be a space between the for and the (

lib/CodeGen/StatepointExampleGC.cpp
29

Space before and after =

39–40

If this is the case, why not just cast<PointerType> ?

44

Address space 1 has a special meaning in LLVM, it's identical to address space 0 except for the fact that "null" may be dereferenced. You might want to consider a different address space.

Will update with revisions.

include/llvm/CodeGen/GCStrategy.h
71–73

FYI, I'm going to be doing a fair amount of style/spacing cleanup once I'm done with the current round of changes. Ordering fields, updating doxygen comments, and the like will happen then.

lib/CodeGen/SelectionDAG/StatepointLowering.cpp
429

Thanks. Will fix this and other style comments.

lib/CodeGen/StatepointExampleGC.cpp
44

Er, where are you getting that from? All I see in the LangRef is that non-zero address spaces are target defined.

(p.s. I'm planning on raising this question separately on the mailing list at some point. Changing it shouldn't matter much.)

reames updated this revision to Diff 17720.Dec 30 2014, 8:48 AM

Responding to comments.

David, Peter - Since the patch was accidentally incomplete as of the last LGTM, can one of you confirm you're happy with the current form of patch?

artagnon added inline comments.
lib/CodeGen/StatepointExampleGC.cpp
2

Perhaps rename this to StatepointGC, to look like ErlangGC and OCamlGC?
Also, you need a llvm::linkStatepointGC() { } for anyone to use it. Please see "introduce link_gc_components" for an example of the work going in this direction.

reames added inline comments.Jan 5 2015, 10:43 AM
lib/CodeGen/StatepointExampleGC.cpp
2

It looks like I do need to update the file comment to the new name.

I would strongly prefer to keep the current name. This is *specifically* an example. It is not tied to any external GC. The Ocaml and Erlang ones have external dependences.

As for your second point, see line 53 in this file.

@reames, I don't know about Erlang (HiPE might actually use it), but the OCaml GC is currently just an example as well. It is not practically useful even for a hypothetical OCaml LLVM frontend.

reames added a comment.Jan 5 2015, 2:25 PM

I will rename/document that about the Ocaml GC strategy. I filled a bug
to track that here:
http://llvm.org/bugs/show_bug.cgi?id=22098

Philip

majnemer accepted this revision.Jan 6 2015, 3:44 PM
majnemer added a reviewer: majnemer.

LGTM.

I see you've left addrspace(1) in--is that intentional?

reames added a comment.Jan 6 2015, 3:50 PM

I see you've left addrspace(1) in--is that intentional?

Yes. So far, no one has clarified what addrspace(1) is used for. Given I'd need to update other tests, I'll do that in one change once the documentation is in place.

OK--LGTM from me if you still need it.

This revision was automatically updated to reflect the committed changes.