<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 1, 2014, at 4:29 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 1, 2014 at 3:44 PM, Bob Wilson <span dir="ltr" class=""><<a href="mailto:bob.wilson@apple.com" target="_blank" class="">bob.wilson@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bwilson<br class="">
Date: Wed Oct  1 17:44:01 2014<br class="">
New Revision: 218838<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218838&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=218838&view=rev</a><br class="">
Log:<br class="">
PR21101: tablegen's FastISel emitter should filter out unused functions.<br class="">
<br class="">
FastISel has a fixed set of virtual functions that are overridden by the<br class="">
tablegen-generated code for each target. These functions are distinguished by<br class="">
the kinds of operands, e.g., register + immediate = "ri". The FastISel emitter<br class="">
has been blindly emitting functions with different combinations of operand<br class="">
kinds, even for combinations that are completely unused by FastISel, e.g.,<br class="">
"fastEmit_rrr". Change to filter out functions that will be irrelevant for<br class="">
FastISel and do not bother generating the code for them. Also add explicit<br class="">
"override" keywords for the virtual functions that are overridden.<br class=""></blockquote><div class=""><br class=""></div><div class="">We do seem to have some tests for TableGen under llvm/test/TableGen - is this testable?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div>It’s removing dead code, so I do not see any value in testing that.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class="">Any data on savings gained by omitting these unused functions?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div>On OS X, the linker will strip dead code so I’m assuming that the end result is no change. YMMV on other platforms.<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="">
Modified:<br class="">
    llvm/trunk/utils/TableGen/FastISelEmitter.cpp<br class="">
<br class="">
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=218838&r1=218837&r2=218838&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=218838&r1=218837&r2=218838&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)<br class="">
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Wed Oct  1 17:44:01 2014<br class="">
@@ -19,6 +19,7 @@<br class="">
<br class="">
 #include "CodeGenDAGPatterns.h"<br class="">
 #include "llvm/ADT/SmallString.h"<br class="">
+#include "llvm/ADT/StringSwitch.h"<br class="">
 #include "llvm/Support/Debug.h"<br class="">
 #include "llvm/Support/ErrorHandling.h"<br class="">
 #include "llvm/TableGen/Error.h"<br class="">
@@ -541,6 +542,17 @@ void FastISelMap::collectPatterns(CodeGe<br class="">
         continue;<br class="">
     }<br class="">
<br class="">
+    // Check if the operands match one of the patterns handled by FastISel.<br class="">
+    std::string ManglingSuffix;<br class="">
+    raw_string_ostream SuffixOS(ManglingSuffix);<br class="">
+    Operands.PrintManglingSuffix(SuffixOS, ImmediatePredicates, true);<br class="">
+    SuffixOS.flush();<br class="">
+    if (!StringSwitch<bool>(ManglingSuffix)<br class="">
+        .Cases("", "r", "rr", "ri", "rf", true)<br class="">
+        .Cases("rri", "i", "f", true)<br class="">
+        .Default(false))<br class="">
+      continue;<br class="">
+<br class="">
     // Get the predicate that guards this pattern.<br class="">
     std::string PredicateCheck = Pattern.getPredicateCheck();<br class="">
<br class="">
@@ -803,7 +815,10 @@ void FastISelMap::printFunctionDefinitio<br class="">
     if (!Operands.empty())<br class="">
       OS << ", ";<br class="">
     Operands.PrintParameters(OS);<br class="">
-    OS << ") {\n";<br class="">
+    OS << ") ";<br class="">
+    if (!Operands.hasAnyImmediateCodes())<br class="">
+      OS << "override ";<br class="">
+    OS << "{\n";<br class="">
<br class="">
     // If there are any forms of this signature available that operate on<br class="">
     // constrained forms of the immediate (e.g., 32-bit sext immediate in a<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>