JonChesterfield wrote:

A user perspective is useful here, thanks for stopping by! The docs might be 
too concise. There's a nice example in the discourse thread,

```
void qsort( void* ptr, size_t count,
   size_t __attribute__((always_specialize)) size,
   int (* __attribute__((always_specialize)) comp)(const void*, const void*) ) 
{...}
```

Calls to that with constant values for size and/or the comparison will then hit 
this transform, including at O0.

1. Builds static copies of the function specialised to the constant arguments 
with that attribute
2. Changes calls to point to the specialisations.

I'll add a recursive sort to the clang test suite, since replacing the function 
pointer with a direct call without unrolling the recursion is a nice example of 
this doing something that inlining struggles with. Thanks!

https://github.com/llvm/llvm-project/pull/143983
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to