{"record":{"id":"230a2344057ffec0","repo":"oracle/graal","slug":"register-s-is-not-allocatable","errorCode":null,"errorMessage":"register %s is not allocatable","messagePattern":"register (.+?) is not allocatable","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/alloc/RegisterAllocationConfig.java","lineNumber":97,"sourceCode":"     * after the register name in the {@code spec}. In this case, {@code null} is returned instead\n     * of throwing an exception.\n     */\n    private static Register findRegister(String spec, List<Register> all) {\n        boolean optional = false;\n        String name = spec;\n        if (spec.endsWith(\"?\")) {\n            optional = true;\n            name = spec.substring(0, spec.length() - 1);\n        }\n        for (Register reg : all) {\n            if (reg.name.equals(name)) {\n                return reg;\n            }\n        }\n        if (optional) {\n            return null;\n        }\n        throw new IllegalArgumentException(\"register \" + name + \" is not allocatable\");\n    }\n\n    protected List<Register> initAllocatable(List<Register> registers) {\n        if (allocationRestrictedTo != null) {\n            Register[] regs = new Register[allocationRestrictedTo.length];\n            int i = 0;\n            for (String spec : allocationRestrictedTo) {\n                Register register = findRegister(spec, registers);\n                if (register == null) {\n                    regs = Arrays.copyOf(regs, regs.length - 1);\n                } else {\n                    regs[i++] = register;\n                }\n            }\n            return List.of(regs);\n        }\n\n        return registers;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/alloc/RegisterAllocationConfig.java#L79-L115","documentation":"RegisterAllocationConfig.findRegister resolves a register name (from the RegisterPressure option's comma-separated restriction list) against the set of allocatable registers for the target architecture. If the name matches no register and the spec is not marked optional with a trailing '?', it throws IllegalArgumentException('register <name> is not allocatable').","triggerScenarios":"Setting -Dgraal.RegisterPressure=rax,rbx,whatever on x86-64 where 'whatever' is not a register name, or copying a register list between architectures (e.g. x0-x28 AArch64 names used on AMD64, or vice versa). The optional form 'name?' returns null instead of throwing.","commonSituations":"Benchmark scripts or CI matrices that pin RegisterPressure for register-allocation experiments and are then run on a different architecture/container image; typos in register names; using platform register aliases (e.g. 'r13' vs 'sp' naming differences across Graal versions).","solutions":["Correct the register list to names valid for the target architecture — inspect the arch's Register class (e.g. AMD64.cpuRegisters / AArch64.cpuRegisters) for the canonical names.","Remove -Dgraal.RegisterPressure entirely if you did not intend to restrict allocation.","Append '?' to a spec (e.g. 'k?' on AArch64) when a register may or may not be allocatable on the current configuration, so absence is tolerated."],"exampleFix":"# before (run on aarch64)\n-Dgraal.RegisterPressure=rax,rbx,rcx\n\n# after\n-Dgraal.RegisterPressure=x0,x1,x2","handlingStrategy":"validation","validationCode":"// verify every spec resolves against the target arch's allocatable set\nSet<String> allocatable = Arrays.stream(registerConfig.getAllocatableRegisters())\n                .map(r -> r.name).collect(Collectors.toSet());\nfor (String spec : registerPressure.split(\",\")) {\n    String name = spec.endsWith(\"?\") ? spec.substring(0, spec.length() - 1) : spec;\n    if (!allocatable.contains(name)) {\n        throw new IllegalArgumentException(\"Unknown register for this arch: \" + name);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make RegisterPressure lists per-architecture in CI configs and select them by os.arch.","Use the trailing-'?' optional form for registers that exist only in some configurations."],"tags":["register-allocation","options","architecture-specific","configuration","illegal-argument"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}