[LLVMdev] How do you add MachineBlockPlacement to a Function Pass Manager?

Andrew Trick atrick at apple.com
Tue Sep 24 00:57:37 PDT 2013


On Sep 19, 2013, at 1:46 PM, greatwolf <llvm.greatwolf at mamber.net> wrote:

> I'm trying to port llvm-lua so it's buildable with llvm trunk. A problem I'm
> running into is that it uses the older BlockPlacement pass. From searching
> around and reading llvm's commit, this pass has been replaced and superseded
> by Chandler's MachineBlockPlacement pass.
> 
> What's unclear to me is how exactly do you add this pass to say a function
> pass manager?
> 
> The current llvm-lua code has something like this:
> 
>    // ...
>    if(OptLevel > 1) {
>      TheFPM = new llvm::FunctionPassManager(M);
>    // add some passes for opt1
>    // ...
>      if(OptLevel > 2) {
>        // BlockPlacement
>        TheFPM->add(llvm::createBlockPlacementPass());
>        // Reassociate expressions.
>        TheFPM->add(llvm::createReassociatePass());
>    // etc ...
> 
> It looks like llvm actually had a `createMachineBlockPlacementPass` once a
> upon a time. But that was removed and refactored by atrick #150100. It now
> just has a
> 
>    extern char &MachineBlockPlacementID;
> 
> in Passes.h instead.
> 
> I'm /very/ new to llvm and only started looking at it a few days ago. After
> exhaustively checking through the doc, I still cannot find any example or
> explanation on how to do this.
> 
> If there's no corresponding `create*Pass` for a given pass how would you add
> it to a manager? Is there some way to add that pass via ID or are they not
> meant to be added this way?

Pass::createPass(ID) can instantiate a pass from its ID. But you don't want to create a MachineFunctionPass at this point in your pipeline. Machine passes are configured within TargetPassConfig, which is probably not something you need to meddle with.

I think you're looking at an old IR-level block placement that is now obsolete. I don't remember when it was removed, but it should be safe to ignore.
-Andy



More information about the llvm-dev mailing list