openjdk/jdk · warning

Warning: ThreadLocal instruction %s should be named 'tlsLoad

Error message

Warning: ThreadLocal instruction %s should be named 'tlsLoadP_*'

What it means

ADLC naming-convention warning from InstructForm::is_tls_instruction(): the instruction's match rule references the ThreadLocal ideal node, but its identifier does not follow the required 'tlsLoadP' / 'tlsLoadP_*' convention. The instruction is still classified as a TLS instruction (returns 1), but the warning flags that downstream generated code relies on the name prefix for TLS handling.

Source

Thrown at src/hotspot/share/adlc/formssel.cpp:304

  if (_size != nullptr && strcmp(_size, "0") == 0) {
    return 1;
  }
  return 0;
}

int InstructForm::is_tls_instruction() const {
  if (_ident != nullptr &&
      ( ! strcmp( _ident,"tlsLoadP") ||
        ! strncmp(_ident,"tlsLoadP_",9)) ) {
    return 1;
  }

  if (_matrule != nullptr && _insencode != nullptr) {
    const char* opType = _matrule->_opType;
    if (strcmp(opType, "Set")==0)
      opType = _matrule->_rChild->_opType;
    if (strcmp(opType,"ThreadLocal")==0) {
      fprintf(stderr, "Warning: ThreadLocal instruction %s should be named 'tlsLoadP_*'\n",
              (_ident == nullptr ? "nullptr" : _ident));
      return 1;
    }
  }

  return 0;
}


// Return 'true' if this instruction matches an ideal 'If' node
bool InstructForm::is_ideal_if() const {
  if( _matrule == nullptr ) return false;

  return _matrule->is_ideal_if();
}

// Return 'true' if this instruction matches an ideal 'FastLock' node
bool InstructForm::is_ideal_fastlock() const {

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Rename the instruction to 'tlsLoadP' or with the 'tlsLoadP_' prefix
  2. If the name cannot change, verify the generated matcher still handles the instruction correctly
  3. Rebuild to confirm the warning is gone

Example fix

// before
instruct loadTLS(iRegP reg) %{ match(Set reg (ThreadLocal)); %}

// after
instruct tlsLoadP_slow(iRegP reg) %{ match(Set reg (ThreadLocal)); %}
Defensive patterns

Strategy: validation

Validate before calling

grep -nP 'instruct\s+(?!tlsLoadP)\w+.*ThreadLocal' src/hotspot/cpu/x86/x86.ad 2>/dev/null || true # flag instructions matching ThreadLocal with wrong names

Prevention

When it happens

Trigger: Defining an instruct whose match rule's opType (after unwrapping a 'Set') is 'ThreadLocal' while naming the instruction something other than tlsLoadP or tlsLoadP_something. The check inspects _ident and the matrule/insencode pair.

Common situations: Adding or renaming thread-local load instructions during HotSpot porting; naming a new TLS access helper 'loadTLS' instead of 'tlsLoadP_slow'.

Related errors


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