<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 18 May 2015 at 11:07, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: sanjoy<br>
Date: Mon May 18 13:07:00 2015<br>
New Revision: 237593<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D237593-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=EZRvoJai0V1ZEULFLl3UFBFw3GpoHtruFDOok84hYrI&s=4QqYr7GqSrZjVxTSY4zWHbjeCHYmt-2bkaDpOtpbsM8&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=237593&view=rev</a><br>
Log:<br>
Exploit dereferenceable_or_null attribute in LICM pass<br>
<br>
Summary:<br>
Allow hoisting of loads from values marked with dereferenceable_or_null<br>
attribute. For values marked with the attribute perform<br>
context-sensitive analysis to determine whether it's known-non-null or<br>
not.<br></blockquote><div><br></div><div>This commit caused PR23608, see the testcase in that PR.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">-/// Only sink or hoist an instruction if it is not a trapping instruction<br>
+/// Only sink or hoist an instruction if it is not a trapping instruction,<br>
+/// or if the instruction is known not to trap when moved to the preheader.<br>
 /// or if it is a trapping instruction and is guaranteed to execute.<br>
-///<br>
-static bool isSafeToExecuteUnconditionally(const Instruction &Inst,<br>
+static bool isSafeToExecuteUnconditionally(const Instruction &Inst,<br>
                                            const DominatorTree *DT,<br>
+                                           const TargetLibraryInfo *TLI,<br>
                                            const Loop *CurLoop,<br>
                                            const LICMSafetyInfo *SafetyInfo) {<br>
-  // If it is not a trapping instruction, it is always safe to hoist.<br>
-  if (isSafeToSpeculativelyExecute(&Inst))<br>
+  const Instruction *CtxI = CurLoop->getLoopPreheader()->getTerminator();<br></blockquote><div><br></div><div>A Loop* is not guaranteed to have a preheader, in which case CurLoop->getLoopPreheader() will return null.</div><div><br></div><div>Nick</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+  if (isSafeToSpeculativelyExecute(&Inst, CtxI, DT, TLI))<br>
     return true;<br>
<br>
   return isGuaranteedToExecute(Inst, DT, CurLoop, SafetyInfo);<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
</blockquote></div></div></div>