[CIR] Upstream missing support for scalar expressions
Open
@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
isNontemporalflag through to
builder.createStore() - Void type loads: converting void element type to
UInt8via
withElementTypebefore 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.cpp—emitStoreOfScalar: nontemporal store flagCIRGenExpr.cpp—emitLoadOfScalar: void element typeCIRGenExpr.cpp—emitScalarConstant: reference constant emissionCIRGenExprScalar.cpp—VisitMaterializeTemporaryExpr: scalar temp loadCIRGenExprScalar.cpp—VisitPseudoObjectExpr: 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.cppclang/test/CIR/CodeGen/temporary-materialization.cppclang/test/CIR/CodeGen/materialize-temporary.cpp
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.