[llvm-commits] [LLVMdev] [PATCH] Get DCE to consider livein PhysRegs to successor basic blocks.

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Jun 22 08:46:37 PDT 2011


On Jun 21, 2011, at 12:07 PM, Sanjoy Das wrote:

>> 
>> Looks good, but keep the comment (sans FIXME).
>> 
> 
> Revised patch attached.

Three nits:

-    // FIXME: Add live-ins from sucessors to LivePhysRegs. Normally, physregs
+    // Add live-ins from sucessors to LivePhysRegs. Normally, physregs
     // are not live across blocks, but some targets (x86) can have flags live
     // out of a block.
+    for (MachineBasicBlock::succ_iterator S = MBB->succ_begin();
+         S != MBB->succ_end(); S++) {
+      for (MachineBasicBlock::livein_iterator LI = (*S)->livein_begin();
+           LI != (*S)->livein_end(); LI++) {
+        LivePhysRegs.set(*LI);
+      }
+    }
 
1. Wrap the comment properly.
2. Use the standard LLVM idiom for evaluating the end() methods only once.
3. Don't use {} for single statements.

But note that you really shouldn't be depending on this patch for your work. Live physregs prevent code motion and (now) dead code elimination. Virtual registers are always better.

/jakob





More information about the llvm-commits mailing list