[PATCH] D105176: [InstrProfiling] Use external weak reference for bias variable

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 9 17:54:36 PDT 2021


phosek added a comment.

@MaskRay it looks like we could use the following pattern:

  extern intptr_t __llvm_profile_counter_bias;
  
  #if defined(_WIN32)
  intptr_t __llvm_profile_counter_bias_default = 0;
  #pragma comment(linker, "/alternatename:" \
                  SYMBOL_NAME("__llvm_profile_counter_bias") "=" \
                  SYMBOL_NAME("__llvm_profile_counter_bias_default"))
  #endif
  
  bool usesRuntimeCounterRelocation() {
    void *s1 = &__llvm_profile_counter_bias;
    void *s2 = &__llvm_profile_counter_bias_default;
    return s1 != s2;
  }

This does seem to work with `clang-cl` but when I tried this with `cl` I still get an error:

  error LNK2019: unresolved external symbol __llvm_profile_counter_bias referenced in function usesRuntimeCounterRelocation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105176



More information about the llvm-commits mailing list