This is an archive of the discontinued LLVM Phabricator instance.

[RewriteStatepointsForGC] Remove the hardcoded GC strategy names
AbandonedPublic

Authored by znix on Dec 20 2022, 10:55 PM.

Details

Summary

Previously, RewriteStatepointsForGC had a hardcoded list of GC
strategies for which it would run, and using it with a custom strategy
required patching LLVM.

The locic for selecting the variables that are considered managed was
also hardcoded to use pointers in address space 1, rather than
delegating to GCStrategy::isGCManagedPointer.

This patch fixes both of these flaws: this pass now applies to all
functions whose GCStrategy returns true for useStatepoints, and checking
if a pointer is managed or not is also now done by the strategy.

One potentially questionable design decision in this change: the pass will
be enabled for all GC strategies that use statepoints. It seems unlikely
this would be a problem - consumers that don't use this pass probably
aren't adding it to the pass manager anyway - but if you had two different
GC strategies and only one wants this pass enabled then that'd need a new
flag in GCStrategy, which I can add if anyone thinks it's necessary.

Diff Detail

Event Timeline

znix created this revision.Dec 20 2022, 10:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2022, 10:55 PM
znix requested review of this revision.Dec 20 2022, 10:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2022, 10:55 PM
znix added a comment.Dec 21 2022, 12:01 AM

I'm not sure why the tests are failing? It looks like a linkage issue:

LLVM ERROR: unsupported GC: statepoint-example (did you remember to link and initialize the library?)

I'm not sure why this would occur in the tests, but not locally. I built with BUILD_SHARED_LIBS which I'm guessing has something to do with it, but llvm/lib/IR/BuiltinGCs.cpp (where the statepoint-example GC registration is located) is in LLVMCore so I'd expect it to always be initialised?

I'm not sure why the tests are failing? It looks like a linkage issue:

LLVM ERROR: unsupported GC: statepoint-example (did you remember to link and initialize the library?)

I'm not sure why this would occur in the tests, but not locally. I built with BUILD_SHARED_LIBS which I'm guessing has something to do with it, but llvm/lib/IR/BuiltinGCs.cpp (where the statepoint-example GC registration is located) is in LLVMCore so I'd expect it to always be initialised?

This exact issue prevented me from landing similar patch in the past. And I did not figure out what was going on there.
static initializers are definitely running, but at the time RS4GC runs relevant array is zeroed (is BSS initialization happens _after_ C++ static initializers? or we have multiple copies?)
Unfortunately I had not enough time to find out.

znix abandoned this revision.Jan 5 2023, 11:09 PM

This diff was superseded by D141110.