When -pg option is present than a call to _mcount is inserted into every
function. However since the proper ABI was not followed then the generated
gmon.out did not give proper results. By inserting needed instructions before
every _mcount we can fix this.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Simple use case if someone is unfamiliar with gpof and -pg options:
clang++ test.cpp -pg ... # compile with _mcount calls ./a.out # generates gmon.out gprof a.out # shows report
For simple test.cpp:
int main() { return 0; }
We now get proper results:
... index % time self children called name 0.00 0.00 1/1 __libc_start_main [620] [1] 0.0 0.00 0.00 1 main [1] ...
Tested with following configurations:
mips -fpic -fast-isel=false (used for _mcount: Mips::JALRPseudo) mips -fpic (used for _mcount: Mips::JALR) mips -fast-isel=false (used for _mcount: Mips::JAL) mips (used for _mcount: Mips::JAL) mips64 -fpic -fast-isel=false (used for _mcount: Mips::JALR64Pseudo) mips64 -fpic (used for _mcount: Mips::JALR64Pseudo) mips64 -fast-isel=false (used for _mcount: Mips::JALR64Pseudo) mips64 (used for _mcount: Mips::JALR64Pseudo) micromips -fpic -fast-isel=false (used for _mcount: Mips::JALR16_MM) micromips -fpic (used for _mcount: Mips::JALR16_MM) micromips -fast-isel=false (used for _mcount: Mips::JAL_MM) micromips (used for _mcount: Mips::JAL_MM)
Current _mcount implementation for Mips can be found here:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blob;f=sysdeps/mips/machine-gmon.h;hb=HEAD
Comment Actions
@mbrkusanin This is causing failures on EXPENSIVE_CHECKS builds, please can you take a look?
Comment Actions
Tests would fail when we add -verify-machineinstrs option.
I've added this option to my test and fixed the code in: r374320