Skip to content

Commit 3890745

Browse files
author
git apple-llvm automerger
committed
Merge commit 'de3d74aa5de5' from llvm.org/main into next
2 parents dd626d3 + de3d74a commit 3890745

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
199199
return emitNullValue(e->getType(), cgf.getLoc(e->getSourceRange()));
200200
}
201201

202+
mlir::Value VisitGNUNullExpr(const GNUNullExpr *e) {
203+
return emitNullValue(e->getType(), cgf.getLoc(e->getSourceRange()));
204+
}
205+
202206
mlir::Value VisitOpaqueValueExpr(OpaqueValueExpr *e) {
203207
if (e->isGLValue())
204208
return emitLoadOfLValue(cgf.getOrCreateOpaqueLValueMapping(e),
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7+
8+
void gnu_null_expr() {
9+
long a = __null;
10+
int *b = __null;
11+
}
12+
13+
// CIR: %[[A_ADDR:.*]] = cir.alloca !s64i, !cir.ptr<!s64i>, ["a", init]
14+
// CIR: %[[B_ADDR:.*]] = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["b", init]
15+
// CIR: %[[CONST_0:.*]] = cir.const #cir.int<0> : !s64i
16+
// CIR: cir.store {{.*}} %[[CONST_0]], %[[A_ADDR]] : !s64i, !cir.ptr<!s64i>
17+
// CIR: %[[CONST_NULL:.*]] = cir.const #cir.ptr<null> : !cir.ptr<!s32i>
18+
// CIR: cir.store {{.*}} %[[CONST_NULL]], %[[B_ADDR]] : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
19+
20+
// LLVM: %[[A_ADDR:.*]] = alloca i64, i64 1, align 8
21+
// LLVM: %[[B_ADDR:.*]] = alloca ptr, i64 1, align 8
22+
// LLVM: store i64 0, ptr %[[A_ADDR]], align 8
23+
// LLVM: store ptr null, ptr %[[B_ADDR]], align 8
24+
25+
// OGCG: %[[A_ADDR:.*]] = alloca i64, align 8
26+
// OGCG: %[[B_ADDR:.*]] = alloca ptr, align 8
27+
// OGCG: store i64 0, ptr %[[A_ADDR]], align 8
28+
// OGCG: store ptr null, ptr %[[B_ADDR]], align 8

0 commit comments

Comments
 (0)