[llvm-commits] Pass manager bug fix

Guo, Xiaoyi Xiaoyi.Guo at amd.com
Thu Aug 25 15:25:55 PDT 2011


Please review the attached fix for a problem in the pass manager, and commit if acceptable. The fix is against TOT and has passed regression tests.

The problem is in the assignPassManager() methods. For example, in LoopPass::assignPassManager():

    // Create new Loop Pass Manager if it does not exist.
    assert (!PMS.empty() && "Unable to create Loop Pass Manager");
    PMDataManager *PMD = PMS.top();

    // [1] Create new Call Graph Pass Manager
    LPPM = new LPPassManager();
    LPPM->populateInheritedAnalysis(PMS);

    // [2] Set up new manager's top level manager
    PMTopLevelManager *TPM = PMD->getTopLevelManager();
    TPM->addIndirectPassManager(LPPM);

    // [3] Assign manager to manage this new manager. This may create
    // and push new managers into PMS
    Pass *P = LPPM->getAsPass();
    TPM->schedulePass(P);

    // [4] Push new manager into PMS
    PMS.push(LPPM);


Step 3 above may create and push new managers into PMS, in which case the Depth of LPPM will no longer be correct. This may in turn cause other things to go wrong. For example, it may cause some analysis passes to be freed prematurely and cause crash.

My fix is to not set the depth of a pass manager until it is pushed onto the stack.

Regards,
Xiaoyi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110825/1adcab34/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PassManager.diff
Type: application/octet-stream
Size: 9371 bytes
Desc: PassManager.diff
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110825/1adcab34/attachment.obj>


More information about the llvm-commits mailing list