Changeset 4371


Ignore:
Timestamp:
Dec 29, 2014, 5:13:27 PM (4 years ago)
Author:
nmedfort
Message:

Potential but barely tested fix for nested Ifs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4359 r4371  
    693693            genAdvanceOutStore(carry_summary, mAdvanceQueueIdx++); //baseAdvanceQueueIdx + ifAdvanceCount - 1);
    694694        }
    695         bIfBody.CreateBr(ifEndBlock);
    696 
     695        // If we compiled an If or a While statement, we won't be in the same basic block as before.
     696        // Create the branch from the current basic block to the end block.
     697        IRBuilder<> bIfBodyEndBlock(mBasicBlock);
     698        bIfBodyEndBlock.CreateBr(ifEndBlock);
    697699        //End Block
    698700        IRBuilder<> bEnd(ifEndBlock);
    699         mBasicBlock = ifEndBlock;
    700        
    701701        for (const Assign * a : ifStatement->getDefined()) {
    702702            PHINode * phi = bEnd.CreatePHI(mBitBlockType, 2, a->getName()->str());
     
    704704            assert (f != mMarkerMap.end());
    705705            phi->addIncoming(mZeroInitializer, ifEntryBlock);
    706             phi->addIncoming(f->second, ifBodyBlock);
     706            phi->addIncoming(f->second, mBasicBlock);
    707707            mMarkerMap[a->getName()] = phi;
    708708        }
     709        // Set the basic block to the new end block
     710        mBasicBlock = ifEndBlock;
    709711    }
    710712    else if (const While * whileStatement = dyn_cast<const While>(stmt))
Note: See TracChangeset for help on using the changeset viewer.