[llvm] Fix Valgrind false-positive in Value::getPointerAlignment for Functions (PR #175714)

Vassil Vassilev via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 13 12:11:25 PST 2026


vgvassilev wrote:

> > In our experience the issue appears in Debug and RelWithDebInfo builds and not in Release builds. I've been chasing this for long time and I cannot fully claim that I understand it. MaybeAlign derives from std::optional and perhaps the compiler fails to optimize the union inside it. There are a few valgrind false positive complaints around std::optional on the internet, too. I do not know how to reproduce this issue upstream with a small test... That causes a lot of suppression files to be created, hence my push for this patch to get in.
> 
> I'm not a huge fan of pessimizing our code quality to satisfy valgrind. We already have coverage for the sorts of failures that valgrind would find with sanitizers (and with the sanitizer bots through CI). And I'm especially not a huge fan of landing a change like this without a complete understanding of what is actually happening. If there is a claim that valgrind is wrong, there should be sufficient evidence that valgrind is actually wrong. The last time I found code mentioning it was hacking around a valgrind bug in LLVM, it turned out the code in LLVM was wrong (although the hacky patch did correctly fix the issue). I would not expect the compiler failing to optimize something would trip up valgrind.

Let me check with the downstream clients again to see if that’s still an issue with current llvm. My information is based on llvm20 and even though that code has not changed maybe something else has..

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


More information about the llvm-commits mailing list