Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line numbers don't match with autofdo output for llvm #64

Closed
harubyy opened this issue Mar 6, 2018 · 2 comments
Closed

line numbers don't match with autofdo output for llvm #64

harubyy opened this issue Mar 6, 2018 · 2 comments

Comments

@harubyy
Copy link

harubyy commented Mar 6, 2018

Hello,
I'm working on a simple bubblesort code. I'm on Ubuntu 16.04, I compile it with LLVM5 and generate the profile output using autofdo as shown below.

clang -O2  -g sort.c -o sort_g_O0
sudo perf record -e cpu/event=0xc4,umask=0x20,name=br_inst_retired_near_taken,period=400009/pp -b ./sort_g_O0
sudo ../../autofdo/create_llvm_prof --binary=./sort_g_O0 --out=sort_g_O0.prof

Then I use llvm-prof to read this sampled profile. The output gives me some weird line numbers that do not match with the source code.

The (partial) output of
llvm-profdata show -sample sort_g_O0.prof
is this:
2: inlined callee: sort_array: 583159, 0, 4 sampled lines
Samples collected in the function's body {
1: 0
3: 1
4: 1
65501: 1
}
Samples collected in inlined callsites {
6: inlined callee: bubble_sort: 583142, 0, 6 sampled lines
Samples collected in the function's body {
2: 3
4: 12608
5: 16740
7: 4209
8: 4209
65516: 12673
}
No inlined callsites in this function

I tried to figure it out myself,

  • I changed the optimization level to 0 and I still get the weird line number in sort_array function.
  • I printed the offset and line numbers in llvm_profile_writer.cc and indeed something is wrong. But I'm lost tracking it back to dwarf info.

Can somebody help me on this? Am I doing something wrong, if not, why am I seeing these line numbers?

I attached the files.
llvm_autofdo.zip

Thanks!

@danielcdh danielcdh assigned danielcdh and unassigned danielcdh Apr 16, 2018
@danielcdh
Copy link
Contributor

Sorry for the late reply.

The "line number" is not line number but "line offset to the start of the function". If you see a very large number like 65516, it's normally because the sampled instruction has incorrect debug info or no debug info, thus it is mapped to the line 0 of the file, giving it an negative "line offset to the start of the function". The profile you provided looks reasonable and should be good to use.

Dehao

@harubyy
Copy link
Author

harubyy commented Apr 17, 2018

Ah, I see, then yes, there's no problems. Thank you very much for the information. And sorry for my late reply as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants