[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 20:39:23 PDT 2024


Sirraide wrote:

> Well, there was some head-scratching before debugging revealed that Clang was treating `malloc()` as a built-in.

Yeah, we have a class of ‘builtins’ that are marked as a `LibBuiltin` in `clang/Basic/Builtins.td`, and iirc that’s basically literally every function in the C standard library (and a few from the C++ standard library like `std::move`, `std::forward`, etc.). It’s what allows us to e.g. optimise `printf("foo\n")` → `puts("foo")`. If you only want *actual* builtin functions, you’ll have to exclude those, but I’m not sure all the builtins are nonblocking because I don’t know every single builtin off the top of my head...

If need be, it should be possible to add additional information to `Builtins.td` to signify what builtins are blocking etc., but I’d probably only recommend doing that if it turns out that that applies to a large number of them.

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


More information about the cfe-commits mailing list