<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">r188755.<div><br></div><div>Thanks again for the review!</div><div><br></div><div>Michael</div><div><br></div><div><div><div>On Aug 17, 2013, at 10:31 PM, Owen Anderson <<a href="mailto:owen@apple.com">owen@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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>This looks good to me.  I really appreciate the level of self-documentation you've put into it!</div><div><br></div><div>--Owen</div><br><div><div>On Aug 16, 2013, at 1:53 PM, Michael Gottesman <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>> 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;">Hey Owen!<div><br></div><div>I don't think Jakob is going to have time to review this (just spoke with him). Could you take a look at this?</div><div><br></div><div>Michael</div><div><br><div></div></div></div><span><0001-stackprotector-Teach-selectiondag-how-to-handle-the-.patch></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div></div><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><b>From:<span class="Apple-converted-space"> </span></b></span><span style="font-family: Helvetica; font-size: 12px;">Michael Gottesman <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>><br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><b>Subject:<span class="Apple-converted-space"> </span></b></span><span style="font-family: Helvetica; font-size: 12px;"><b>Re: [PATCH] SelectionDAG Stack Protector Insertion</b><br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><b>Date:<span class="Apple-converted-space"> </span></b></span><span style="font-family: Helvetica; font-size: 12px;">August 14, 2013 9:49:40 PM PDT<br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><b>To:<span class="Apple-converted-space"> </span></b></span><span style="font-family: Helvetica; font-size: 12px;">Jakob Stoklund Olesen <<a href="mailto:jolesen@apple.com">jolesen@apple.com</a>><br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica; font-size: 12px;"><b>Cc:<span class="Apple-converted-space"> </span></b></span><span style="font-family: Helvetica; font-size: 12px;">Commit Messages and Patches for LLVM <<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a>><br></span></div><br><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Updated patch.<div><br></div><div></div></div><br><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div></div><div><br><div><div>On Aug 13, 2013, at 5:28 PM, Michael Gottesman <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="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;">Hey Jakob!<br><br>Attached is a patch which uses the new stack protector check intrinsic to insert a stack protector check in FinishBasicBlock after we have already decided on whether or not to tail call call sites. This prevents the stack protector basic block expansion from disrupting sibling tail calls.<br><br>A global outline of the flow of the patch is:<br><br>1. I introduce a new StackProtectorDescriptor object following the example of the BitTest/Switch code introducing the CaseBlock/BitTestBlock structure. To satisfy my paranoia I made it a class so I could hide some implementations details related to initialization. The descriptor contains per-BB data which we clear for every BB we process (the success/parent machine basic block) and per-Function data that we clear as we process each function (the failure machine basic block). We do this so we can reuse the failure basic block for each return statement in the function.<br><br>2. When we visit the stack protector check intrinsic, we do not attach any actual code to the DAG. Instead we initialize the stack protector descriptor with the information we need to emit the loads/comparisons/new basic blocks, export our one operand from the basic block, and then call getControlRoot() to ensure that our exports are flushed properly. Calling getControlRoot() is necessary since we are going to process the return statement of the basic block which will eliminate the export (from what I understand).<br><br>3. In FinishBasicBlock (again following the lead of how we handle BitTests/Switches), if we initialized our stack protector with per-BB state while we were processing the actual basic block, we:<br><span class="Apple-tab-span" style="white-space: pre;">   </span>a. Find the split point right before the first terminator of the parent basic block.<br><span class="Apple-tab-span" style="white-space: pre;">    </span>b. While doing that we copy any physical registers referenced in the terminators of the parent basic block into temporary registers before the split point and back into the correct physical registers after the split point. This allows us to not have to deal with live-ins and let the register allocator do what it does best = ).<br><span class="Apple-tab-span" style="white-space: pre;">        </span>c. We splice all of the parent basic block from the split point to the end of the function into the success basic block.<br><span class="Apple-tab-span" style="white-space: pre;">        </span>d. We then code-gen a new end to the parent basic block which performs the stack protector check and branches to either the success or failure basic block.<br><span class="Apple-tab-span" style="white-space: pre;">     </span>e. Then if the failure MBB has not been code-gened yet, we code-gen it. The failure basic block just calls __stack_chk_fail via makeLibCall. *NOTE* We only do this once since all return statements branch to the same fail BB.<br><span class="Apple-tab-span" style="white-space: pre;">        </span>f. We clear any per-BB state from the stack protector descriptor (which consists of the parent/success basic blocks) and leave the fail basic block state around so we can reuse it.<br><br>4. When we finish a specific function, we clear the function specific state as well from the stack protector descriptor (which is just the failure basic block).<br><br>Please Review,<br>Michael<br><br><span><0001-stackprotector-Teach-selectiondag-how-to-handle-the-.patch></span><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></blockquote></div></div></blockquote></div></div></blockquote></div><br></div></body></html>