LLVM 22.x tile for building compilers, language runtimes, and out-of-tree tooling
88
83%
Does it follow best practices?
Impact
96%
1.23xAverage score across 5 eval scenarios
Passed
No known issues
Use this skill when the user needs a new or customized ABI for a target inside the LLVM tree, or when an out-of-tree frontend must choose among existing conventions and attributes.
Scope boundary: Truly new register/stack rules require target TableGen + lowering changes inside LLVM. Out-of-tree projects that only consume an installed LLVM should not expect to add a global CallingConv::ID without rebuilding LLVM.
| Goal | Where to work |
|---|---|
| Use standard C/fast call on existing target | IR only: setCallingConv, parameter attributes |
| Language needs special struct return / copies | sret, byval, inalloca, alignment attrs |
| New register/stack layout for a target | In-tree: CallingConv.h, *CallingConv.td, *ISelLowering.cpp |
| Document/embedder custom protocol | Often metadata + existing CC, or a dedicated in-tree target fork |
Read calling-conventions.md for terminology (CCState, CCValAssign, related IR features).
llvm::CallingConv::ID that matches the platform (usually C or Fast).llvm::Function and on CallInst/InvokeInst, call setCallingConv.sret, byval, nest, swiftself, etc.) per LangRef.verifyModule and compile with llc (or your driver) for the intended triple.F->setCallingConv(CallingConv::C);
F->addParamAttrs(0, ParamAttrBuilder...); // e.g. ByVal, StructRetIf this satisfies the ABI, stop—no TableGen work needed.
llvm/include/llvm/IR/CallingConv.h.LangRef.rst) with the spelling and number.switch (CC) exhaustiveness warnings in tree.*CallingConv.td)llvm/lib/Target/X86/X86CallingConv.td (pattern: Target/*/*CallingConv.td).def / multiclass instance for your convention that hooks CCAssignFn-style logic the same way sibling conventions do.cmake --build --target <Target>CommonTableGen or full target build)—never hand-edit *Gen*.inc.If you are unsure which multiclass to extend, clone the closest existing convention (e.g. a variant of Fast) and adjust register/stack rules incrementally.
In the target’s *ISelLowering.cpp (and related files):
LowerFormalArguments — handle the new CallingConv when assigning incoming values to SDValues / registers.LowerCall / LowerCallTo — match outgoing call setup (caller-side).CanLowerReturn / LowerReturn — return-value rules (registers, sret, multiple values).Use CCState / CCValAssign consistently with the TableGen side. Mismatches here cause silent ABI bugs.
Search the target for getCallingConv() / callconv dispatch to find existing patterns.
If Clang (or another frontend) must expose the convention:
setCallingConv on the IR function and calls..ll showing call/define with the new cc number or name (as printed by LLVM).Run llvm-lit on the new files.
[ ] CallingConv enum value unique and documented
[ ] TableGen + generated inc files regenerated
[ ] LowerFormalArguments / LowerCall / LowerReturn updated
[ ] Varargs path considered (if applicable)
[ ] Clang/frontend mapping (if user-facing)
[ ] lit tests for IR + machine level
[ ] Compared against platform ABI doc or psABIYou cannot complete Steps 2–4 from a standalone plugin; they live in the LLVM target sources. Out-of-tree frontends should:
CallingConv values and attributes, and/orcc without matching backend assignment logic.docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
add-alias-analysis
add-attributes-metadata
add-calling-convention
add-debug-info
add-exception-handling
add-gc-statepoints
add-intrinsic
add-lto
add-sanitizer
add-vectorization-hint
frontend-to-ir
jit-setup
lit-filecheck
lower-struct-types
new-target
out-of-tree-setup
tessl-llvm
version-sync