; Pin: JSLpseudo declares Defs = [A, X, Y, DPF0].
;
; Without X, Y, DPF0 in the Defs list, an i64-returning libcall
; (which returns lo16 in A, mid16 in X, hi16 in Y, hh16 in DPF0)
; verifier-fails with "$y undefined" in math.c::floor.  See
; feedback_jslpseudo_caller_save.md.
;
; This test compiles a call to an i64-returning external function
; with -verify-machineinstrs.  If JSLpseudo's Defs are stripped, the
; X/Y/DPF0 reads after the call would be on physregs the call didn't
; declare it defined, and -verify-machineinstrs fails.
;
; RUN: llc -mtriple=w65816 -O2 -verify-machineinstrs < %s | FileCheck %s

declare i64 @ext_i64(i64 %x)

define i64 @i64_libcall_uses_xy(i64 %x) {
; CHECK-LABEL: i64_libcall_uses_xy:
; CHECK:       jsl ext_i64
; The post-call sequence stores the i64 return value (lo16 in A, mid16
; in X, hi16 in Y, hh16 in DPF0) back to the caller's frame.  If
; JSLpseudo did not Def X, the txa here would verifier-fail because X
; would not be live across the call.
; CHECK:       txa
; CHECK:       rtl
  %r = call i64 @ext_i64(i64 %x)
  ret i64 %r
}
