[llvm] r218838 - PR21101: tablegen's FastISel emitter should filter out unused functions.
Eric Christopher
echristo at gmail.com
Wed Oct 1 17:29:46 PDT 2014
On Wed, Oct 1, 2014 at 5:12 PM, Bob Wilson <bob.wilson at apple.com> wrote:
>
> On Oct 1, 2014, at 4:29 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Wed, Oct 1, 2014 at 3:44 PM, Bob Wilson <bob.wilson at apple.com> wrote:
>>
>> Author: bwilson
>> Date: Wed Oct 1 17:44:01 2014
>> New Revision: 218838
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=218838&view=rev
>> Log:
>> PR21101: tablegen's FastISel emitter should filter out unused functions.
>>
>> FastISel has a fixed set of virtual functions that are overridden by the
>> tablegen-generated code for each target. These functions are distinguished
>> by
>> the kinds of operands, e.g., register + immediate = "ri". The FastISel
>> emitter
>> has been blindly emitting functions with different combinations of operand
>> kinds, even for combinations that are completely unused by FastISel, e.g.,
>> "fastEmit_rrr". Change to filter out functions that will be irrelevant for
>> FastISel and do not bother generating the code for them. Also add explicit
>> "override" keywords for the virtual functions that are overridden.
>
>
> We do seem to have some tests for TableGen under llvm/test/TableGen - is
> this testable?
>
>
> It’s removing dead code, so I do not see any value in testing that.
>
>
> Any data on savings gained by omitting these unused functions?
>
>
> On OS X, the linker will strip dead code so I’m assuming that the end result
> is no change. YMMV on other platforms.
As a note you could check by using -Wl,-no_dead_strip on a mac :)
-eric
>
>
>>
>>
>> Modified:
>> llvm/trunk/utils/TableGen/FastISelEmitter.cpp
>>
>> Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=218838&r1=218837&r2=218838&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
>> +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Wed Oct 1 17:44:01 2014
>> @@ -19,6 +19,7 @@
>>
>> #include "CodeGenDAGPatterns.h"
>> #include "llvm/ADT/SmallString.h"
>> +#include "llvm/ADT/StringSwitch.h"
>> #include "llvm/Support/Debug.h"
>> #include "llvm/Support/ErrorHandling.h"
>> #include "llvm/TableGen/Error.h"
>> @@ -541,6 +542,17 @@ void FastISelMap::collectPatterns(CodeGe
>> continue;
>> }
>>
>> + // Check if the operands match one of the patterns handled by
>> FastISel.
>> + std::string ManglingSuffix;
>> + raw_string_ostream SuffixOS(ManglingSuffix);
>> + Operands.PrintManglingSuffix(SuffixOS, ImmediatePredicates, true);
>> + SuffixOS.flush();
>> + if (!StringSwitch<bool>(ManglingSuffix)
>> + .Cases("", "r", "rr", "ri", "rf", true)
>> + .Cases("rri", "i", "f", true)
>> + .Default(false))
>> + continue;
>> +
>> // Get the predicate that guards this pattern.
>> std::string PredicateCheck = Pattern.getPredicateCheck();
>>
>> @@ -803,7 +815,10 @@ void FastISelMap::printFunctionDefinitio
>> if (!Operands.empty())
>> OS << ", ";
>> Operands.PrintParameters(OS);
>> - OS << ") {\n";
>> + OS << ") ";
>> + if (!Operands.hasAnyImmediateCodes())
>> + OS << "override ";
>> + OS << "{\n";
>>
>> // If there are any forms of this signature available that operate on
>> // constrained forms of the immediate (e.g., 32-bit sext immediate in
>> a
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list