41 lines · plain
1; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s2 3; Test function which compares two integers and returns the value of4; the overflow flag, by using an asm goto to make the asm block branch5; based on that flag, and then a phi to set the return value based on6; whether the branch was taken.7define i32 @overflow(i64 %a, i64 %b) #0 {8asm:9 callbr void asm sideeffect "cmp $0, $1 \0A\09 b.vs ${2:l}",10 "r,r,!i,~{cc}"(i64 %a, i64 %b)11 to label %fallthrough [label %indirect]12 13indirect:14 br label %fallthrough15 16fallthrough:17 ; Return 1 if we came via the 'indirect' block (because the b.vs was18 ; taken), and 0 if we came straight from the asm block (because it19 ; was untaken).20 %retval = phi i32 [0, %asm], [1, %indirect]21 ret i32 %retval22}23 24; CHECK: overflow:25; CHECK-NEXT: .cfi_startproc26; CHECK-NEXT: // %bb.{{[0-9]+}}:27; CHECK-NEXT: bti c28; CHECK-NEXT: //APP29; CHECK-NEXT: cmp x0, x130; CHECK-NEXT: b.vs [[LABEL:\.[A-Za-z0-9_]+]]31; CHECK-NEXT: //NO_APP32; CHECK-NEXT: // %bb.{{[0-9]+}}:33; CHECK-NEXT: mov w0, wzr34; CHECK-NEXT: ret35; CHECK-NEXT: [[LABEL]]:36; CHECK-NOT: bti37; CHECK: mov w0, #138; CHECK-NEXT: ret39 40attributes #0 = { "branch-target-enforcement" "target-features"="+bti" }41