[libcxx-commits] [libcxx] [libc++] Mark __{emplace, push}_back_slow_path as noinline (PR #94379)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 9 08:11:45 PDT 2025


================
@@ -1142,6 +1142,24 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {
   return this->__end_;
 }
 
+// This makes the compiler inline `__else()` if `__cond` is known to be false. Currently LLVM doesn't do that without
+// the `__builtin_constant_p`, since it considers `__else` unlikely even through it's known to be run.
+// See https://llvm.org/PR154292
----------------
ldionne wrote:

```suggestion
// This function performs an if-else on the given condition, calling either `__if()` or `__else()`. The `__if()` branch is annotated as being likely.
//
// However, it increases the likelihood that the `__else()` branch will be inlined if `__cond` is known to be a constant by
// the optimizer, which LLVM currently doesn't do when naively applying the [[likely]] attribute.
// See https://llvm.org/PR154292
```

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


More information about the libcxx-commits mailing list