#include <llvm/Support/raw_ostream.h>
#include <llvm/Module.h>
#include <llvm/LLVMContext.h>

#include <llvm/Pass.h>
#include <llvm/PassManager.h>
#include <llvm/Analysis/LoopInfo.h>

using namespace llvm;

class TestMP : public ModulePass {
	public:
		static char ID;
		TestMP() : ModulePass(ID) {}
		virtual void getAnalysisUsage(AnalysisUsage& AU) const {
			// if the line below is not commented out, a segfault in llvm::PassInfo::isAnalysisGroup occurs:
			// llvm::PassInfo::createPass (this=0x0) at llvm/lib/VMCore/Pass.cpp:196
			AU.addRequired<LoopInfo>();
		}
		virtual bool runOnModule(Module& M) {
			outs() << "\nHELLO!\n";
			return false;
		}
};
char TestMP::ID = 0;
static RegisterPass<TestMP> TMP("asdf", "ASDF");

int main(void) {
	Module mod("test", getGlobalContext());

	PassManager PM;
	PM.add(new TestMP());
	PM.run(mod);

	return 0;
}
