57 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc -mattr=+zcmp -verify-machineinstrs \3; RUN: -mtriple=riscv32 -target-abi=ilp32 < %s \4; RUN: | FileCheck %s -check-prefixes=RV32IZCMP5; RUN: llc -mattr=+zcmp -verify-machineinstrs \6; RUN: -mtriple=riscv64 -target-abi=lp64 < %s \7; RUN: | FileCheck %s -check-prefixes=RV64IZCMP8 9; This source code exposed a crash in the RISC-V Zcmp Push/Pop optimization10; pass. The root cause was: Not doing a bounds check before using a returned11; iterator.12 13declare dso_local void @f1() local_unnamed_addr14declare dso_local void @f2() local_unnamed_addr15define dso_local void @f0(i1 %c) local_unnamed_addr {16; RV32IZCMP-LABEL: f0:17; RV32IZCMP: # %bb.0: # %entry18; RV32IZCMP-NEXT: andi a0, a0, 119; RV32IZCMP-NEXT: beqz a0, .LBB0_220; RV32IZCMP-NEXT: # %bb.1: # %if.T21; RV32IZCMP-NEXT: cm.push {ra}, -1622; RV32IZCMP-NEXT: .cfi_def_cfa_offset 1623; RV32IZCMP-NEXT: .cfi_offset ra, -424; RV32IZCMP-NEXT: call f125; RV32IZCMP-NEXT: cm.pop {ra}, 1626; RV32IZCMP-NEXT: .cfi_restore ra27; RV32IZCMP-NEXT: .cfi_def_cfa_offset 028; RV32IZCMP-NEXT: .LBB0_2: # %if.F29; RV32IZCMP-NEXT: tail f230;31; RV64IZCMP-LABEL: f0:32; RV64IZCMP: # %bb.0: # %entry33; RV64IZCMP-NEXT: andi a0, a0, 134; RV64IZCMP-NEXT: beqz a0, .LBB0_235; RV64IZCMP-NEXT: # %bb.1: # %if.T36; RV64IZCMP-NEXT: cm.push {ra}, -1637; RV64IZCMP-NEXT: .cfi_def_cfa_offset 1638; RV64IZCMP-NEXT: .cfi_offset ra, -839; RV64IZCMP-NEXT: call f140; RV64IZCMP-NEXT: cm.pop {ra}, 1641; RV64IZCMP-NEXT: .cfi_restore ra42; RV64IZCMP-NEXT: .cfi_def_cfa_offset 043; RV64IZCMP-NEXT: .LBB0_2: # %if.F44; RV64IZCMP-NEXT: tail f245 46entry:47 br i1 %c, label %if.T, label %if.F48 49if.T:50 tail call void @f1()51 br label %if.F52 53if.F:54 tail call void @f2()55 ret void56}57