[PATCH] D32491: [globalisel][tablegen] Compute available feature bits correctly.

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 02:40:09 PDT 2017


rovka added a comment.

So, we have a new GISelAccessor with a new InstructionSelector for each unique subtarget (module + function attributes, as hashed in getSubtargetImpl). Why do we need to have module features and function features in each InstructionSelector? Isn't there a different InstructionSelector for each kind of function, and don't we magically get the right one when processing each function? What am I missing? It seems to me that we could get away with a single set of availableFeatures per InstructionSelector.

In any case, I think you need a more complex test with several different functions with different attributes to make sure you're computing the correct features for each function and you don't have any stale info lingering between them (something like what I do with function attributes in arm-instruction-select.mir, although that's just for convenience and not for this exact purpose).



================
Comment at: include/llvm/Target/Target.td:538
+  /// Ignored by SelectionDAG, it always recomputes the predicate on every use.
+  bit RecomputePerFunction = 0;
 }
----------------
This looks very easy to forget to set when adding a new predicate. Would it make sense to have 2 subclasses of Predicate (ModulePredicate and FunctionPredicate) and define all the predicates based on them? Naturally, it would be a pretty big mechanical change to update all the targets, so it should be a separate patch, but I think it would make things easier to maintain in the long run. What do you think?


================
Comment at: lib/Target/AArch64/AArch64InstructionSelector.cpp:53
+                             const AArch64RegisterBankInfo &RBI,
+                             bool ForCodeSize);
 
----------------
This doesn't look like it would scale very well if we needed to add more function-level predicates. Is there any significant disadvantage to threading the MachineFunction all the way down here? Then we'd only have to update the constructor, without createXInstructionSelector etc.


================
Comment at: lib/Target/AArch64/AArch64TargetMachine.cpp:266
                        : TargetFS;
+  std::string ForCodeSizeStr = ForCodeSize ? "-forcodesize" : "";
 
----------------
Nit: I guess it doesn't matter much, since this is only used for hashing, but it would be nice to keep the convention used for the target features etc (",+forcodesize").


https://reviews.llvm.org/D32491





More information about the llvm-commits mailing list