[llvm] fix preserve_none in X86 backend (PR #192300)

Jerry Dang via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 19:56:26 PDT 2026


================

----------------
kuroyukiasuna wrote:

Thanks for the careful review, this is quite interesting. There are actually 2 new findings out of this:
1. This test case doesn't reflect the exact preserve_none causing crash bug - it is passing an incoming pointer argument `ptr %a` as the byval source, rather than a local alloca. The original problem is that when preserve_none is used with byval on a local alloca the compile crashes. I wrote a new test which works correctly and the assembly confirms the byval copy is materialized.
2. This test case did help uncover another pre-existing bug however. `preserve_none` + `byval` with an incoming pointer argument never generates the required byval copy, regardless of whether the call is a tail call or not. Even a plain call (not tail call) exhibits this miscompilation - the callee receives a pointer directly to the original memory instead of a private copy, violating the byval contract like you mentioned.

I would prefer tracking this in a separate issue. As this patch focuses on fixing the crash caused by `preserve_none` + `tail call` + `byval`.

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


More information about the llvm-commits mailing list