diff options
author | Julian Büning <julian.buening@rwth-aachen.de> | 2018-05-12 19:49:07 +0200 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2018-05-22 16:24:46 +0100 |
commit | 45dbf0624f6fe37d25ba401c2bf99b8315f8847b (patch) | |
tree | 94ebd15744b8ee84e1735f657774e5e1d1d862c0 | |
parent | 1b8bad9dda673f1340b50c39334eb92ee8a8c306 (diff) | |
download | klee-45dbf0624f6fe37d25ba401c2bf99b8315f8847b.tar.gz |
some housekeeping in Passes.h and IntrinsicCleaner.cpp
This commit addresses the following: * remove unused variables block_split (::runOnBasicBlock) and LI (::IntrinsicCleanerPass) in IntrinsicCleanerPass * add `dirty = true` to `Intrinsic::vacopy` case * use `eraseFromParent()` methods instead of `removeFromParent()` and `delete` * add `override` keyword to `runOn{Module,Function}` methods
-rw-r--r-- | lib/Module/IntrinsicCleaner.cpp | 18 | ||||
-rw-r--r-- | lib/Module/Passes.h | 27 |
2 files changed, 21 insertions, 24 deletions
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 10b5df08..4e3c3796 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -45,15 +45,13 @@ bool IntrinsicCleanerPass::runOnModule(Module &M) { bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { bool dirty = false; - bool block_split=false; LLVMContext &ctx = M.getContext(); unsigned WordSize = DataLayout.getPointerSizeInBits() / 8; - for (BasicBlock::iterator i = b.begin(), ie = b.end(); - (i != ie) && (block_split == false);) { + for (BasicBlock::iterator i = b.begin(), ie = b.end(); i != ie;) { IntrinsicInst *ii = dyn_cast<IntrinsicInst>(&*i); - // increment now since LowerIntrinsic deletion makes iterator invalid. - ++i; + // increment now since deletion of instructions makes iterator invalid. + ++i; if(ii) { switch (ii->getIntrinsicID()) { case Intrinsic::vastart: @@ -89,8 +87,8 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii); val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii); } - ii->removeFromParent(); - delete ii; + ii->eraseFromParent(); + dirty = true; break; } @@ -176,20 +174,20 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { resultStruct = builder.CreateInsertValue(resultStruct, overflow, 1); ii->replaceAllUsesWith(resultStruct); - ii->removeFromParent(); - delete ii; + ii->eraseFromParent(); dirty = true; break; } case Intrinsic::dbg_value: - case Intrinsic::dbg_declare: + case Intrinsic::dbg_declare: { // Remove these regardless of lower intrinsics flag. This can // be removed once IntrinsicLowering is fixed to not have bad // caches. ii->eraseFromParent(); dirty = true; break; + } case Intrinsic::trap: { // Intrisic instruction "llvm.trap" found. Directly lower it to diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h index 88c0ce8c..e6fa18ce 100644 --- a/lib/Module/Passes.h +++ b/lib/Module/Passes.h @@ -49,8 +49,8 @@ class RaiseAsmPass : public llvm::ModulePass { public: RaiseAsmPass() : llvm::ModulePass(ID), TLI(0) {} - - virtual bool runOnModule(llvm::Module &M); + + bool runOnModule(llvm::Module &M) override; }; // This is a module pass because it can add and delete module @@ -62,12 +62,12 @@ class IntrinsicCleanerPass : public llvm::ModulePass { bool runOnBasicBlock(llvm::BasicBlock &b, llvm::Module &M); public: - IntrinsicCleanerPass(const llvm::DataLayout &TD, bool LI = true) + IntrinsicCleanerPass(const llvm::DataLayout &TD) : llvm::ModulePass(ID), DataLayout(TD), IL(new llvm::IntrinsicLowering(TD)) {} ~IntrinsicCleanerPass() { delete IL; } - virtual bool runOnModule(llvm::Module &M); + bool runOnModule(llvm::Module &M) override; }; // performs two transformations which make interpretation @@ -87,15 +87,15 @@ class PhiCleanerPass : public llvm::FunctionPass { public: PhiCleanerPass() : llvm::FunctionPass(ID) {} - - virtual bool runOnFunction(llvm::Function &f); + + bool runOnFunction(llvm::Function &f) override; }; class DivCheckPass : public llvm::ModulePass { static char ID; public: DivCheckPass(): ModulePass(ID) {} - virtual bool runOnModule(llvm::Module &M); + bool runOnModule(llvm::Module &M) override; }; /// This pass injects checks to check for overshifting. @@ -116,7 +116,7 @@ class OvershiftCheckPass : public llvm::ModulePass { static char ID; public: OvershiftCheckPass(): ModulePass(ID) {} - virtual bool runOnModule(llvm::Module &M); + bool runOnModule(llvm::Module &M) override; }; /// LowerSwitchPass - Replace all SwitchInst instructions with chained branch @@ -125,10 +125,10 @@ public: class LowerSwitchPass : public llvm::FunctionPass { public: static char ID; // Pass identification, replacement for typeid - LowerSwitchPass() : FunctionPass(ID) {} - - virtual bool runOnFunction(llvm::Function &F); - + LowerSwitchPass() : FunctionPass(ID) {} + + bool runOnFunction(llvm::Function &F) override; + struct SwitchCase { llvm ::Constant *value; llvm::BasicBlock *block; @@ -170,8 +170,7 @@ public: static char ID; InstructionOperandTypeCheckPass() : llvm::ModulePass(ID), instructionOperandsConform(true) {} - // TODO: Add `override` when we switch to C++11 - bool runOnModule(llvm::Module &M); + bool runOnModule(llvm::Module &M) override; bool checkPassed() const { return instructionOperandsConform; } }; } |