[LLVMdev] Pass Incompatibility

Luke Dalessandro luked at cs.rochester.edu
Wed Oct 20 09:51:57 PDT 2010


On Oct 20, 2010, at 12:35 PM, John Criswell wrote:

> On 10/20/10 6:05 AM, Luke Dalessandro wrote:
>> I have a transformation where I'd like to use both DominatorTree (for ExtractCodeRegion), and DemoteRegisterToMemory (i.e., reg2mem). The transformation is phased, so all occurrences of getAnalysis<DominatorTree>(Function) happen before any occurrence of getAnalysisID<FunctionPass>(&DemoteRegisterToMemoryID, Function).
> 
> I believe that reg2mem is a transform pass, correct?  

Absolutely.

> If so, then you should not be making it a prerequisite for your pass.  Instead, whatever is scheduling the set of transform passes (e.g, the user on the opt command line or the source code that schedules your pass to be run with a PassManager) should run reg2mem right before your pass is run.  Your pass should assert that the LLVM bitcode has the property that reg2mem creates.

Hmm... so it sounds like the only thing that makes sense in my situation is to split my transformation into two passes, since it's important to me that the incoming code to the pass be post-mem2reg.

> In general, passes cannot depend upon transform passes.  There are certain situations in which PassManager cannot resolve dependencies when a transform pass is part of a dependency chain (e.g., Transform Pass A requires Transform Pass B and Analysis Pass C, but B invalidates C), and so you get cryptic error messages.  That is probably what you are seeing here.

OK. The asymmetry in failures between

  void getAnalysisUsage(AnalysisUsage& au) const {
    au.addRequired<DominatorTree>();
    au.addRequiredID(DemoteRegisterToMemoryID);
  }

and

  void getAnalysisUsage(AnalysisUsage& au) const {
    au.addRequiredID(DemoteRegisterToMemoryID);
    au.addRequired<DominatorTree>();
  }

had me confused.

Luke

> 
> -- John T.
> 
> 
>> If I register these two passes with DominatorTree first, I get the following assert.
>> 
>> PassAnalysisSupport.h:239: AnalysisType&  llvm::Pass::getAnalysisID(const void*, llvm::Function&) [with AnalysisType = llvm::DominatorTree]: Assertion `ResultPass&&  "Unable to find requested analysis info"' failed.
>> 
>> If I register DemoteRegisterToMemoryID first then I get this assert during code extraction.
>> 
>> CodeExtractor.cpp:681: llvm::Function*<unnamed>::CodeExtractor::ExtractCodeRegion(const std::vector<llvm::BasicBlock*, std::allocator<llvm::BasicBlock*>  >&): Assertion `BlocksToExtract.count(*PI)&&  "No blocks in this region may have entries from outside the region" " except for the first block!"' failed.
>> 
>> If I split my pass in half, then the transformation works as expected, with region extraction and DemoteRegisterToMemory going on their merry way. The split pass is harder to understand though, and injects a pass into -help that doesn't actually work on its own.
>> 
>> Is it simply the case the, in order to use these two passes, I must split my transformation into two passes, or is there another/a better way?
>> 
>> Thanks,
>> Luke
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list