llvm-project
f132e926 - [CIR] Coerce Direct args and returns in CallConvLowering (#195879)

Commit
4 days ago
[CIR] Coerce Direct args and returns in CallConvLowering (#195879) Fourth PR in the split of #192119/#192124. Implements the Direct-with-coercion path in CallConvLowering. Every Direct argument or return whose ABI type differs from its source type is now coerced through a store/reload roundtrip via an entry-block alloca, mirroring classic codegen's CreateCoercedLoad/CreateCoercedStore. The temporary alloca uses max(srcAlign, dstAlign) from the DataLayout and is hoisted into the entry block so it composes with HoistAllocas regardless of pipeline order. When the coerced type is larger than the source -- e.g. a 12-byte aggregate returned as { i64, i64 } -- the slot is sized to the larger type and accessed through a source-typed view for the store and a destination-typed view for the load, so neither side over-reads. CallConvLowering is split into three phases (function-definition coercion, call-site rewriting, and Ignore cleanup) because in-place block-argument type changes from Direct-with-coerce otherwise confused the earlier ordering, synthesizing alloca/load chains for call-site uses of Ignore'd arguments that were about to be dropped. Co-authored-by: Cursor <cursoragent@cursor.com>
Author
Parents
Loading