[clang] [CIR] Implement __builtin_object_size and __builtin_dynamic_object_size (PR #166191)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 3 10:49:40 PST 2025


================
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
+
+typedef unsigned long size_t;
----------------
andykaylor wrote:

I see classic codegen has a few tests for this (`clang/test/CodeGen/object-size.c`, `clang/test/CodeGen/object-size.cpp`, and `clang/test/CodeGen/object-size-flex-array.c`) that cover many cases where the builtin is lowered to a constant. Can you incorporate whichever parts of those work with this PR?

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


More information about the cfe-commits mailing list