This sets the maximum entry count among all functions in the program to the module using module flags. This allows the optimizer to use this information.
Details
- Reviewers
davidxl bogner - Commits
- rG695890c971f4: Attach maximum function count to Module when using PGO mode.
rGdd4c71ca6e2e: Revert r254647.
rGd547e5e16842: Attach maximum function count to Module when using PGO mode
rC255918: Attach maximum function count to Module when using PGO mode.
rC255416: Revert r254647.
rC255397: Attach maximum function count to Module when using PGO mode
rL255918: Attach maximum function count to Module when using PGO mode.
rL255416: Revert r254647.
rL255397: Attach maximum function count to Module when using PGO mode
Diff Detail
- Repository
- rL LLVM
Event Timeline
Should also add a test case as a followup. Example:
./projects/compiler-rt/test/profile/instrprof-basic.c
David
lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
380–381 ↗ | (On Diff #41683) | Can you add a test for this to clang's test/CodeGen? |
I've added a test case to check for the presence of MaxFunctionCount module flag. I'll check in this patch soon.
I have reverted the commit in r255416 because the test failed in many architectures. In many cases the linker is not able to find libclang_rt.profile-$ARCH.a file. There are also other errors. Here is one:
0. Program arguments: /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang -cc1 -triple hexagon-unknown--elf -emit-obj -disable-free -main-file-name pgo-max-function-count.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu hexagonv4 -mqdsp6-compat -Wreturn-type -fshort-enums -mllvm -machine-sink-split=0 -target-linker-version 2.25 -dwarf-column-info -fprofile-instr-generate -resource-dir /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.8.0 -internal-externc-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/lib/gcc/hexagon/0.0.0/include -internal-externc-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/lib/gcc/hexagon/0.0.0/include-fixed -internal-externc-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../../gnu/hexagon/include -O2 -fdebug-compilation-dir /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/CodeGen -ferror-limit 19 -fmessage-length 0 -fshort-enums -fno-signed-char -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o /tmp/pgo-max-function-count-816195.o -x c /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.src/tools/clang/test/CodeGen/pgo-max-function-count.c
<snip>
Target: hexagon-unknown--elf
Seems like the command line is messed up (I assume there should be a space between hexagon-unknown and --elf).
Any suggestions on how to fix this test case? AFAICT, there are no PGO related tests in clang and I based this on PGO tests in compiler-rt/
Updated the patch addressing Justin's comments and a new test case.
(Should I open a new review thread since phabricator thinks this has been submitted?)
Use -fprofile-instr-generate option. -fprofile-generate is for GCC compatibility.