Chromium Code Reviews| Index: lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| index 8bf0848fd713df46478adf6a54569496e7a70dea..697d453b5382e078f29501b590bb449fceed8aea 100644 |
| --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp |
| @@ -13,14 +13,17 @@ |
| // |
| //===----------------------------------------------------------------------===// |
| -#include "llvm/Pass.h" |
| +#include "llvm/ADT/STLExtras.h" |
| #include "llvm/ADT/StringMap.h" |
| #include "llvm/ADT/Twine.h" |
| #include "llvm/Analysis/NaCl.h" |
| #include "llvm/IR/Constants.h" |
| #include "llvm/IR/DerivedTypes.h" |
| +#include "llvm/IR/Instructions.h" |
| #include "llvm/IR/Intrinsics.h" |
| #include "llvm/IR/Module.h" |
| +#include "llvm/IR/NaClIntrinsics.h" |
| +#include "llvm/Pass.h" |
| #include "llvm/Support/Debug.h" |
| #include "llvm/Support/raw_ostream.h" |
| @@ -67,6 +70,8 @@ class PNaClABIVerifyModule : public ModulePass { |
| virtual void print(raw_ostream &O, const Module *M) const; |
| private: |
| void checkGlobalValueCommon(const GlobalValue *GV); |
| + bool isWhitelistedIntrinsic(const NaCl::AtomicIntrinsics *AI, |
|
Mark Seaborn
2013/07/03 04:55:20
This isn't defined any more after rebasing
JF
2013/07/03 15:06:13
Done, and the include up top.
|
| + const Function *F, Intrinsic::ID ID); |
| bool isWhitelistedMetadata(const NamedMDNode *MD); |
| /// Returns whether \p GV is an allowed external symbol in stable bitcode. |
| @@ -173,6 +178,7 @@ void PNaClABIVerifyModule::checkGlobalValueCommon(const GlobalValue *GV) { |
| AllowedIntrinsics::AllowedIntrinsics(LLVMContext *Context) : Context(Context) { |
| Type *I8Ptr = Type::getInt8PtrTy(*Context); |
| + Type *I8 = Type::getInt8Ty(*Context); |
| Type *I16 = Type::getInt16Ty(*Context); |
| Type *I32 = Type::getInt32Ty(*Context); |
| Type *I64 = Type::getInt64Ty(*Context); |
| @@ -197,6 +203,16 @@ AllowedIntrinsics::AllowedIntrinsics(LLVMContext *Context) : Context(Context) { |
| addIntrinsic(Intrinsic::nacl_longjmp); |
| addIntrinsic(Intrinsic::nacl_setjmp); |
| + Type *AtomicTypes[] = { I8, I16, I32, I64 }; |
| + for (Type **T = &AtomicTypes[0], **E = T + array_lengthof(AtomicTypes); |
| + T != E; ++T) { |
| + addIntrinsic(Intrinsic::nacl_atomic_load, *T); |
| + addIntrinsic(Intrinsic::nacl_atomic_store, *T); |
| + addIntrinsic(Intrinsic::nacl_atomic_rmw, *T); |
| + addIntrinsic(Intrinsic::nacl_atomic_cmpxchg, *T); |
| + } |
| + addIntrinsic(Intrinsic::nacl_atomic_fence); |
| + |
| // Stack save and restore are used to support C99 VLAs. |
| addIntrinsic(Intrinsic::stacksave); |
| addIntrinsic(Intrinsic::stackrestore); |
| @@ -215,7 +231,7 @@ AllowedIntrinsics::AllowedIntrinsics(LLVMContext *Context) : Context(Context) { |
| bool AllowedIntrinsics::isAllowed(const Function *Func) { |
| // Keep 3 categories of intrinsics for now. |
| // (1) Allowed always, provided the exact name and type match. |
| - // (2) Never allowed |
| + // (2) Never allowed. |
| // (3) "Dev" intrinsics, which may or may not be allowed. |
| // "Dev" intrinsics are controlled by the PNaClABIAllowDevIntrinsics flag. |
| // Please keep these sorted or grouped in a sensible way, within |