Search code examples
llvmobfuscationllvm-clangllvm-irllvm-gcc

LLVM undefined reference to llvm::createDemoteRegisterToMemoryPass


I'm working on OLLVM (https://github.com/obfuscator-llvm/obfuscator), which is an obfuscation project based LLVM. I'm getting the error message above when trying to use reg2mem pass in my own pass. The code is as blow.

struct MyPass : public FunctionPass {
    static char ID;
    MyPass():FunctionPass(ID) {}
    bool runOnFunction(Function &F);
};

bool MyPass::runOnFunction(Function &F) {
    FunctionPass *regPass = createDemoteRegisterToMemoryPass();
    regPass->runOnFunction(F);
    return false;
}  

I build the whole project as it says on github wiki.
I'll appreciate a lot if anyone who can help me.


Solution

  • In file lib/Transforms/Obfuscation/LLVMBuild.txt add the following line:

    required_libraries = Scalar

    or if you already have required_libraries in that file just add Scalar to the libs after a white space