about summary refs log tree commit diff homepage
path: root/lib/Module/Passes.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Module/Passes.h')
-rw-r--r--lib/Module/Passes.h53
1 files changed, 29 insertions, 24 deletions
diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h
index b3c46124..accb64d0 100644
--- a/lib/Module/Passes.h
+++ b/lib/Module/Passes.h
@@ -12,9 +12,15 @@
 
 #include "klee/Config/Version.h"
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Module.h"
+#else
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
+#endif
 #include "llvm/Pass.h"
 #include "llvm/CodeGen/IntrinsicLowering.h"
 
@@ -38,9 +44,7 @@ namespace klee {
 class RaiseAsmPass : public llvm::ModulePass {
   static char ID;
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9)
   const llvm::TargetLowering *TLI;
-#endif
 
   llvm::Function *getIntrinsic(llvm::Module &M,
                                unsigned IID,
@@ -55,11 +59,7 @@ class RaiseAsmPass : public llvm::ModulePass {
   bool runOnInstruction(llvm::Module &M, llvm::Instruction *I);
 
 public:
-#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
-  RaiseAsmPass() : llvm::ModulePass((intptr_t) &ID) {}
-#else
-  RaiseAsmPass() : llvm::ModulePass(ID) {}
-#endif
+  RaiseAsmPass() : llvm::ModulePass(ID), TLI(0) {}
   
   virtual bool runOnModule(llvm::Module &M);
 };
@@ -76,7 +76,7 @@ class IntrinsicCleanerPass : public llvm::ModulePass {
   llvm::IntrinsicLowering *IL;
   bool LowerIntrinsics;
 
-  bool runOnBasicBlock(llvm::BasicBlock &b);
+  bool runOnBasicBlock(llvm::BasicBlock &b, llvm::Module &M);
 public:
 #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
   IntrinsicCleanerPass(const llvm::TargetData &TD,
@@ -84,11 +84,7 @@ public:
   IntrinsicCleanerPass(const llvm::DataLayout &TD,
 #endif
                        bool LI=true)
-#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
-    : llvm::ModulePass((intptr_t) &ID),
-#else
     : llvm::ModulePass(ID),
-#endif
 #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
       TargetData(TD),
 #else
@@ -117,11 +113,7 @@ class PhiCleanerPass : public llvm::FunctionPass {
   static char ID;
 
 public:
-#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
-  PhiCleanerPass() : llvm::FunctionPass((intptr_t) &ID) {}
-#else
   PhiCleanerPass() : llvm::FunctionPass(ID) {}
-#endif
   
   virtual bool runOnFunction(llvm::Function &f);
 };
@@ -129,11 +121,28 @@ public:
 class DivCheckPass : public llvm::ModulePass {
   static char ID;
 public:
-#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
-  DivCheckPass(): ModulePass((intptr_t) &ID) {}
-#else
   DivCheckPass(): ModulePass(ID) {}
-#endif
+  virtual bool runOnModule(llvm::Module &M);
+};
+
+/// This pass injects checks to check for overshifting.
+///
+/// Overshifting is where a Shl, LShr or AShr is performed
+/// where the shift amount is greater than width of the bitvector
+/// being shifted.
+/// In LLVM (and in C/C++) this undefined behaviour!
+///
+/// Example:
+/// \code
+///     unsigned char x=15;
+///     x << 4 ; // Defined behaviour
+///     x << 8 ; // Undefined behaviour
+///     x << 255 ; // Undefined behaviour
+/// \endcode
+class OvershiftCheckPass : public llvm::ModulePass {
+  static char ID;
+public:
+  OvershiftCheckPass(): ModulePass(ID) {}
   virtual bool runOnModule(llvm::Module &M);
 };
 
@@ -143,11 +152,7 @@ public:
 class LowerSwitchPass : public llvm::FunctionPass {
 public:
   static char ID; // Pass identification, replacement for typeid
-#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
-  LowerSwitchPass() : FunctionPass((intptr_t) &ID) {} 
-#else
   LowerSwitchPass() : FunctionPass(ID) {} 
-#endif
   
   virtual bool runOnFunction(llvm::Function &F);