<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br><div><div>On Jul 12, 2013, at 4:29 PM, Manman Ren wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 12, 2013, at 1:54 PM, Jim Grosbach wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Manman,<div><br></div><div>This looks really good and I’m happy with the general approach. One minor note is that I don’t think you need to use a DenseMap<> between the SPAdj values and the MBB pointers. Instead you can just allocate a SmallVector<unsigned> and index it via MachineBasicBlock::Number. MachineFunction::getNumBlockIDs() will give you how many entries to allocate into the vector (it’s >= the number of MBBs since the numbering may have gaps if an MBB was deleted).</div></div></blockquote><div><br></div>Hi Jim,</div><div><br></div><div>Thanks for reviewing the patch.</div><div>Updated patch to use SmallVector instead of DenseMap:</div><div><div>--- lib/CodeGen/PrologEpilogInserter.cpp<span class="Apple-tab-span" style="white-space:pre">        </span>(revision 186215)</div><div>+++ lib/CodeGen/PrologEpilogInserter.cpp<span class="Apple-tab-span" style="white-space:pre">    </span>(working copy)</div><div>@@ -728,7 +728,33 @@</div><div> void PEI::replaceFrameIndices(MachineFunction &Fn) {</div><div>   if (!Fn.getFrameInfo()->hasStackObjects()) return; // Nothing to do?</div><div> </div><div>+  // Store SPAdj at exit of a basic block.</div><div>+  SmallVector<int, 8> SPState;</div><div>+  SPState.resize(Fn.getNumBlockIDs());</div><div>+  SmallPtrSet<MachineBasicBlock*, 8> Reachable;</div><div>+</div><div>+  // Iterate over the reachable blocks in DFS order.</div><div>+  for (df_ext_iterator<MachineFunction*, SmallPtrSet<MachineBasicBlock*, 8> ></div><div>+       DFI = df_ext_begin(&Fn, Reachable), DFE = df_ext_end(&Fn, Reachable);</div><div>+       DFI != DFE; ++DFI) {</div><div>+    int SPAdj = 0;</div><div>+    // Check the exit state of the DFS stack predecessor.</div><div>+    if (DFI.getPathLength() >= 2) {</div><div>+      MachineBasicBlock *StackPred = DFI.getPath(DFI.getPathLength() - 2);</div><div>+      assert(Reachable.count(StackPred) &&</div><div>+             "DFS stack predecessor is already visited.\n");</div><div>+      SPAdj = SPState[StackPred->getNumber()];</div><div>+    }</div><div>+    MachineBasicBlock *BB = *DFI;</div><div>+    replaceFrameIndices(BB, Fn, SPAdj);</div><div>+    SPState[BB->getNumber()] = SPAdj;</div><div>+  }</div><div>+</div><div>+  // Handle the unreachable blocks.</div><div>   for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {</div><div>+    if (Reachable.count(BB))</div><div>+      // Already handled in DFS traversal.</div><div>+      continue;</div><div>     int SPAdj = 0;</div><div>     replaceFrameIndices(BB, Fn, SPAdj);</div><div>   }</div><div><br></div><div>Manman</div><div><br></div><div></div></div></div><span><spadj_pei.patch></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>-Jim</div><div><br><div><div>On Jul 11, 2013, at 9:15 PM, Manman Ren <<a href="mailto:mren@apple.com">mren@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><br class="Apple-interchange-newline">On Jul 11, 2013, at 6:40 PM, Jakob Stoklund Olesen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jul 11, 2013, at 12:07 PM, Manman Ren <<a href="mailto:mren@apple.com">mren@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">Modify MachineVerifier to make sure</span><br style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">1> on every path through the CFG, a FrameSetup <n> is always followed by a</span><br style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">  FrameDestroy <n> and a FrameDestroy is always followed by a FrameSetup.</span><br style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">2> stack adjustments are identical on all CFG edges to a merge point.</span><br style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></blockquote></div><br><div>One more thing: You need to verify that the frame is destroyed at the end of a return block.</div></div></blockquote>Good point, I can add this extra check.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Manman</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>/jakob</div></div></blockquote></div></blockquote></div><br></div></div></blockquote></div><br></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></div></body></html>