libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / config / i386 / gcc-auto-profile
blob04f7d35dcc5175fcfa0f7ae01d0b5ac2e3dd34f1
1 #!/bin/sh
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
6 # usages:
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.
16 FLAGS=u
18 if [ "$1" = "--kernel" ] ; then
19 FLAGS=k
20 shift
22 if [ "$1" = "--all" ] ; then
23 FLAGS=uk
24 shift
27 if ! grep -q Intel /proc/cpuinfo ; then
28 echo >&2 "Only Intel CPUs supported"
29 exit 1
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
38 model*:\ 46|\
39 model*:\ 30|\
40 model*:\ 31|\
41 model*:\ 26|\
42 model*:\ 47|\
43 model*:\ 37|\
44 model*:\ 44) E="cpu/event=0x88,umask=0x40/$FLAGS" ;;
45 model*:\ 55|\
46 model*:\ 74|\
47 model*:\ 77|\
48 model*:\ 76|\
49 model*:\ 90|\
50 model*:\ 92|\
51 model*:\ 95|\
52 model*:\ 87|\
53 model*:\ 133|\
54 model*:\ 122) E="cpu/event=0xC4,umask=0xFE/p$FLAGS" ;;
55 model*:\ 28|\
56 model*:\ 38|\
57 model*:\ 39|\
58 model*:\ 54|\
59 model*:\ 53) E="cpu/event=0x88,umask=0x41/$FLAGS" ;;
60 model*:\ 42|\
61 model*:\ 45|\
62 model*:\ 58|\
63 model*:\ 62|\
64 model*:\ 60|\
65 model*:\ 69|\
66 model*:\ 70|\
67 model*:\ 63|\
68 model*:\ 61|\
69 model*:\ 71|\
70 model*:\ 79|\
71 model*:\ 86|\
72 model*:\ 78|\
73 model*:\ 94|\
74 model*:\ 142|\
75 model*:\ 158|\
76 model*:\ 165|\
77 model*:\ 166|\
78 model*:\ 85|\
79 model*:\ 85) E="cpu/event=0xC4,umask=0x20/p$FLAGS" ;;
80 model*:\ 125|\
81 model*:\ 126|\
82 model*:\ 167|\
83 model*:\ 140|\
84 model*:\ 141|\
85 model*:\ 143|\
86 model*:\ 207|\
87 model*:\ 106|\
88 model*:\ 108) E="cpu/event=0xc4,umask=0x20/p$FLAGS" ;;
89 model*:\ 134|\
90 model*:\ 150|\
91 model*:\ 156|\
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."
95 exit 1 ;;
96 esac
97 set -x
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.
101 set +x
102 echo >&2 "Retrying without /p."
103 E="$(echo "${E}" | sed -e 's/\/p/\//')"
104 set -x
105 exec perf record -e $E -b "$@"
106 set +x