1 // KEEP-ALL-NOT: warning:
2 // KEEP-ALL: "-mframe-pointer=all"
3 // KEEP-NON-LEAF-NOT: warning:
4 // KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
5 // KEEP-NONE-NOT: warning:
6 // KEEP-NONE: "-mframe-pointer=none"
8 // On Linux x86, omit frame pointer when optimization is enabled.
9 // RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
10 // RUN: FileCheck --check-prefix=KEEP-NONE %s
11 // RUN: %clang -### -target i386-linux -S -O1 %s 2>&1 | \
12 // RUN: FileCheck --check-prefix=KEEP-NONE %s
14 // -fno-omit-frame-pointer or -pg disables frame pointer omission.
15 // RUN: %clang -### -target i386-linux -S %s 2>&1 | \
16 // RUN: FileCheck --check-prefix=KEEP-ALL %s
17 // RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
18 // RUN: FileCheck --check-prefix=KEEP-ALL %s
19 // RUN: %clang -### -target i386-linux -S -O1 -pg %s 2>&1 | \
20 // RUN: FileCheck --check-prefix=KEEP-ALL %s
22 // -momit-leaf-frame-pointer omits leaf frame pointer.
23 // -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
24 // RUN: %clang -### -target i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
25 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
26 // RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
27 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
28 // RUN: %clang -### -target i386-linux -S -O1 -momit-leaf-frame-pointer %s 2>&1 | \
29 // RUN: FileCheck --check-prefix=KEEP-NONE %s
31 // fno-omit-frame-pointer -momit-leaf-frame-pointer can be overwritten by
32 // fomit-frame-pointer later on the command without warning
33 // RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer -fomit-frame-pointer %s 2>&1 | \
34 // RUN: FileCheck --check-prefix=KEEP-NONE %s
36 // RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
37 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
38 // Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
39 // RUN: %clang -### -target i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
40 // RUN: FileCheck --check-prefix=KEEP-NONE %s
41 // RUN: %clang -### -target i386-linux -S %s -O1 -mno-omit-leaf-frame-pointer 2>&1 | \
42 // RUN: FileCheck --check-prefix=KEEP-NONE %s
44 // -pg -fomit-frame-pointer => error.
45 // RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
46 // RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
47 // CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
48 // CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
50 // CloudABI follows the same rules as Linux.
51 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
52 // RUN: FileCheck --check-prefix=KEEP-NONE %s
54 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
55 // RUN: FileCheck --check-prefix=KEEP-ALL %s
57 // NetBSD follows the same rules as Linux.
58 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
59 // RUN: FileCheck --check-prefix=KEEP-NONE %s
61 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
62 // RUN: FileCheck --check-prefix=KEEP-ALL %s
64 // Darwin disables omitting the leaf frame pointer even under optimization
65 // unless the command lines are given.
66 // RUN: %clang -### -target i386-apple-darwin -S %s 2>&1 | \
67 // RUN: FileCheck --check-prefix=KEEP-ALL %s
69 // RUN: %clang -### -target i386-apple-darwin -S -O1 %s 2>&1 | \
70 // RUN: FileCheck --check-prefix=KEEP-ALL %s
72 // RUN: %clang -### -target i386-darwin -S -fomit-frame-pointer %s 2>&1 | \
73 // RUN: FileCheck --check-prefix=KEEP-NONE %s
75 // RUN: %clang -### -target i386-darwin -S -momit-leaf-frame-pointer %s 2>&1 | \
76 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
78 // RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
79 // RUN: FileCheck --check-prefix=WARN-OMIT-7S %s
80 // WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
81 // WARN-OMIT-7S: "-mframe-pointer=all"
83 // RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
84 // RUN: FileCheck --check-prefix=WARN-OMIT-7K %s
85 // WARN-OMIT-7K: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7k'
86 // WARN-OMIT-7K: "-mframe-pointer=all"
88 // RUN: %clang -### -target armv7s-apple-ios8.0 -momit-leaf-frame-pointer %s 2>&1 | \
89 // RUN: FileCheck --check-prefix=WARN-OMIT-LEAF-7S %s
90 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag '-momit-leaf-frame-pointer' is not supported for target 'armv7s'
91 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
93 // On AArch64, PS4, PS5, and VE, default to omitting the frame pointer on leaf
95 // RUN: %clang -### -target aarch64 -S %s 2>&1 | \
96 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
97 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
98 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
99 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
100 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
101 // RUN: %clang -### -target x86_64-sie-ps5 -S %s 2>&1 | \
102 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
103 // RUN: %clang -### -target x86_64-sie-ps5 -S -O2 %s 2>&1 | \
104 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
105 // RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
106 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
107 // RUN: %clang -### -target ve-unknown-linux-gnu -S %s 2>&1 | \
108 // RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
110 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
111 // RUN: FileCheck --check-prefix=KEEP-ALL %s
112 // RUN: %clang -### -target powerpc64 -S -O1 %s 2>&1 | \
113 // RUN: FileCheck --check-prefix=KEEP-NONE %s
115 // SPARC targets omit the frame pointer when optimizations are enabled.
116 // RUN: %clang -### -target sparc -S %s 2>&1 | \
117 // RUN: FileCheck --check-prefix=KEEP-ALL %s
118 // RUN: %clang -### -target sparc -S -O1 %s 2>&1 | \
119 // RUN: FileCheck --check-prefix=KEEP-NONE %s
120 // RUN: %clang -### -target sparcel -S %s 2>&1 | \
121 // RUN: FileCheck --check-prefix=KEEP-ALL %s
122 // RUN: %clang -### -target sparcel -S -O1 %s 2>&1 | \
123 // RUN: FileCheck --check-prefix=KEEP-NONE %s
124 // RUN: %clang -### -target sparc64 -S %s 2>&1 | \
125 // RUN: FileCheck --check-prefix=KEEP-ALL %s
126 // RUN: %clang -### -target sparc64 -S -O1 %s 2>&1 | \
127 // RUN: FileCheck --check-prefix=KEEP-NONE %s
129 // For AAarch32 (A32, T32) linux targets, default omit frame pointer when
130 // optimizations are enabled.
131 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -S %s 2>&1 | \
132 // RUN: FileCheck --check-prefix=KEEP-ALL %s
133 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -S %s 2>&1 | \
134 // RUN: FileCheck --check-prefix=KEEP-ALL %s
135 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -S %s 2>&1 | \
136 // RUN: FileCheck --check-prefix=KEEP-ALL %s
137 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -S %s 2>&1 | \
138 // RUN: FileCheck --check-prefix=KEEP-ALL %s
139 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -O1 -S %s 2>&1 | \
140 // RUN: FileCheck --check-prefix=KEEP-NONE %s
141 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -O1 -S %s 2>&1 | \
142 // RUN: FileCheck --check-prefix=KEEP-NONE %s
143 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -O1 -S %s 2>&1 | \
144 // RUN: FileCheck --check-prefix=KEEP-NONE %s
145 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
146 // RUN: FileCheck --check-prefix=KEEP-NONE %s
147 // For Android, keep the framepointers always.
148 // RUN: %clang -### -target armv7a-linux-androideabi- -marm -O1 -S %s 2>&1 | \
149 // RUN: FileCheck --check-prefix=KEEP-ALL %s
150 // RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -O1 -S %s 2>&1 | \
151 // RUN: FileCheck --check-prefix=KEEP-ALL %s
152 // RUN: %clang -### -target armv7a-linux-androideabi- -marm -mbig-endian -O1 -S %s 2>&1 | \
153 // RUN: FileCheck --check-prefix=KEEP-ALL %s
154 // RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
155 // RUN: FileCheck --check-prefix=KEEP-ALL %s