The GitHub Actions job "mainline-only" on tvm-ffi.git/main has failed. Run started by GitHub user tqchen (triggered by tqchen).
Head commit for run: 1e8c998269e8667b35c576bbaeb37fadb94593b1 / Tianqi Chen <[email protected]> [FEAT] Optimize Expected<T> for minimal compiled code and efficiency (#599) ## Summary Optimize `Expected<T>` so the happy paths compile down to a handful of instructions. The previous implementation routed `is_ok` / `is_err` through `as<Error>()` (which refcount-bumped the Error tag just to test type), and `value()` went through `cast<T>()` which performed a redundant runtime type check on every read. ## Changes - `is_ok()` / `is_err()` read the type-index discriminator directly. No indirection. - `value()` and `error()` use `TVM_FFI_PREDICT_TRUE/FALSE` to hint the happy path; the type-traits read uses the `*AfterCheck` variants since the `Expected` invariant already guarantees the held type. - `value_or()` gains an rvalue overload that moves from the held value instead of copying when the `Expected` is consumed as a temporary. - Add `TVM_FFI_UNSAFE_ASSUME` macro (alongside `TVM_FFI_PREDICT_*`) expanding to `__builtin_assume` / `__assume`. Applied inside non-Object `CopyFromAnyViewAfterCheck` to hint the compiler about the type-index invariant. - Add `MoveFromAnyAfterCheck` to `TypeTraits<DLDataType>`; the gap prevented `Expected<DLDataType>::value() &&` from compiling. POD type, so delegate to `CopyFromAnyViewAfterCheck`. - Add `MoveFromAnyAfterCheck` to `TypeTraits<TypedFunction<FType>>`; delegate to `TypeTraits<Function>::MoveFromAnyAfterCheck`. ## Codegen (clang++-17 -O2, lines of asm, lower is better) | Probe | Before | After | |---|---|---| | is_ok / is_err (int) | 173 | 5 | | value() lvalue (int) | 696 | 37 | | value() rvalue (int) | 725 | 34 | | value() rvalue (String) | 810 | 96 | | value() rvalue (Array<int>) | 1763 | 107 | | make_ok().value() | 738 | 50 | | std::move(make_ok()).value() | 738 | 50 | `make_ok().value()` compiles bit-identical to `std::move(make_ok()).value()` — the prvalue temporary materializes an xvalue, binding the `&&` overload directly. No `std::move` needed at the call site. Report URL: https://github.com/apache/tvm-ffi/actions/runs/26590730907 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
