[clang] [CIR] Add builtin operator new/delete (PR #168578)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 18 11:55:02 PST 2025


================
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
+
+
+void test_builtins_basic() {
+  __builtin_operator_delete(__builtin_operator_new(4));
+  // CIR-LABEL: test_builtins_basic
+  // CIR: [[P:%.*]] = cir.call @_Znwm({{%.*}}) : (!u64i) -> !cir.ptr<!void>
----------------
andykaylor wrote:

I think they're being set in `CodeGenModule::ConstructAttributeList` in classic codegen. This is a known hole in CIR codegen. Even if we were setting these the same as OGCG, I'd want to use a wildcard match here.

https://github.com/llvm/llvm-project/pull/168578


More information about the cfe-commits mailing list