[LLVMdev] MBB Critical edges

Fernando Magno Quintao Pereira fernando at CS.UCLA.EDU
Fri Aug 10 12:30:18 PDT 2007


Hi all,

     I have a pass to break critical edges of Machine Basic Blocks, but I 
just discovered a bug (when compiling code for x86). The problem is 'jumpl 
*%reg'. I don't know how to update the jump table for this type of 
instruction. The code that I had (see below) does not update the jump 
table, and the actual branch keeps jumping to the old basic block, instead 
of the new. Could someone help me to fix this? If it works fine, I can 
send a patch for this pass.

     /// modify every branch in src that points to dst to point
     /// to the new machine basic block "crit_mbb" instead:
     MachineBasicBlock::iterator mii = src.end();
     bool found_branch = false;
     while (mii != src.begin()) {
         mii--;
         // if there are no more branches, finish the loop
         if (!tii->isTerminatorInstr(mii->getOpcode())) {
             break;
         }
         // Scan the operands of this branch, replacing any
         // uses of dst with crit_mbb.
         for (unsigned i = 0, e = mii->getNumOperands(); i != e; ++i) {
             if (mii->getOperand(i).isMachineBasicBlock() &&
                  mii->getOperand(i).getMachineBasicBlock() == & dst) {
                 found_branch = true;
                 mii->getOperand(i).setMachineBasicBlock(crit_mbb);
             }
         }
     }

Thanks a lot,

Fernando



More information about the llvm-dev mailing list