hbarve1/tessl-llvm/add-gc-statepoints
Claude Code and agent skill by hbarve1/tessl-llvm
- community
Checking that the SKILL.md file is still in the repository.
Add garbage-collection support to an LLVM 22 IR frontend. Covers the shadow-stack (gcroot) model for simple GCs and the statepoint/gc.relocate model for moving/relocating collectors, including the RewriteStatepointsForGC pass and StackMap section.
Install
npx vskill@latest install hbarve1/tessl-llvm/add-gc-statepointsSKILL.md
The same SKILL.md was published earlier as hbarve1/tessl-llvm/add-gc-statepoints.
Skill: Add GC Support to an LLVM Frontend (LLVM 22)
Use this skill when your language runtime needs a garbage collector and you must tell LLVM where GC-safe points are and which pointers are live.
Step 0 — Choose a model
| Model | Use when | |
|---|---|---|
| gcroot / shadow stack | Simple stop-the-world GC, prototype, or interpreter. Easy to implement. | |
| Statepoints | Moving/relocating collector (objects can be copied). Production use. |
For new language runtimes, prefer statepoints — gcroot is legacy and does not support moving objects.
Model A: gcroot (shadow stack)
Step A1 — Set the GC strategy on functions
Step A2 — Mark GC root allocas
Every heap-pointer local variable needs a root alloca in the entry block:
Step A3 — Use the root across GC points
Step A4 — Link the shadow-stack runtime
You must supply a shadow-stack runtime (or link against one). Minimal C structure:
Model B: Statepoints (relocating GC)
Step B1 — Set the GC strategy on functions
Step B2 — Use RewriteStatepointsForGC pass (recommended)
Let the pass automatically insert gc.statepoint + gc.relocate sequences around all calls:
The pass:
- Finds all calls in functions with a GC strategy.
- Computes live GC pointer sets at each call.
- Rewrites calls to
gc.statepoint+gc.relocatesequences. - Emits StackMap metadata.
After this pass, every GC pointer use after a call site is replaced with a gc.relocate result.
Step B3 — Manual statepoint emission (advanced / understanding only)
If you emit statepoints manually instead of using the pass:
The C++ API equivalent:
Step B4 — Read the StackMap section
After compiling, the object file contains a __llvm_stackmaps section:
Your GC runtime reads this section at startup to discover the locations of all live pointers at each GC-safe point.
Step B5 — Custom GC strategy (optional)
Register a custom strategy for code generation hooks:
Functions with gc "my-gc" will use it during codegen.
Verifying the output
Common mistakes
- Never use a pointer variable after a statepoint — always use the
gc.relocateresult. The original pointer is invalid if the GC moved the object. - Never apply
RewriteStatepointsForGCwithout first callingF->setGC(...)— the pass silently skips functions without a GC strategy. - Never mix gcroot and statepoints in the same module — they are incompatible.
- Always initialize root allocas to
nullbefore the firstgcrootcall. - Always reload GC roots after any call that may trigger collection (gcroot model).
- Always use
gc.relocatefor every live GC pointer across a statepoint — not just the ones you think are "interesting" to the optimizer.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtiles/tessl-llvm/skills/add-gc-statepoints/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hbarve1/tessl-llvm/add-gc-statepoints)