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"
7 
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
13 
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
21 
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
30 
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
35 
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
43 
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'
49 
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
53 
54 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
55 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
56 
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
60 
61 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
62 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
63 
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
68 
69 // RUN: %clang -### -target i386-apple-darwin -S -O1 %s 2>&1 | \
70 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
71 
72 // RUN: %clang -### -target i386-darwin -S -fomit-frame-pointer %s 2>&1 | \
73 // RUN:   FileCheck --check-prefix=KEEP-NONE %s
74 
75 // RUN: %clang -### -target i386-darwin -S -momit-leaf-frame-pointer %s 2>&1 | \
76 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
77 
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"
82 
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"
87 
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"
92 
93 // On AArch64 and PS4, default to omitting the frame pointer on leaf functions
94 // RUN: %clang -### -target aarch64 -S %s 2>&1 | \
95 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
96 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
97 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
98 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
99 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
100 // RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
101 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
102 
103 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
104 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
105 // RUN: %clang -### -target powerpc64 -S -O1 %s 2>&1 | \
106 // RUN:   FileCheck --check-prefix=KEEP-NONE %s
107 
108 // For AAarch32 (A32, T32) linux targets, default omit frame pointer when
109 // optimizations are enabled.
110 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -S %s 2>&1 | \
111 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
112 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -S %s 2>&1 | \
113 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
114 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -S %s 2>&1 | \
115 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
116 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -S %s 2>&1 | \
117 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
118 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -O1 -S %s 2>&1 | \
119 // RUN:   FileCheck --check-prefix=KEEP-NONE %s
120 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -O1 -S %s 2>&1 | \
121 // RUN:   FileCheck --check-prefix=KEEP-NONE %s
122 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -O1 -S %s 2>&1 | \
123 // RUN:   FileCheck --check-prefix=KEEP-NONE %s
124 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
125 // RUN:   FileCheck --check-prefix=KEEP-NONE %s
126 // For Android, keep the framepointers always.
127 // RUN: %clang -### -target armv7a-linux-androideabi- -marm -O1 -S %s 2>&1 | \
128 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
129 // RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -O1 -S %s 2>&1 | \
130 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
131 // RUN: %clang -### -target armv7a-linux-androideabi- -marm -mbig-endian -O1 -S %s 2>&1 | \
132 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
133 // RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
134 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
135 
f0()136 void f0() {}
f1()137 void f1() { f0(); }
138