| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| ; RUN: llc -mtriple=riscv64 -mattr=+save-restore,+reserve-x5 -verify-machineinstrs < %s \ |
| ; RUN: | FileCheck %s |
| |
| ; This test verifies that the shrink-wrap pass does not crash when the save |
| ; point reaches the entry block (which has no predecessors) while trying to find |
| ; a cheaper save point via FindIDom. |
| |
| @a = global i32 0, align 4 |
| |
| define signext i32 @shrinkwrap_entry_no_preds() { |
| ; CHECK-LABEL: shrinkwrap_entry_no_preds: |
| ; CHECK: # %bb.0: # %entry |
| ; CHECK-NEXT: call t0, __riscv_save_0 |
| ; CHECK-NEXT: .cfi_def_cfa_offset 16 |
| ; CHECK-NEXT: .cfi_offset ra, -8 |
| ; CHECK-NEXT: lui a0, %hi(a) |
| ; CHECK-NEXT: lw a0, %lo(a)(a0) |
| ; CHECK-NEXT: beqz a0, .LBB0_2 |
| ; CHECK-NEXT: # %bb.1: # %if.then |
| ; CHECK-NEXT: call b |
| ; CHECK-NEXT: .LBB0_2: # %if.end |
| ; CHECK-NEXT: li a0, 0 |
| ; CHECK-NEXT: tail __riscv_restore_0 |
| entry: |
| %0 = load i32, ptr @a, align 4 |
| %tobool.not = icmp eq i32 %0, 0 |
| br i1 %tobool.not, label %if.end, label %if.then |
| |
| if.then: |
| tail call void @b() |
| br label %if.end |
| |
| if.end: |
| ret i32 0 |
| } |
| |
| declare void @b() |