openjdk/jdk · critical

pipeline_res_mask_initializer: semantic error: pipeline stag

Error message

pipeline_res_mask_initializer: semantic error: pipeline stage undeclared: %s

What it means

A fatal semantic error in adlc's pipeline model processing (pipeline_res_mask_initializer). A pipe class resource usage lists a stage name (piperesource->_stage) that is not present in the pipeline description's declared stage list (pipeline->_stages). adlc prints the error and calls exit(1), aborting the build of the generated matcher/encoder sources.

Source

Thrown at src/hotspot/share/adlc/output_c.cpp:510

      resources_used_exclusively |= used_mask;
    }

    int formatlen =
      snprintf_checked(&resource_mask[templen], resource_mask_size - templen, "  %s(0x%0*x, %*d, %*d, %s %s(",
        pipeline_use_element,
        masklen, used_mask,
        cycledigit, lb, cycledigit, ub,
        ((used_mask & (used_mask-1)) != 0) ? "true, " : "false,",
        pipeline_use_cycle_mask);

    templen += formatlen;

    memset(res_mask, 0, cyclemasksize * sizeof(uint));

    int cycles = piperesource->_cycles;
    uint stage          = pipeline->_stages.index(piperesource->_stage);
    if ((uint)NameList::Not_in_list == stage) {
      fprintf(stderr,
              "pipeline_res_mask_initializer: "
              "semantic error: "
              "pipeline stage undeclared: %s\n",
              piperesource->_stage);
      exit(1);
    }
    uint upper_limit    = stage + cycles - 1;
    uint lower_limit    = stage - 1;
    uint upper_idx      = upper_limit >> 5;
    uint lower_idx      = lower_limit >> 5;
    uint upper_position = upper_limit & 0x1f;
    uint lower_position = lower_limit & 0x1f;

    uint mask = (((uint)1) << upper_position) - 1;

    while (upper_idx > lower_idx) {
      res_mask[upper_idx--] |= mask;
      mask = (uint)-1;

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Note the stage name printed at the end of the message; it is exactly the undeclared name
  2. Add that stage to the pipeline description's stage list (stages(...)) or fix the typo in the pipe class resource usage
  3. Keep stage lists and pipe classes in one edit when renaming stages
  4. Re-run make; adlc exits 1 so the build stops at the ad file compile step

Example fix

// before
pipe_desc( %{ stages(IF, ID, EX, WB); %} );
pipe_class p(...) %{ ...; EX2; %} // EX2 undeclared

// after
pipe_desc( %{ stages(IF, ID, EX, EX2, WB); %} );
pipe_class p(...) %{ ...; EX2; %}
Defensive patterns

Strategy: validation

Validate before calling

# Verify each stage used in pipe classes is declared:
python3 - <<'EOF'
import re
src = open('src/hotspot/cpu/<arch>/<arch>.ad').read()
declared = set(re.findall(r'stages\\(([^)]*)\\)', src))
declared = set(s.strip() for m in declared for s in m.replace('\\n',' ').split(',') if s.strip())
used = set(re.findall(r'([A-Z][A-Za-z0-9_]*)\\s*\\(\d+\\)', src))
missing = used - declared
assert not missing, f'undeclared pipeline stages: {missing}'
EOF

Prevention

When it happens

Trigger: In the .ad file's pipeline description, a pipe_class's resource usage references a stage (e.g. 'myRes 3' where the cycle/stage syntax names a stage) that was never declared in the pipe_desc stages(...) declaration; or a typo in a stage name between the declaration and its use.

Common situations: Hand-editing pipeline descriptions; renaming a stage in stages(...) but not in the pipe classes that use it; porting a pipeline model between architectures where stage names differ.

Related errors


AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14). Data as JSON: /api/errors/4f30ca3765917791. Report an issue: GitHub.