[clang] [CIR] Copy byval records as bytes in CallConvLowering (PR #227170)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 18:27:35 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
Author: Bruno Cardoso Lopes (bcardosolopes)
<details>
<summary>Changes</summary>
A byval record argument was copied with a whole-record cir.load/cir.store, both in the callee (into the parameter's slot) and at call sites (into the byval temporary). A record's LLVM type is built from one member for a union, so bytes that are padding in that member but data in another were dropped. A clang built with -fclangir miscompiled itself this way: TemplateArgument, passed by value, lost its integer bit width.
Use cir.copy instead when the value comes straight from memory.
With this fix, the `-fclangir`-built clang passes check-clang with zero failures, identical to the same clang built without -fclangir.
---
Full diff: https://github.com/llvm/llvm-project/pull/227170.diff
10 Files Affected:
- (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp (+41-2)
- (added) clang/test/CIR/CodeGen/call-conv-lowering-x86_64-byval-union.c (+41)
- (modified) clang/test/CIR/CodeGen/call-conv-lowering-x86_64-non-byval.cpp (+2-4)
- (modified) clang/test/CIR/CodeGen/call-conv-lowering-x86_64-variadic.c (+16-16)
- (modified) clang/test/CIR/CodeGen/call.c (+4-4)
- (modified) clang/test/CIR/Transforms/abi-lowering/indirect-byval.cir (+3-4)
- (modified) clang/test/CIR/Transforms/abi-lowering/indirect-call.cir (+3-2)
- (modified) clang/test/CIR/Transforms/abi-lowering/indirect-non-byval-forward-param.cir (+11-18)
- (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-struct-indirect.cir (+2-4)
- (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-union.cir (+2-3)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/227170
More information about the cfe-commits
mailing list