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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 case Intrinsic::eh_unwind_init: | 192 case Intrinsic::eh_unwind_init: |
193 // We do not want to expose addresses to the user. | 193 // We do not want to expose addresses to the user. |
194 case Intrinsic::frameaddress: | 194 case Intrinsic::frameaddress: |
195 case Intrinsic::returnaddress: | 195 case Intrinsic::returnaddress: |
196 // Not supporting stack protectors. | 196 // Not supporting stack protectors. |
197 case Intrinsic::stackprotector: | 197 case Intrinsic::stackprotector: |
198 // Var-args handling is done w/out intrinsics. | 198 // Var-args handling is done w/out intrinsics. |
199 case Intrinsic::vacopy: | 199 case Intrinsic::vacopy: |
200 case Intrinsic::vaend: | 200 case Intrinsic::vaend: |
201 case Intrinsic::vastart: | 201 case Intrinsic::vastart: |
| 202 // Disallow the *_with_overflow intrinsics because they return |
| 203 // struct types. All of them can be introduced by passing -ftrapv |
| 204 // to Clang, which we do not support for now. umul_with_overflow |
| 205 // and uadd_with_overflow are introduced by Clang for C++'s new[], |
| 206 // but ExpandArithWithOverflow expands out this use. |
| 207 case Intrinsic::sadd_with_overflow: |
| 208 case Intrinsic::ssub_with_overflow: |
| 209 case Intrinsic::uadd_with_overflow: |
| 210 case Intrinsic::usub_with_overflow: |
| 211 case Intrinsic::smul_with_overflow: |
| 212 case Intrinsic::umul_with_overflow: |
202 return false; | 213 return false; |
203 | 214 |
204 // (3) Dev intrinsics. | 215 // (3) Dev intrinsics. |
205 case Intrinsic::dbg_declare: | 216 case Intrinsic::dbg_declare: |
206 case Intrinsic::dbg_value: | 217 case Intrinsic::dbg_value: |
207 return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata; | 218 return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata; |
208 case Intrinsic::cos: // Rounding not defined: support with fast-math? | 219 case Intrinsic::cos: // Rounding not defined: support with fast-math? |
209 case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? | 220 case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? |
210 case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? | 221 case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? |
211 case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it? | 222 case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it? |
212 case Intrinsic::exp: // Rounding not defined: support with fast-math? | 223 case Intrinsic::exp: // Rounding not defined: support with fast-math? |
213 case Intrinsic::exp2: // Rounding not defined: support with fast-math? | 224 case Intrinsic::exp2: // Rounding not defined: support with fast-math? |
214 case Intrinsic::expect: // From __builtin_expect. | 225 case Intrinsic::expect: // From __builtin_expect. |
215 case Intrinsic::flt_rounds: // For FLT_ROUNDS macro from float.h. | 226 case Intrinsic::flt_rounds: // For FLT_ROUNDS macro from float.h. |
216 // We do not have fesetround() in newlib, can we return a | 227 // We do not have fesetround() in newlib, can we return a |
217 // consistent rounding mode though? | 228 // consistent rounding mode though? |
218 case Intrinsic::log: // Rounding not defined: support with fast-math? | 229 case Intrinsic::log: // Rounding not defined: support with fast-math? |
219 case Intrinsic::log2: // Rounding not defined: support with fast-math? | 230 case Intrinsic::log2: // Rounding not defined: support with fast-math? |
220 case Intrinsic::log10: // Rounding not defined: support with fast-math? | 231 case Intrinsic::log10: // Rounding not defined: support with fast-math? |
221 case Intrinsic::nacl_target_arch: // Used by translator self-build. | 232 case Intrinsic::nacl_target_arch: // Used by translator self-build. |
222 case Intrinsic::pow: // Rounding is supposed to be the same as libm. | 233 case Intrinsic::pow: // Rounding is supposed to be the same as libm. |
223 case Intrinsic::powi: // Rounding not defined: support with fast-math? | 234 case Intrinsic::powi: // Rounding not defined: support with fast-math? |
224 case Intrinsic::prefetch: // Could ignore if target doesn't support? | 235 case Intrinsic::prefetch: // Could ignore if target doesn't support? |
225 case Intrinsic::sin: // Rounding not defined: support with fast-math? | 236 case Intrinsic::sin: // Rounding not defined: support with fast-math? |
226 case Intrinsic::sqrt: // Rounding is defined, but setting errno up to libm. | 237 case Intrinsic::sqrt: // Rounding is defined, but setting errno up to libm. |
227 case Intrinsic::stackrestore: // Used to support C99 VLAs. | 238 case Intrinsic::stackrestore: // Used to support C99 VLAs. |
228 case Intrinsic::stacksave: // Used to support C99 VLAs. | 239 case Intrinsic::stacksave: // Used to support C99 VLAs. |
229 // the *_with_overflow return struct types, so we'll need to fix these. | |
230 case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv | |
231 case Intrinsic::ssub_with_overflow: | |
232 case Intrinsic::uadd_with_overflow: | |
233 case Intrinsic::usub_with_overflow: | |
234 case Intrinsic::smul_with_overflow: | |
235 case Intrinsic::umul_with_overflow: // Introduced by c++ new[x * y]. | |
236 return PNaClABIAllowDevIntrinsics; | 240 return PNaClABIAllowDevIntrinsics; |
237 } | 241 } |
238 } | 242 } |
239 | 243 |
240 bool PNaClABIVerifyModule::isWhitelistedMetadata(const NamedMDNode *MD) { | 244 bool PNaClABIVerifyModule::isWhitelistedMetadata(const NamedMDNode *MD) { |
241 return MD->getName().startswith("llvm.dbg.") && PNaClABIAllowDebugMetadata; | 245 return MD->getName().startswith("llvm.dbg.") && PNaClABIAllowDebugMetadata; |
242 } | 246 } |
243 | 247 |
244 bool PNaClABIVerifyModule::runOnModule(Module &M) { | 248 bool PNaClABIVerifyModule::runOnModule(Module &M) { |
245 if (!M.getModuleInlineAsm().empty()) { | 249 if (!M.getModuleInlineAsm().empty()) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 355 } |
352 | 356 |
353 char PNaClABIVerifyModule::ID = 0; | 357 char PNaClABIVerifyModule::ID = 0; |
354 INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module", | 358 INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module", |
355 "Verify module for PNaCl", false, true) | 359 "Verify module for PNaCl", false, true) |
356 | 360 |
357 ModulePass *llvm::createPNaClABIVerifyModulePass( | 361 ModulePass *llvm::createPNaClABIVerifyModulePass( |
358 PNaClABIErrorReporter *Reporter) { | 362 PNaClABIErrorReporter *Reporter) { |
359 return new PNaClABIVerifyModule(Reporter); | 363 return new PNaClABIVerifyModule(Reporter); |
360 } | 364 } |
OLD | NEW |