[PATCH] D81682: [PGO] Extend the value profile buckets for mem op sizes.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 13:08:45 PDT 2020


yamauchi added a comment.

The relevant MSVC related code now looks like

  /*
   * Clz and Popcount. This code was copied from
   * compiler-rt/lib/fuzzer/{FuzzerBuiltins.h,FuzzerBuiltinsMsvc.h} and
   * llvm/include/llvm/Support/MathExtras.h.
   */
  #if defined(_MSC_VER) && !defined(__clang__)
  
  #include <intrin.h>
  INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
  int InstProfClzll(unsigned long long X) {
    unsigned long LeadZeroIdx = 0;
  #if !defined(_M_ARM64) && !defined(_M_X64)
    // Scan the high 32 bits.
    if (_BitScanReverse(&LeadZeroIdx, (unsigned long)(X >> 32)))
      return (int)(63 - (LeadZeroIdx + 32)); // Create a bit offset
                                                        // from the MSB.
    // Scan the low 32 bits.
    if (_BitScanReverse(&LeadZeroIdx, (unsigned long)(X)))
      return (int)(63 - LeadZeroIdx);
  #else
    if (_BitScanReverse64(&LeadZeroIdx, X)) return 63 - LeadZeroIdx;
  #endif
    return 64;
  }
  INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
  int InstProfPopcountll(unsigned long long X) {
    // This code originates from https://reviews.llvm.org/rG30626254510f.
    unsigned long long v = X;
    v = v - ((v >> 1) & 0x5555555555555555ULL);
    v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
    v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
    return (int)((unsigned long long)(v * 0x0101010101010101ULL) >> 56);
  }
  
  #else
  
  INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
  int InstProfClzll(unsigned long long X) { return __builtin_clzll(X); }
  INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
  int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); }
  
  #endif  /* defined(_MSC_VER) && !defined(__clang__) */


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81682/new/

https://reviews.llvm.org/D81682





More information about the llvm-commits mailing list