[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 07:58:11 PDT 2017


rovka added a comment.

Thanks for all the explanations!
LGTM with that extra test, we can keep discussing the remaining points but I think it's ok to iterate in-tree. I'd really, really like to see the default change from 0 to 1 on RecomputePerFunction, it seems safer that way.



================
Comment at: include/llvm/Target/Target.td:538
+  /// Ignored by SelectionDAG, it always recomputes the predicate on every use.
+  bit RecomputePerFunction = 0;
 }
----------------
dsanders wrote:
> rovka wrote:
> > 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?
> If your predicate references MF you'll get a compile error since MF isn't declared in computeAvailableModuleFeatures. Things implemented via class members (e.g. ForCodeSize but that one is ok because of the cache) will silently do the wrong thing. Even without that, I think renaming to ModulePredicate/FunctionPredicate would be a good change to make since it's clearer.
> 
> If we're going to rename Predicate, we should probably take the opportunity to add ISel/CG/CodeGen or similar to the name too.
> 
> One thing that's a bit weird here is that predicates using ForCodeSize and similar would be ModulePredicate's because of the cache in getSubtargetImpl() even though they're logically per-function predicates.
Hmm, actually, in light of your more detailed explanations, I'm not so sure Module vs Function is the right abstraction here. The matter of whether or not a predicate is safe to cache doesn't seem to correlate as well as I was hoping with whether or not it's a function predicate. Maybe we should have something like CacheablePredicate (or StablePredicate? or ConstantPredicate?), and use that everywhere except where it's not safe to cache? That would force people to either decide that something is safe to cache or fall back to the slow-but-correct path of recomputing it every time.

Also, +1 for finding a better name for these predicates in general, I hate having to explain to people that this isn't about flag registers and condition codes every time :)


================
Comment at: lib/Target/AArch64/AArch64InstructionSelector.cpp:53
+                             const AArch64RegisterBankInfo &RBI,
+                             bool ForCodeSize);
 
----------------
dsanders wrote:
> rovka wrote:
> > 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.
> The caller doesn't have access to MachineFunction so I assume you meant Function. I'm not sure about threading that down since it moves the predicate testing away from the cache key generator. It would be easy to add a predicate in the instruction selector and forget to update the key generator. I agree we need to do something here though. I'll have a think about it.
That's a good point.


================
Comment at: lib/Target/AArch64/AArch64TargetMachine.cpp:266
                        : TargetFS;
+  std::string ForCodeSizeStr = ForCodeSize ? "-forcodesize" : "";
 
----------------
dsanders wrote:
> rovka wrote:
> > 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").
> Ok. And presumably we'd have "-forcodesize" instead of "" if we're matching that convention.
Yup.


https://reviews.llvm.org/D32491





More information about the llvm-commits mailing list