How to handle pointer relocation in LLVM?

Hello! I’m working on simple jvm jit compiler based on llvm.

My backend itself does not generate any safepoints, so pointer relocation can not happen while executiong my functions. But when I call hotspot intrinsics like operator “new” it already contains a safepoint and after returning from this call, all pointers could be reallocated.

To handle this I need to tell JVM where my pointers are (stack offsets or registers) for every “new” call.

I’ve never wrote any passes that happen after register allocation, so I would really appreciate if you could tell me some ideas what llvm infrastructure could I use to do this.

P.S. I,ve already seen this page
Garbage Collection Safepoints in LLVM — LLVM 17.0.0git documentation, but I don’t think I need all that complexity with abstract machine, I want something simple. And to be honest, I really want to make it myself, just to learn more llvm :slight_smile: