[PATCH] D13329: [PGO]: Eliminate __llvm_profile_register calls for Linux (compiler_rt)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 11:13:21 PDT 2015


Xinliang David Li <davidxl at google.com> writes:
> On Mon, Oct 12, 2015 at 10:51 AM, Justin Bogner <mail at justinbogner.com> wrote:
>> David Li <davidxl at google.com> writes:
>>> davidxl updated this revision to Diff 36641.
>>> davidxl added a comment.
>>>
>>> Make new change strictly limited to linux platform.
>>
>> LGTM, please clang-format InstrProfilingPlatformLinux.c though.
>
> ok. I assume the one liner change in LLVM is also ok (skipping
> register function call when target is linux).

Yeah, that change is obvious. Do make sure the PlatformOther path is
still covered by the tests there though.

>>
>> Would you mind reaching out to some BSD folks so they're aware of this
>> change? Ian Taylor's explanation made it sound like this might work for
>> them too, so they might be interested.
>
> yes -- will do this as a follow up.
>
> thanks,
>
> David
>
>>
>>>
>>> http://reviews.llvm.org/D13329
>>>
>>> Files:
>>>   lib/profile/CMakeLists.txt
>>>   lib/profile/InstrProfilingPlatformLinux.c
>>>   lib/profile/InstrProfilingPlatformOther.c
>>>
>>> Index: lib/profile/InstrProfilingPlatformOther.c
>>> ===================================================================
>>> --- lib/profile/InstrProfilingPlatformOther.c
>>> +++ lib/profile/InstrProfilingPlatformOther.c
>>> @@ -9,7 +9,7 @@
>>>
>>>  #include "InstrProfiling.h"
>>>
>>> -#if !defined(__APPLE__)
>>> +#if !defined(__APPLE__) && !defined(__linux__)
>>>  #include <stdlib.h>
>>>
>>>  static const __llvm_profile_data *DataFirst = NULL;
>>> Index: lib/profile/InstrProfilingPlatformLinux.c
>>> ===================================================================
>>> --- /dev/null
>>> +++ lib/profile/InstrProfilingPlatformLinux.c
>>> @@ -0,0 +1,48 @@
>>> +/*===- InstrProfilingPlatformLinux.c - Profile data Linux platform ------===*\
>>> +|*
>>> +|*                     The LLVM Compiler Infrastructure
>>> +|*
>>> +|* This file is distributed under the University of Illinois Open Source
>>> +|* License. See LICENSE.TXT for details.
>>> +|*
>>> +\*===----------------------------------------------------------------------===*/
>>> +
>>> +#include "InstrProfiling.h"
>>> +
>>> +#if defined(__linux__)
>>> +#include <stdlib.h>
>>> +
>>> +extern __llvm_profile_data __start___llvm_prf_data
>>> +    __attribute__((visibility("hidden")));
>>> +extern __llvm_profile_data __stop___llvm_prf_data
>>> +    __attribute__((visibility("hidden")));
>>> +extern uint64_t __start___llvm_prf_cnts __attribute__((visibility("hidden")));
>>> +extern uint64_t __stop___llvm_prf_cnts __attribute__((visibility("hidden")));
>>> +extern char __start___llvm_prf_names __attribute__((visibility("hidden")));
>>> +extern char __stop___llvm_prf_names __attribute__((visibility("hidden")));
>>> +
>>> +__attribute__((visibility("hidden"))) const __llvm_profile_data *
>>> +__llvm_profile_begin_data(void) {
>>> +  return &__start___llvm_prf_data;
>>> +}
>>> +__attribute__((visibility("hidden"))) const __llvm_profile_data *
>>> +__llvm_profile_end_data(void) {
>>> +  return &__stop___llvm_prf_data;
>>> +}
>>> +__attribute__((visibility("hidden"))) const char *__llvm_profile_begin_names(
>>> +    void) {
>>> +  return &__start___llvm_prf_names;
>>> +}
>>> +__attribute__((visibility("hidden"))) const char *__llvm_profile_end_names(
>>> +    void) {
>>> +  return &__stop___llvm_prf_names;
>>> +}
>>> +__attribute__((visibility("hidden"))) uint64_t *__llvm_profile_begin_counters(
>>> +    void) {
>>> +  return &__start___llvm_prf_cnts;
>>> +}
>>> +__attribute__((visibility("hidden"))) uint64_t *__llvm_profile_end_counters(
>>> +    void) {
>>> +  return &__stop___llvm_prf_cnts;
>>> +}
>>> +#endif
>>> Index: lib/profile/CMakeLists.txt
>>> ===================================================================
>>> --- lib/profile/CMakeLists.txt
>>> +++ lib/profile/CMakeLists.txt
>>> @@ -6,6 +6,7 @@
>>>    InstrProfilingBuffer.c
>>>    InstrProfilingFile.c
>>>    InstrProfilingPlatformDarwin.c
>>> +  InstrProfilingPlatformLinux.c
>>>    InstrProfilingPlatformOther.c
>>>    InstrProfilingRuntime.cc
>>>    InstrProfilingUtil.c)


More information about the llvm-commits mailing list