Chromium Code Reviews| Index: lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| index 44c027fba4690762eb1facec317d022db28bbf95..084ddbeb9ff3f7093793688a21934adfd9fc9dac 100644 |
| --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| @@ -122,6 +122,23 @@ void PNaClABIVerifyModule::CheckGlobalValueCommon(const GlobalValue *GV) { |
| } |
| } |
| +static bool IntTypeAcceptable(unsigned width, |
| + const ArrayRef<unsigned>& AcceptableSizes) { |
| + for (unsigned i = 0; i < AcceptableSizes.size(); ++i) |
|
eliben
2013/05/15 23:34:54
Would it be cleaner to iterate over it (it has ite
jvoung (off chromium)
2013/05/16 16:45:00
Done.
|
| + if (AcceptableSizes[i] == width) |
| + return true; |
| + return false; |
| +} |
| + |
| +static bool FunctionHasIntArg1(const Function* F, |
|
eliben
2013/05/15 23:34:54
The name is not entirely clear... also you may be
jvoung (off chromium)
2013/05/16 16:45:00
Well, I assume I'll be checking parameter types fo
|
| + const ArrayRef<unsigned>& AcceptableSizes) { |
| + FunctionType* FT = F->getFunctionType(); |
| + if (FT->getNumParams() != 1) |
| + return false; |
| + return IntTypeAcceptable(FT->getParamType(0)->getIntegerBitWidth(), |
| + AcceptableSizes); |
| +} |
| + |
| bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, |
| unsigned ID) { |
| // Keep 3 categories of intrinsics for now. |
| @@ -135,6 +152,10 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, |
| // Disallow by default. |
| default: return false; |
| // (1) Always allowed. |
| + case Intrinsic::bswap: { |
|
eliben
2013/05/15 23:34:54
I think this would be clearer in a method - isWhit
jvoung (off chromium)
2013/05/16 16:45:00
Done.
|
| + unsigned accepted_sizes[] = { 16, 32, 64 }; |
| + return FunctionHasIntArg1(F, accepted_sizes); |
| + } |
| case Intrinsic::invariant_end: |
| case Intrinsic::invariant_start: |
| case Intrinsic::lifetime_end: |
| @@ -179,7 +200,6 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, |
| case Intrinsic::dbg_declare: |
| case Intrinsic::dbg_value: |
| return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata; |
| - case Intrinsic::bswap: // Support via compiler_rt if arch doesn't have it? |
| case Intrinsic::cos: // Rounding not defined: support with fast-math? |
| case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? |
| case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? |
| @@ -187,7 +207,9 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, |
| case Intrinsic::exp: // Rounding not defined: support with fast-math? |
| case Intrinsic::exp2: // Rounding not defined: support with fast-math? |
| case Intrinsic::expect: // From __builtin_expect. |
| - case Intrinsic::flt_rounds: |
| + case Intrinsic::flt_rounds: // For FLT_ROUNDS macro from float.h. |
| + // We do not have fesetround() in newlib, can we return a |
| + // consistent rounding mode though? |
| case Intrinsic::log: // Rounding not defined: support with fast-math? |
| case Intrinsic::log2: // Rounding not defined: support with fast-math? |
| case Intrinsic::log10: // Rounding not defined: support with fast-math? |
| @@ -196,9 +218,9 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, |
| case Intrinsic::powi: // Rounding not defined: support with fast-math? |
| case Intrinsic::prefetch: // Could ignore if target doesn't support? |
| case Intrinsic::sin: // Rounding not defined: support with fast-math? |
| - case Intrinsic::sqrt: |
| + case Intrinsic::sqrt: // Rounding is defined, but setting errno up to libm. |
| case Intrinsic::stackrestore: // Used to support C99 VLAs. |
| - case Intrinsic::stacksave: |
| + case Intrinsic::stacksave: // Used to support C99 VLAs. |
| // the *_with_overflow return struct types, so we'll need to fix these. |
| case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv |
| case Intrinsic::ssub_with_overflow: |