Skip to content
  1. Mar 18, 2022
    • Vasileios Porpodas's avatar
      [SLP] Fix lookahead operand reordering for splat loads. · 5efa7898
      Vasileios Porpodas authored
      Splat loads are inexpensive in X86. For a 2-lane vector we need just one
      instruction: `movddup (%reg), xmm0`. Using the standard Splat score leads
      to worse code. This patch adds a new score dedicated for splat loads.
      
      Please note that a splat is usually three IR instructions:
      - It is usually a load and 2 inserts:
       %ld = load double, double* %gep
       %ins1 = insertelement <2 x double> poison, double %ld, i32 0
       %ins2 = insertelement <2 x double> %ins1, double %ld, i32 1
      
      - But it can also be a load, an insert and a shuffle:
       %ld = load double, double* %gep
       %ins = insertelement <2 x double> poison, double %ld, i32 0
       %shf = shufflevector <2 x double> %ins, <2 x double> poison, <2 x i32> zeroinitializer
      
      Because of this some of the lit tests contain more IR instructions.
      
      Differential Revision: https://reviews.llvm.org/D121354
      5efa7898
    • Vasileios Porpodas's avatar
    • Benjamin Kramer's avatar
    • Paul Kirth's avatar
      964398cc
    • Nico Weber's avatar
      [gn build] (manually) port 6316129e · 5f4a334d
      Nico Weber authored
      5f4a334d
    • Paul Kirth's avatar
      Revert "Revert "[misexpect] Re-implement MisExpect Diagnostics"" · 6cf560d6
      Paul Kirth authored
      I mistakenly reverted my commit, so I'm relanding it.
      
      This reverts commit 10866a1d.
      6cf560d6
    • Paul Kirth's avatar
      Revert "[misexpect] Re-implement MisExpect Diagnostics" · 10866a1d
      Paul Kirth authored
      This reverts commit e7749d47.
      10866a1d
    • Paul Kirth's avatar
      [misexpect] Re-implement MisExpect Diagnostics · e7749d47
      Paul Kirth authored
      Reimplements MisExpect diagnostics from D66324 to reconstruct its
      original checking methodology only using MD_prof branch_weights
      metadata.
      
      New checks rely on 2 invariants:
      
      1) For frontend instrumentation, MD_prof branch_weights will always be
         populated before llvm.expect intrinsics are lowered.
      
      2) for IR and sample profiling, llvm.expect intrinsics will always be
         lowered before branch_weights are populated from the IR profiles.
      
      These invariants allow the checking to assume how the existing branch
      weights are populated depending on the profiling method used, and emit
      the correct diagnostics. If these invariants are ever invalidated, the
      MisExpect related checks would need to be updated, potentially by
      re-introducing MD_misexpect metadata, and ensuring it always will be
      transformed the same way as branch_weights in other optimization passes.
      
      Frontend based profiling is now enabled without using LLVM Args, by
      introducing a new CodeGen option, and checking if the -Wmisexpect flag
      has been passed on the command line.
      
      Differential Revision: https://reviews.llvm.org/D115907
      e7749d47
    • Yonghong Song's avatar
      [BPF] handle unsigned icmp ops in BPFAdjustOpt pass · 2e94d8e6
      Yonghong Song authored
      When investigating an issue with bcc tool inject.py, I found
      a verifier failure with latest clang. The portion of code
      can be illustrated as below:
        struct pid_struct {
          u64 curr_call;
          u64 conds_met;
          u64 stack[2];
        };
        struct pid_struct *bpf_map_lookup_elem();
        int foo() {
          struct pid_struct *p = bpf_map_lookup_elem();
          if (!p) return 0;
          p->curr_call--;
          if (p->conds_met < 1 || p->conds_met >= 3)
              return 0;
          if (p->stack[p->conds_met - 1] == p->curr_call)
              p->conds_met--;
          ...
        }
      
      The verifier failure looks like:
        ...
        8: (79) r1 = *(u64 *)(r0 +0)
         R0_w=map_value(id=0,off=0,ks=4,vs=32,imm=0) R10=fp0 fp-8=mmmm????
        9: (07) r1 += -1
        10: (7b) *(u64 *)(r0 +0) = r1
         R0_w=map_value(id=0,off=0,ks=4,vs=32,imm=0) R1_w=inv(id=0) R10=fp0 fp-8=mmmm????
        11: (79) r2 = *(u64 *)(r0 +8)
         R0_w=map_value(id=0,off=0,ks=4,vs=32,imm=0) R1_w=inv(id=0) R10=fp0 fp-8=mmmm????
        12: (bf) r3 = r2
        13: (07) r3 += -3
        14: (b7) r4 = -2
        15: (2d) if r4 > r3 goto pc+13
         R0=map_value(id=0,off=0,ks=4,vs=32,imm=0) R1=inv(id=0) R2=inv(id=2)
         R3=inv(id=0,umin_value=18446744073709551614,var_off=(0xffffffff00000000; 0xffffffff))
         R4=inv-2 R10=fp0 fp-8=mmmm????
        16: (07) r2 += -1
        17: (bf) r3 = r2
        18: (67) r3 <<= 3
        19: (bf) r4 = r0
        20: (0f) r4 += r3
        math between map_value pointer and register with unbounded min value is not allowed
      
      Here the compiler optimized "p->conds_met < 1 || p->conds_met >= 3" to
        r2 = p->conds_met
        r3 = r2
        r3 += -3
        r4 = -2
        if (r3 < r4) return 0
        r2 += -1
        r3 = r2
        ...
      In the above, r3 is initially equal to r2, but is modified used by the comparison.
      But later on r2 is used again. This caused verification failure.
      
      BPF backend has a pass, AdjustOpt, to prevent such transformation, but only
      focused on signed integers since typical bpf helper returns signed integers.
      To fix this case, let us handle unsigned integers as well.
      
      Differential Revision: https://reviews.llvm.org/D121937
      2e94d8e6
  2. Mar 17, 2022
Loading