2 # Profile workload for gcc profile feedback (autofdo) using Linux perf.
3 # Auto generated. To regenerate for new CPUs run
4 # contrib/gen_autofdo_event.py --script --all in gcc source
7 # gcc-auto-profile program (profile program and children)
8 # gcc-auto-profile -a sleep X (profile all for X secs, may need root)
9 # gcc-auto-profile -p PID sleep X (profile PID)
10 # gcc-auto-profile --kernel -a sleep X (profile kernel)
11 # gcc-auto-profile --all -a sleep X (profile kernel and user space)
13 # Identify branches taken event for CPU.
18 if [ "$1" = "--kernel" ] ; then
22 if [ "$1" = "--all" ] ; then
27 if ! grep -q Intel
/proc
/cpuinfo
; then
28 echo >&2 "Only Intel CPUs supported"
32 if grep -q hypervisor
/proc
/cpuinfo
; then
33 echo >&2 "Warning: branch profiling may not be functional in VMs"
36 case `grep -E -q "^cpu family\s*: 6" /proc/cpuinfo &&
37 grep -E "^model\s*:" /proc/cpuinfo | head -n1` in
44 model
*:\
44) E
="cpu/event=0x88,umask=0x40/$FLAGS" ;;
54 model
*:\
122) E
="cpu/event=0xC4,umask=0xFE/p$FLAGS" ;;
59 model
*:\
53) E
="cpu/event=0x88,umask=0x41/$FLAGS" ;;
79 model
*:\
85) E
="cpu/event=0xC4,umask=0x20/p$FLAGS" ;;
88 model
*:\
108) E
="cpu/event=0xc4,umask=0x20/p$FLAGS" ;;
92 model
*:\
190) E
="cpu/event=0xc4,umask=0xfe/p$FLAGS" ;;
94 echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to update script."
98 if ! perf record
-e $E -b "$@" ; then
99 # PEBS may not actually be working even if the processor supports it
100 # (e.g., in a virtual machine). Trying to run without /p.
102 echo >&2 "Retrying without /p."
103 E
="$(echo "${E}" | sed -e 's/\/p/\//')"
105 exec perf record
-e $E -b "$@"