Hello LLVM Folks,
I just tried running the example off http://llvm.org/docs/WritingAnLLVMPass.html#quickstart. I used the same code in the example to create a new pass called hello, and tried compiling the same like:
The code for pass.cpp:
#include “llvm/Pass.h”
#include “llvm/Function.h”
#include “llvm/Support/raw_ostream.h”
using namespace llvm;
namespace {
struct Hello : public FunctionPass {
static char ID;
Hello() : FunctionPass(ID) {}
virtual bool runOnFunction(Function &F) {
errs() << "Hello: ";
errs().write_escaped(F.getName()) << ‘\n’;
return false;
}
};
}
char Hello::ID = 0;
static RegisterPass X(“hello”, “Hello World Pass”, false, false);
Compile Steps:
g++ -c pass.cpp -I/usr/local/include llvm-config --cxxflags
g++ -shared -o pass.so pass.o -L/usr/local/lib llvm-config --ldflags --libs
Followed by:
opt -load=pass.so -help
But I see no mention of hello in the output. I am using MacOSX Lion, and the llvm code is something that I checked out recently from the trunk. I ran nm on pass.so and the symbols for hello are present just fine.
Not sure what is that I missing here. Any help?
Arpan