OLD | NEW |
1 //===- PNaClABIVerifyModule.cpp - Verify PNaCl ABI rules --------===// | 1 //===- PNaClABIVerifyModule.cpp - Verify PNaCl ABI rules --------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // Verify module-level PNaCl ABI requirements (specifically those that do not | 10 // Verify module-level PNaCl ABI requirements (specifically those that do not |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, | 125 bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, |
126 unsigned ID) { | 126 unsigned ID) { |
127 // Keep 3 categories of intrinsics for now. | 127 // Keep 3 categories of intrinsics for now. |
128 // (1) Allowed always | 128 // (1) Allowed always |
129 // (2) Never allowed | 129 // (2) Never allowed |
130 // (3) "Dev" intrinsics, which may or may not be allowed. | 130 // (3) "Dev" intrinsics, which may or may not be allowed. |
131 // "Dev" intrinsics are controlled by the PNaClABIAllowDevIntrinsics flag. | 131 // "Dev" intrinsics are controlled by the PNaClABIAllowDevIntrinsics flag. |
132 // Please keep these sorted within each category. | 132 // Please keep these sorted or grouped in a sensible way, within |
| 133 // each category. |
133 switch(ID) { | 134 switch(ID) { |
134 // Disallow by default. | 135 // Disallow by default. |
135 default: return false; | 136 default: return false; |
136 // (1) Always allowed. | 137 // (1) Always allowed. |
137 case Intrinsic::invariant_end: | 138 case Intrinsic::invariant_end: |
138 case Intrinsic::invariant_start: | 139 case Intrinsic::invariant_start: |
139 case Intrinsic::lifetime_end: | 140 case Intrinsic::lifetime_end: |
140 case Intrinsic::lifetime_start: | 141 case Intrinsic::lifetime_start: |
141 case Intrinsic::memcpy: | 142 case Intrinsic::memcpy: |
142 case Intrinsic::memmove: | 143 case Intrinsic::memmove: |
143 case Intrinsic::memset: | 144 case Intrinsic::memset: |
144 case Intrinsic::nacl_read_tp: | 145 case Intrinsic::nacl_read_tp: |
145 case Intrinsic::trap: | 146 case Intrinsic::trap: |
146 return true; | 147 return true; |
147 | 148 |
148 // (2) Known to be never allowed. | 149 // (2) Known to be never allowed. |
149 case Intrinsic::not_intrinsic: | 150 case Intrinsic::not_intrinsic: |
| 151 // Trampolines depend on a target-specific-sized/aligned buffer. |
150 case Intrinsic::adjust_trampoline: | 152 case Intrinsic::adjust_trampoline: |
| 153 case Intrinsic::init_trampoline: |
| 154 // CXX exception handling is not stable. |
151 case Intrinsic::eh_dwarf_cfa: | 155 case Intrinsic::eh_dwarf_cfa: |
152 case Intrinsic::eh_return_i32: | 156 case Intrinsic::eh_return_i32: |
153 case Intrinsic::eh_return_i64: | 157 case Intrinsic::eh_return_i64: |
154 case Intrinsic::eh_sjlj_callsite: | 158 case Intrinsic::eh_sjlj_callsite: |
155 case Intrinsic::eh_sjlj_functioncontext: | 159 case Intrinsic::eh_sjlj_functioncontext: |
156 case Intrinsic::eh_sjlj_longjmp: | 160 case Intrinsic::eh_sjlj_longjmp: |
157 case Intrinsic::eh_sjlj_lsda: | 161 case Intrinsic::eh_sjlj_lsda: |
158 case Intrinsic::eh_sjlj_setjmp: | 162 case Intrinsic::eh_sjlj_setjmp: |
159 case Intrinsic::eh_typeid_for: | 163 case Intrinsic::eh_typeid_for: |
160 case Intrinsic::eh_unwind_init: | 164 case Intrinsic::eh_unwind_init: |
161 case Intrinsic::init_trampoline: | 165 // We do not want to expose addresses to the user. |
| 166 case Intrinsic::frameaddress: |
| 167 case Intrinsic::returnaddress: |
| 168 // Not supporting stack protectors. |
162 case Intrinsic::stackprotector: | 169 case Intrinsic::stackprotector: |
| 170 // Var-args handling is done w/out intrinsics. |
163 case Intrinsic::vacopy: | 171 case Intrinsic::vacopy: |
164 case Intrinsic::vaend: | 172 case Intrinsic::vaend: |
165 case Intrinsic::vastart: | 173 case Intrinsic::vastart: |
166 return false; | 174 return false; |
167 | 175 |
168 // (3) Dev intrinsics. | 176 // (3) Dev intrinsics. |
169 case Intrinsic::dbg_declare: | 177 case Intrinsic::dbg_declare: |
170 case Intrinsic::dbg_value: | 178 case Intrinsic::dbg_value: |
171 return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata; | 179 return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata; |
172 case Intrinsic::bswap: // Support via compiler_rt if arch doesn't have it? | 180 case Intrinsic::bswap: // Support via compiler_rt if arch doesn't have it? |
173 case Intrinsic::cos: // Rounding not defined: support with fast-math? | 181 case Intrinsic::cos: // Rounding not defined: support with fast-math? |
174 case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? | 182 case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? |
175 case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? | 183 case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? |
176 case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it? | 184 case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it? |
177 case Intrinsic::exp: // Rounding not defined: support with fast-math? | 185 case Intrinsic::exp: // Rounding not defined: support with fast-math? |
178 case Intrinsic::exp2: // Rounding not defined: support with fast-math? | 186 case Intrinsic::exp2: // Rounding not defined: support with fast-math? |
179 case Intrinsic::expect: // From __builtin_expect. | 187 case Intrinsic::expect: // From __builtin_expect. |
180 case Intrinsic::flt_rounds: | 188 case Intrinsic::flt_rounds: |
181 case Intrinsic::frameaddress: // Support for 0-level or not? | |
182 case Intrinsic::log: // Rounding not defined: support with fast-math? | 189 case Intrinsic::log: // Rounding not defined: support with fast-math? |
183 case Intrinsic::log2: // Rounding not defined: support with fast-math? | 190 case Intrinsic::log2: // Rounding not defined: support with fast-math? |
184 case Intrinsic::log10: // Rounding not defined: support with fast-math? | 191 case Intrinsic::log10: // Rounding not defined: support with fast-math? |
185 case Intrinsic::nacl_target_arch: // Used by translator self-build. | 192 case Intrinsic::nacl_target_arch: // Used by translator self-build. |
186 case Intrinsic::pow: // Rounding is supposed to be the same as libm. | 193 case Intrinsic::pow: // Rounding is supposed to be the same as libm. |
187 case Intrinsic::powi: // Rounding not defined: support with fast-math? | 194 case Intrinsic::powi: // Rounding not defined: support with fast-math? |
188 case Intrinsic::prefetch: // Could ignore if target doesn't support? | 195 case Intrinsic::prefetch: // Could ignore if target doesn't support? |
189 case Intrinsic::returnaddress: // Support for 0-level or not? | |
190 case Intrinsic::sin: // Rounding not defined: support with fast-math? | 196 case Intrinsic::sin: // Rounding not defined: support with fast-math? |
191 case Intrinsic::sqrt: | 197 case Intrinsic::sqrt: |
192 case Intrinsic::stackrestore: // Used to support C99 VLAs. | 198 case Intrinsic::stackrestore: // Used to support C99 VLAs. |
193 case Intrinsic::stacksave: | 199 case Intrinsic::stacksave: |
194 // the *_with_overflow return struct types, so we'll need to fix these. | 200 // the *_with_overflow return struct types, so we'll need to fix these. |
195 case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv | 201 case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv |
196 case Intrinsic::ssub_with_overflow: | 202 case Intrinsic::ssub_with_overflow: |
197 case Intrinsic::uadd_with_overflow: | 203 case Intrinsic::uadd_with_overflow: |
198 case Intrinsic::usub_with_overflow: | 204 case Intrinsic::usub_with_overflow: |
199 case Intrinsic::smul_with_overflow: | 205 case Intrinsic::smul_with_overflow: |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 317 } |
312 | 318 |
313 char PNaClABIVerifyModule::ID = 0; | 319 char PNaClABIVerifyModule::ID = 0; |
314 INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module", | 320 INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module", |
315 "Verify module for PNaCl", false, true) | 321 "Verify module for PNaCl", false, true) |
316 | 322 |
317 ModulePass *llvm::createPNaClABIVerifyModulePass( | 323 ModulePass *llvm::createPNaClABIVerifyModulePass( |
318 PNaClABIErrorReporter *Reporter) { | 324 PNaClABIErrorReporter *Reporter) { |
319 return new PNaClABIVerifyModule(Reporter); | 325 return new PNaClABIVerifyModule(Reporter); |
320 } | 326 } |
OLD | NEW |