[llvm-dev] Profiling Support for BareMetal Target

Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 13 18:16:34 PDT 2018


Hi,

> On Mar 13, 2018, at 7:14 AM, Mohamed Shafi via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> I followed two posts as my guideline
> 
> http://lists.llvm.org/pipermail/llvm-dev/2017-September/117339.html and
> http://lists.llvm.org/pipermail/llvm-dev/2017-September/117156.html
> 
> I am using clang 4.0.1 and compiler-rt 4.0 release
> 
> 1. I made changes in the LCF to mimic Linux Platform (for linker magic)
> 
> In data section i have added:
> 
>    __start___llvm_prf_cnts = .;
>    KEEP(*(__llvm_prf_cnts))
>    __stop___llvm_prf_cnts = .;
>    __start___llvm_prf_data = .;
>    KEEP(*(__llvm_prf_data))
>    __stop___llvm_prf_data = .;
>    __start___llvm_prf_names = .;
>    KEEP(*(__llvm_prf_names))
>    __stop___llvm_prf_names = .;
>    __start___llvm_prf_vnds = .;
>    KEEP(*(__llvm_prf_vnds))
>    __stop___llvm_prf_vnds = .;
> 
> 2. Since there are not .ctors or atexit available i called the
> functions lprofSetupValueProfiler and __llvm_profile_initialize_file
> from the startup before main and __llvm_profile_write_file during the
> exit after main.
> 
> 3. Made changes in the compiler-rt library to adapt the profile
> sources for a bare metal target.
> 
> When i run the elf file of a simple return 0 main i do get a
> default.profraw file and after processing the raw data using
> llvm-profdata and llvm-cov all i get is
> error: a.out: Failed to load coverage: No coverage data found
> 
> I could see the following :
> 
> $ llvm-profdata.exe show  -detailed-summary default.profraw
> Total functions: 1
> Maximum function count: 1
> Maximum internal block count: 0
> Detailed summary:
> Total number of blocks: 1
> Total count: 1
> 0 blocks with count >= 0 account for 80 percentage of the total counts.
> 0 blocks with count >= 0 account for 90 percentage of the total counts.
> 0 blocks with count >= 0 account for 95 percentage of the total counts.
> 0 blocks with count >= 0 account for 99 percentage of the total counts.
> 0 blocks with count >= 0 account for 99.9 percentage of the total counts.
> 0 blocks with count >= 0 account for 99.99 percentage of the total counts.
> 0 blocks with count >= 0 account for 99.999 percentage of the total counts.
> 
> I am not sure what is wrong.
> In the profiling library i see many entry points. I used
> RegisterRuntime constructor to decide on the functions, that i
> mentioned above, to be called in the startup routine . I am right in
> that ?
> 
> Any idea as to what i am doing wrong ?

Perhaps there's just no __llvm_covmap section in the binary? That would explain the error. Can you retain that section with your linker script?

best,
vedant

> 
> Regards,
> Shafi
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list