[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Driver / frame-pointer-elim.c
blob79cc0ee1b18b99ab647c8cf2b197f1afb6974d1a
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
94 // functions
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 // For AAarch32 (A32, T32) linux targets, default omit frame pointer when
116 // optimizations are enabled.
117 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -S %s 2>&1 | \
118 // RUN: FileCheck --check-prefix=KEEP-ALL %s
119 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -S %s 2>&1 | \
120 // RUN: FileCheck --check-prefix=KEEP-ALL %s
121 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -S %s 2>&1 | \
122 // RUN: FileCheck --check-prefix=KEEP-ALL %s
123 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -S %s 2>&1 | \
124 // RUN: FileCheck --check-prefix=KEEP-ALL %s
125 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -O1 -S %s 2>&1 | \
126 // RUN: FileCheck --check-prefix=KEEP-NONE %s
127 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -O1 -S %s 2>&1 | \
128 // RUN: FileCheck --check-prefix=KEEP-NONE %s
129 // RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -O1 -S %s 2>&1 | \
130 // RUN: FileCheck --check-prefix=KEEP-NONE %s
131 // RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
132 // RUN: FileCheck --check-prefix=KEEP-NONE %s
133 // For Android, keep the framepointers always.
134 // RUN: %clang -### -target armv7a-linux-androideabi- -marm -O1 -S %s 2>&1 | \
135 // RUN: FileCheck --check-prefix=KEEP-ALL %s
136 // RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -O1 -S %s 2>&1 | \
137 // RUN: FileCheck --check-prefix=KEEP-ALL %s
138 // RUN: %clang -### -target armv7a-linux-androideabi- -marm -mbig-endian -O1 -S %s 2>&1 | \
139 // RUN: FileCheck --check-prefix=KEEP-ALL %s
140 // RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
141 // RUN: FileCheck --check-prefix=KEEP-ALL %s
143 void f0() {}
144 void f1() { f0(); }