<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Nov 13, 2013, at 4:09 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com">Paul_Robinson@playstation.sony.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite">I am energized by positive discussions of the 'optnone' attribute<br>during the dev meeting last week, so here we go.<br><br>Some time ago Andrea Di Biagio committed a patch to define an 'optnone'<br>attribute in the LLVM IR; he has since passed the torch to me on this<br>one, so I'm attaching 3 patches to implement the semantics we want.<br><br>While the patches all address semantics of 'optnone' I should point<br>out that (I'm pretty sure) they are independent of each other and<br>don't have to be reviewed sequentially, or anything like that.<br><br>Patch #3 deals with the codegen stuff.  Basically, an 'optnone'<br>function will be treated as if it were compiled at -O0; this is a<br>little easier to accomplish than it is for IR-level passes.<br><br></blockquote></div><div>You changes in Patch #3 won’t work. You’re changing the TargetOptions settings, but that violates what the back-end is expecting. For instance, the UnsafeFPMath is used during the creation of the back-end to register which actions to perform for which operations. E.g., in X86ISelLowering.cpp <span style="color: rgb(113, 194, 193);">X86TargetLowering</span>::<span style="color: rgb(94, 52, 255);">resetOperationActions()</span>:</div><div><br></div><div><div style="margin: 0px;">    <span style="color: #d03cff">if</span> (!TM.Options.<span style="background-color: #affeff">UnsafeFPMath</span>) {</div><div style="margin: 0px;">      setOperationAction(<span style="color: #71c2c1">ISD</span>::FSIN   , <span style="color: #71c2c1">MVT</span>::f64, Expand);</div><div style="margin: 0px;">      setOperationAction(<span style="color: #71c2c1">ISD</span>::FCOS   , <span style="color: #71c2c1">MVT</span>::f64, Expand);</div><div style="margin: 0px;">      setOperationAction(<span style="color: #71c2c1">ISD</span>::FSINCOS, <span style="color: #71c2c1">MVT</span>::f64, Expand);</div><div style="margin: 0px;">    }</div><div><br></div><div>Is it possible to do FastISel only as an initial stage?</div><div><br></div><div>Also, use early exits whenever possible. E.g., this</div><div><br></div><div><div>+    ~OptLevelChanger() {</div><div>+      if (IS.OptLevel != SavedOptLevel) {</div><div>+        DEBUG(dbgs() << "\nRestoring optimization level for Function "</div><div>+              << IS.MF->getFunction()->getName() << "\n");</div><div>+        DEBUG(dbgs() << "\tBefore: -O" << IS.OptLevel</div><div>+              << " ; After: -O" << SavedOptLevel << "\n");</div><div>+        IS.OptLevel = SavedOptLevel;</div><div>+        IS.TM.setOptLevel(SavedOptLevel);</div><div>+      }</div><div>+    }</div></div><div><br></div><div>could be this:</div><div><br></div><div><div>+    ~OptLevelChanger() {</div><div>+      if (IS.OptLevel == SavedOptLevel)</div><div>+        return</div><div>+      DEBUG(dbgs() << "\nRestoring optimization level for Function "</div><div>+            << IS.MF->getFunction()->getName() << "\n");</div><div>+      DEBUG(dbgs() << "\tBefore: -O" << IS.OptLevel</div><div>+            << " ; After: -O" << SavedOptLevel << "\n");</div><div>+      IS.OptLevel = SavedOptLevel;</div><div>+      IS.TM.setOptLevel(SavedOptLevel);</div><div>+    }</div></div><div><br></div></div><div>-bw</div><div><br></div></body></html>