1# Check that we can remove the redundant save of constant registers such as $wzr 2# RUN: llc -mtriple=aarch64-unknown-linux %s -verify-machineinstrs -start-before=machine-cp -o - | FileCheck %s --check-prefix ASM 3# RUN: llc -mtriple=aarch64-unknown-linux %s -verify-machineinstrs -run-pass=machine-cp -o - | FileCheck %s 4--- | 5 target triple = "aarch64-unknown-linux" 6 declare i32 @bar(i32) nounwind 7 define i32 @foo() nounwind { 8 ; ASM-LABEL: foo: 9 ; ASM: // %bb.0: 10 ; ASM-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill 11 ; ASM-NEXT: mov w0, wzr 12 ; ASM-NEXT: bl bar 13 ; ASM-NEXT: mov w0, wzr 14 ; ASM-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload 15 ; ASM-NEXT: ret 16 call i32 @bar(i32 0) 17 ret i32 0 18 } 19... 20--- 21name: foo 22frameInfo: 23 adjustsStack: true 24body: | 25 bb.0 (%ir-block.0): 26 ; CHECK-LABEL: name: foo 27 ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 28 ; CHECK-NEXT: $w0 = COPY $wzr 29 ; CHECK-NEXT: BL @bar, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0 30 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 31 ; CHECK-NEXT: $w0 = COPY $wzr 32 ; CHECK-NEXT: RET_ReallyLR implicit $w0 33 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp 34 renamable $w19 = COPY $wzr 35 $w0 = COPY renamable $w19 36 BL @bar, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0 37 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp 38 $w0 = COPY killed renamable $w19 39 RET_ReallyLR implicit $w0 40... 41