SelectionDAG& dag = ... // initialize SelectionDAG const Function* currentFn = dag.getMachineFunction().getFunction(); if (currentFn != nullptr) { errs() << "Current function name: " << currentFn->getName() << "\n"; }
SelectionDAG& dag = ... // initialize SelectionDAG LLVMContext& ctx = dag.getContext(); Module* module = ... // initialize module StringRef functionName = "foo"; Function* fn = module->getFunction(functionName); if (fn != nullptr) { MachineFunction& mf = dag.getMachineFunction(*fn); errs() << "Size of machine function for " << functionName << ": " << mf.size() << "\n"; }These examples are part of the LLVM library, specifically the SelectionDAG package.