[Clang] Allow non-constant sizes for __builtin_assume_dereferenceable. (#156929)
Update Clang's __builtin_assume_dereferenceable to support non-constant
lengths. The corresponding assume bundle has been updated to support
non-constant sizes in cad62df49a7.
The current docs for the builtin don't mention the constant requirement
for the size argument, so don't need to be updated:
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-assume-dereferenceable
A number of patches landed recently to make the optimizer make better
use of the dereferenceable assumptions, and once
https://github.com/llvm/llvm-project/pull/156730 lands, it can be used
to vectorize some early-exit loops, for example std::find with
std::vector::iterator: https://godbolt.org/z/qo58PKG37
```
#include <algorithm>
#include <cstddef>
#include <vector>
auto find(std::vector<short>::iterator first, short s, unsigned size) {
auto Addr = __builtin_assume_aligned(std::to_address(first), 2);
__builtin_assume_dereferenceable(std::to_address(first), size * sizeof(short));
return std::find(first, first + size, s);
}
```
PR: https://github.com/llvm/llvm-project/pull/156929