this maybe rookie question there way integrate llvm modulepass called default during transformation phase?
right using syntax load pass , register
~/llvm/llvm/build/debug+asserts/bin/clang -xclang -load -xclang ~/llvm/llvm/build/debug+asserts/lib/somepasslib.so
(the problem when want build package pass, compiler accepts when say, pass loading part cflags env variable, makefiles use cflags linking too, , linker has no idea can information , fails build :\ )
there couple of files need modify in order define pass inside llvm core:
i) inside pass: loadable pass registered (assuming pass name functioninfo):
char functioninfo::id = 0; registerpass<functioninfo> x("function-info", "functions information");
you need change this:
char functioninfo::id = 0; initialize_pass_begin(functioninfo, "function-info", "gathering function info", false, false) initialize_pass_dependency(dominatortree) initialize_pass_dependency(loopinfo) .... // initialize passes pass needs initialize_pass_end(functioninfo, "function-info", "gathering function info", false, false) modulepass *llvm::createfunctioninfopass() { return new functioninfo(); }
ii) need register pass inside llvm well, @ least in initializepasses.h , linkallpasses.h. in linkallpasses.h should add :
(void)llvm::createfunctioninfopass();
and in initializepasses.h add :
void initializefunctioninfopass(passregistry &);
iii) beside modifications might need change file depend on going add pass. instance if going add in lib/analysis/ need add 1 line analysis.cpp below :
initializefunctioninfopass(registry);
or if going add new scalar transform need modify both scalar.h , scalar.cpp likewise.