Created
April 9, 2019 18:22
-
-
Save nazwadi/81f372123a64ee217b4fe7a8f9aa13de to your computer and use it in GitHub Desktop.
LLVM_Template - modified slightly from the example in http://llvm.org/docs/ProgrammersManual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From http://llvm.org/docs/ProgrammersManual.html | |
#include "llvm/Pass.h" | |
#include "llvm/IR/Function.h" | |
#include "llvm/Support/raw_ostream.h" | |
using namespace llvm; | |
namespace { | |
struct Hello : public FunctionPass { | |
static char ID; | |
Hello() : FunctionPass(ID) {} | |
virtual bool doInitialization(Module &M) { | |
return false; | |
} | |
virtual bool doFinalization(Module &M) { | |
return false; | |
} | |
bool runOnFunction(Function &F) override { | |
errs() << "Hello: "; | |
errs().write_escaped(F.getName()) << '\n'; | |
return false; | |
} | |
}; // end of struct Hello | |
} | |
char Hello::ID = 0; | |
static RegisterPass<Hello> X("hello", "Hello World Pass", | |
false /* Only looks at CFG */, | |
false /* Analysis Pass */); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment