tqchen opened a new pull request, #602:
URL: https://github.com/apache/tvm-ffi/pull/602

   [CORE] Make AnyView trivially copyable — passed in registers, not by 
reference
   
   Default AnyView's move constructor and move assignment so the type
   is std::is_trivially_copyable_v<AnyView>. AnyView owns nothing, so
   the prior "reset source to None after move" body was dead semantics.
   
   Motivation
   ----------
   The SysV AMD64 / AAPCS AArch64 ABIs pass a 16-byte trivially-copyable
   aggregate in two integer registers (rdi+rsi / x0+x1) — equivalent to
   a Rust #[repr(C)] struct{i32, u32, i64}. A user-defined move ctor
   disqualifies this, forcing the compiler to pass AnyView by hidden
   reference instead (rdi = pointer to caller stack slot).
   
   Result
   ------
   Codegen for `int fn(AnyView x) { return x.type_index(); }` on
   x86-64 SysV (-O2, gcc 11.4):
   
     BEFORE:  mov eax, DWORD PTR [rdi]   ; deref of caller stack slot
     AFTER :  mov eax, edi               ; type_index lives directly in rdi
   
   The high 8 bytes (v_int64) carry through in rsi, exactly as a
   repr(C) struct of {i32, u32, i64} would. AArch64 receives the
   analogous flip (x0+x1 direct vs [x0]/[x0,#8] loads). A
   static_assert(std::is_trivially_copyable_v<AnyView>, ...) is
   added next to the existing size asserts so any future user-defined
   copy/move/destructor that regresses this calling convention fails
   at compile time.
   
   Notes
   -----
   - Any (the owning sibling) is a separate class — not a subclass —
     and remains non-trivially-copyable via its refcount-decrementing
     destructor. The static_assert is fully local to AnyView.
   - No test churn required: no existing test asserted the moved-from
     AnyView reset-to-None semantics.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to