1 //===- TestPasses.cpp - "buggy" passes used to test bugpoint --------------===//
3 // This file contains "buggy" passes that are used to test bugpoint, to check
4 // that it is narrowing down testcases correctly.
6 //===----------------------------------------------------------------------===//
9 #include "llvm/iOther.h"
10 #include "llvm/Support/InstVisitor.h"
11 #include "llvm/Constant.h"
12 #include "llvm/BasicBlock.h"
15 /// CrashOnCalls - This pass is used to test bugpoint. It intentionally
16 /// crashes on any call instructions.
17 class CrashOnCalls : public BasicBlockPass {
18 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
22 bool runOnBasicBlock(BasicBlock &BB) {
23 for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
24 if (isa<CallInst>(*I))
31 RegisterPass<CrashOnCalls>
32 X("bugpoint-crashcalls",
33 "BugPoint Test Pass - Intentionally crash on CallInsts");
37 /// DeleteCalls - This pass is used to test bugpoint. It intentionally
38 /// deletes all call instructions, "misoptimizing" the program.
39 class DeleteCalls : public BasicBlockPass {
40 bool runOnBasicBlock(BasicBlock &BB) {
41 for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
42 if (CallInst *CI = dyn_cast<CallInst>(I)) {
44 CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
45 CI->getParent()->getInstList().erase(CI);
51 RegisterPass<DeleteCalls>
52 Y("bugpoint-deletecalls",
53 "BugPoint Test Pass - Intentionally 'misoptimize' CallInsts");