[clang] [CIR] Add support for __builtin_alloca (PR #157116)

Morris Hafner via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 8 08:36:20 PDT 2025


================
@@ -258,3 +258,13 @@ void trap2() {
 // LLVM:       {{.+}}:
 // LLVM-NEXT:    call void @_Z2f1v()
 // LLVM:       }
+
+void *test_alloca(unsigned long n) {
+  return __builtin_alloca(n);
+}
+
+// CIR-LABEL: @_Z11test_allocam(
+// CIR:         %{{.+}} = cir.alloca !u8i, !cir.ptr<!u8i>, %{{.+}} : !u64i, ["bi_alloca"]
+
+// LLVM-LABEL: @_Z11test_allocam(
----------------
mmha wrote:

I added a some missing OGCG checks with the exception of `__builtin_expect` and `__builtin_expect_with_probability` because OGCG doesn't lower to the LLVM intrinsic.

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


More information about the cfe-commits mailing list