This is an archive of the discontinued LLVM Phabricator instance.

Attach maximum function count to Module when using PGO mode.
ClosedPublic

Authored by eraman on Dec 2 2015, 3:32 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

eraman updated this revision to Diff 41683.Dec 2 2015, 3:32 PM
eraman retitled this revision from to Attach maximum function count to Module when using PGO mode. .
eraman updated this object.
eraman set the repository for this revision to rL LLVM.
eraman added subscribers: cfe-commits, davidxl.
davidxl accepted this revision.Dec 2 2015, 3:39 PM
davidxl added a reviewer: davidxl.
This revision is now accepted and ready to land.Dec 2 2015, 3:39 PM

Should also add a test case as a followup. Example:

./projects/compiler-rt/test/profile/instrprof-basic.c

David

LGTM. Wait a little longer in case other reviews want to chime in.

rsmith added a subscriber: rsmith.Dec 10 2015, 3:34 PM
rsmith added inline comments.
lib/CodeGen/CodeGenModule.cpp
380–381

Can you add a test for this to clang's test/CodeGen?

eraman updated this revision to Diff 42549.Dec 11 2015, 11:31 AM

Added a test case.

eraman marked an inline comment as done.Dec 11 2015, 3:25 PM

I've added a test case to check for the presence of MaxFunctionCount module flag. I'll check in this patch soon.

This revision was automatically updated to reflect the committed changes.

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/

davidxl added inline comments.Dec 14 2015, 2:21 PM
cfe/trunk/test/CodeGen/pgo-max-function-count.c
1 ↗(On Diff #42604)

Use -fprofile-instr-generate option. -fprofile-generate is for GCC compatibility.

4 ↗(On Diff #42604)

use -fprofile-instr-use=%t.profdata ..

eraman updated this revision to Diff 42797.Dec 14 2015, 4:24 PM

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?)

eraman updated this revision to Diff 42801.Dec 14 2015, 4:30 PM

Fix the comment in the test case

I prefer using the profile from the original test case where Max count is not 1.

eraman updated this revision to Diff 43089.Dec 16 2015, 5:21 PM

Updated the test case.

Justin, does this patch look ok?