How to add LiveVariables pass


In LLVM 3.4 using C++ API I would like to track which physical registers are live. Therefore I want to add a LiveVariables pass to FunctionPassManager. However I get this failed assertion:

Pass ‘Remove unreachable machine basic blocks’ is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
~/llvm-3.4/lib/IR/LegacyPassManager.cpp:645: void llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI && “Expected required passes to be initialized”’ failed.

Looking into CodeGen/UnreachableBlockElim.cpp I find that ‘Remove unreachable machine basic blocks’ is the name of UnreachableMachineBlockElim, for which exists a function prototype ‘void initializeUnreachableMachineBlockElimPass(PassRegistry&);’ in InitializePasses.h. Calling that function (for which I don’t see any implementation…) with llvm::PassRegistry::getPassRegistry() before adding LiveVariables to the pass manager still results in the same failed assertion. Creating an instance of UnreachableMachineBlockElim is not possible because the class is not declared in a header file and therefore not visible to the compiler.

How can I add LiveVariables to my FunctionPassManager?

Best regards,