llvm / llvm/llvm-project

[CIR] Upstream missing support for scalar expressions

Open
#192,315 3 comments 0 reactions 1 assignee View on GitHub

@salinhkuhn is already working on this.

Since Apr 20, 2026.

ClangIR
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Overview

Upstream code from the incubator project to replace errorNYI calls in the
CIR codegen implementation related to scalar expressions:

  • Nontemporal stores: threading the isNontemporal flag through to
    builder.createStore()
  • Void type loads: converting void element type to UInt8 via
    withElementType before loading
  • Scalar constant references: loading through a reference returned by
    ConstantEmission::getReferenceLValue()
  • Scalar materialize temporary: calling emitLoadOfLValue(E) to load
    through a materialized temporary's lvalue
  • Pseudo object expressions: delegating to
    CGF.emitPseudoObjectRValue(E).getScalarVal() for pseudo-object rvalue
    emission

Upstream NYI locations:

  • CIRGenExpr.cppemitStoreOfScalar: nontemporal store flag
  • CIRGenExpr.cppemitLoadOfScalar: void element type
  • CIRGenExpr.cppemitScalarConstant: reference constant emission
  • CIRGenExprScalar.cppVisitMaterializeTemporaryExpr: scalar temp load
  • CIRGenExprScalar.cppVisitPseudoObjectExpr: pseudo object rvalue
Suggested minimal test case
// Nontemporal store
void test_nontemporal(int *p, int v) {
  __builtin_nontemporal_store(v, p);
}

// Scalar constant reference
const int &get_ref();
int test_const_ref() {
  static constexpr int val = 42;
  const int &r = val;
  return r;
}

// Materialize temporary (scalar)
int test_materialize() {
  return (const int &)42;
}
Existing incubator tests
  • clang/test/CIR/CodeGen/builtin-nontemporal.cpp
  • clang/test/CIR/CodeGen/temporary-materialization.cpp
  • clang/test/CIR/CodeGen/materialize-temporary.cpp

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.