[clang] [mlir] [CIR] Set `builtin` attribute for new and delete calls (PR #184920)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 07:16:00 PDT 2026


erichkeane wrote:

> what is the effect of marking new/delete as a builtin? (this is just my normal new/delete paranoia :D)

LLVM uses it for opt opportunities (which is why we already have this in classic codegen).  IF the operator is not user provided, the compiler has some extensive freedoms that we'd like to be able to take advantage of (and frankly, by a very reasonable reading of the standard, even then too!).

Some of the opts are: allocation ellision, allocation combination, and allocation re-ordering.

The standard states that 'side effects' to allocation/deallocation functions are not observable (which is a little hand-wavy in how it can actually function...), but clang has traditionally limited the freedom to opt to non-user-provided new/delete for these opts. 

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


More information about the cfe-commits mailing list