[LLVMdev] write a simple MachineFunctionPass

Lang Hames lhames at gmail.com
Thu Mar 28 12:59:30 PDT 2013


Hi Alexandru,

>  I don't want to use INITIALIZE_PASS since I have to recompile the llvm
file that is keeping the pass registration...

I would have encouraged you to use INITIALIZE_PASS to fix this. If you
really don't want to though, I think RegisterPass is still intended to work
for MachineFunctionPasses, though this may no longer be well tested. Can
you attach a skeleton pass that exhibits the problem you're seeing?

Cheers,
Lang.



On Fri, Mar 15, 2013 at 5:41 AM, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:

> I found that : "Code generator passes are registered and initialized
> specially by TargetMachine::addPassesToEmitFile and similar routines, so
> they cannot generally be run from the *opt* or *bugpoint* commands."...So
> how I can run a MachineFunctionPass? In the end, I just want to apply a DFS
> on a CFG of a function. And I need oriented edges and wanted to use
> MachineBasicBlock::const_succ_iterator. It is there a way to get the CFG
> with oriented edges by using a FunctionPass?
>
> Thank you !
>
>
> On Fri, Mar 15, 2013 at 1:30 PM, Alexandru Ionut Diaconescu <
> alexandruionutdiaconescu at gmail.com> wrote:
>
>> Hello everyone,
>>
>> I have written several complex passes till now, but I cannot write a
>> MachineFunctionPass pass. It just gives me segfault. Hence I reduced the
>> pass to the following form :
>>
>>
>> using namespace llvm;
>>
>> namespace {
>>   class CFGexplorator : public MachineFunctionPass {
>>   public:
>>     static char ID; // Pass identification, replacement for typeid
>>     CFGexplorator() : MachineFunctionPass(ID) {
>>       //initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());
>>     }
>>
>>   private:
>>     virtual bool runOnMachineFunction(MachineFunction &MF);
>>
>>     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
>>       MachineFunctionPass::getAnalysisUsage(AU);
>>     }
>>   };
>> } // end anonymous namespace
>>
>> char CFGexplorator::ID = 0;
>> static RegisterPass<CFGexplorator> Y("mycfg", "mycfg", false, false);
>>
>> bool CFGexplorator::runOnMachineFunction(MachineFunction &MF) {
>> return false;
>> }
>>
>>
>>
>> I get the error :
>> Pass 'mycfg' is not initialized.
>> Verify if there is a pass dependency cycle.
>> Required Passes:
>> opt: PassManager.cpp:638: void
>> llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI &&
>> "Expected required passes to be initialized"' failed.
>>
>>
>> So I have to initialize the pass. But in my all other passes I did not
>> any initialization and I don't want to use INITIALIZE_PASS since I have to
>> recompile the llvm file that is keeping the pass registration... Is there a
>> way to keep using static RegisterPass for a MachineFunctionPass ? I mention
>> that if I change to FunctionPass, I have no problems and that is weird..
>>
>> Thank you for any advice !
>>
>>
>>
>>
>
>
> --
> Best regards,
> Alexandru Ionut Diaconescu
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130328/cec93cb8/attachment.html>


More information about the llvm-dev mailing list