brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 4df6192 Raw
92 lines · plain
1; RUN: llc -mtriple=bpfel -mcpu=v4 -gotol-abs-low-bound 0 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s2; Source:3;   // This test covers all three cases:4;   //   (1). jmp to another basic block (not the follow-through one)5;   //   (2). conditional jmp (follow-through and non-follow-through)6;   //   (3). conditional jmp followed by an unconditional jmp7;   // To trigger case (3) the following code is developed which8;   // covers case (1) and (2) as well.9;   unsigned foo(unsigned a, unsigned b) {10;     unsigned s = b;11;     if (a < b)12;       goto next;13;     else14;       goto next2;15;   begin:16;     s /= b;17;     if (s > a)18;       return s * s;19;   next:20;     s *= a;21;     if (s > b)22;       goto begin;23;   next2:24;     s *= b;25;     if (s > a)26;       goto begin;27;     return s;28;   }29; Compilation flags:30;   clang -target bpf -O2 -mcpu=v4 -S -emit-llvm t.c31 32; Function Attrs: nofree norecurse nosync nounwind memory(none)33define dso_local i32 @foo(i32 noundef %a, i32 noundef %b) local_unnamed_addr #0 {34entry:35  %cmp = icmp ult i32 %a, %b36  br i1 %cmp, label %next, label %next237 38; case (3): conditional jmp followed by an unconditional jmp39; CHECK:        w0 = w240; CHECK-NEXT:   if w1 < w2 goto41; CHECK:        gotol LBB0_4    # encoding: [0x06'A',A,A,A,0x00,0x00,0x00,0x00]42; CHECK-NEXT:                   # fixup A - offset: 0, value: LBB0_4, kind: FK_BPF_PCRel_443 44begin:                                            ; preds = %next2, %next45  %s.0 = phi i32 [ %mul3, %next ], [ %mul7, %next2 ]46  %div = udiv i32 %s.0, %b47  %cmp1 = icmp ugt i32 %div, %a48  br i1 %cmp1, label %if.then2, label %next49 50; case (2): conditional jmp51; CHECK:        w0 *= w152; CHECK-NEXT:   if w0 > w2 goto LBB0_753; CHECK:        goto LBB0_454; CHECK-LABEL:  LBB0_7:55; CHECK:        gotol56 57; CHECK-LABEL:  LBB0_4:58 59if.then2:                                         ; preds = %begin60  %mul = mul i32 %div, %div61  br label %cleanup62 63; case (1): unconditional jmp64; CHECK:        w0 *= w065; CHECK-NEXT:   gotol66 67next:                                             ; preds = %begin, %entry68  %s.1 = phi i32 [ %b, %entry ], [ %div, %begin ]69  %mul3 = mul i32 %s.1, %a70  %cmp4 = icmp ugt i32 %mul3, %b71  br i1 %cmp4, label %begin, label %next272 73next2:                                            ; preds = %next, %entry74  %s.2 = phi i32 [ %mul3, %next ], [ %b, %entry ]75  %mul7 = mul i32 %s.2, %b76  %cmp8 = icmp ugt i32 %mul7, %a77  br i1 %cmp8, label %begin, label %cleanup78 79cleanup:                                          ; preds = %next2, %if.then280  %retval.0 = phi i32 [ %mul, %if.then2 ], [ %mul7, %next2 ]81  ret i32 %retval.082}83 84attributes #0 = { nofree norecurse nosync nounwind memory(none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="v4" }85 86!llvm.module.flags = !{!0, !1}87!llvm.ident = !{!2}88 89!0 = !{i32 1, !"wchar_size", i32 4}90!1 = !{i32 7, !"frame-pointer", i32 2}91!2 = !{!"clang version 18.0.0 (https://github.com/llvm/llvm-project.git dccf0f74657ce8c50eb1e997bae356c32d7b1ffe)"}92