This is an archive of the discontinued LLVM Phabricator instance.

[llvm-mc] Add -M to replace -riscv-no-aliases and -riscv-arch-reg-names
ClosedPublic

Authored by MaskRay on May 23 2021, 10:27 PM.

Details

Summary

In objdump, many targets support -M no-aliases. Instead of having a
-*-no-aliases for each target when LLVM adds the support, it makes more sense
to introduce objdump style -M.

-riscv-arch-reg-names is removed. -riscv-no-aliases has too many uses and thus is retained for now.

Diff Detail

Event Timeline

MaskRay created this revision.May 23 2021, 10:27 PM
MaskRay requested review of this revision.May 23 2021, 10:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2021, 10:27 PM
MaskRay edited the summary of this revision. (Show Details)May 23 2021, 10:28 PM
MaskRay updated this revision to Diff 347310.May 23 2021, 10:30 PM

add a TODO

llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
44

Will do s/can /can be / in the next diff.

If we are just keeping -riscv-no-aliases to avoid changing many tests it might be better to just remove it now. Otherwise it will likely stay forever. Maybe it is used externally though, I don't know.

llvm/include/llvm/MC/MCInstPrinter.h
58

It would be better if we could avoid ending up with two variables that mean essentially the same thing. I prefer the name NoAliases because it matches both command line flags better, and doesn't have the logical inversion that PrintAliases does. Can they both be made to use the same storage with cl::location?

jrtc27 added a subscriber: craig.topper.EditedMay 25 2021, 7:38 AM

I think a mass replacement of -(-)riscv-no-aliases is fine. I don't know why so many RVV CodeGen tests use it to be honest, it seems entirely unnecessary. @craig.topper / @frasercrmck is there a reason why the RVV CodeGen tests use --riscv-no-aliases everywhere? As far as I can tell there's nothing interesting hidden by aliases if I remove the option from all the RVV tests and regenerate them:

waltham:llvm-project-upstream jrtc4% git diff | grep '^[-+]; CHECK' | sort | uniq -c
  24844 -; CHECK-NEXT:    jalr zero, 0(ra)
  24844 +; CHECK-NEXT:    ret
      8 -; CHECK-NEXT:    vl4re8.v v28, (a0)
      8 +; CHECK-NEXT:    vl4r.v v28, (a0)
     64 -; CHECK-NEXT:    vl8re8.v v24, (a0)
     64 +; CHECK-NEXT:    vl8r.v v24, (a0)

So, can we just delete them all?

I've never understood why they're there either so I'm not best-qualified to say. I've never used it when adding my own tests. As @tmatheson said, maybe it's used externally?

I've never understood why they're there either so I'm not best-qualified to say. I've never used it when adding my own tests. As @tmatheson said, maybe it's used externally?

I'm also not sure why the rvv tests use no-aliases. I think the majority were generated by a tool developed before I get here. I'll ask around internally.

MaskRay marked an inline comment as done.May 25 2021, 11:34 AM
MaskRay added inline comments.
llvm/include/llvm/MC/MCInstPrinter.h
58

No. RISCV is at odds here. I will use this for aarch64 as well: D103005.

The cl::opt global variable is inelegant and should be avoided. Say we want to have MCInstPrinter, now due to the singleton nature of a cl::opt variable, we cannot really make their PrintAliases states different.

Regarding the name, The positively named PrintAliases avoid negation, instead of the other way around.
If we add something -M aliases then it should become clearer NoAliases is not a good name.

jrtc27 added a comment.EditedMay 25 2021, 11:55 AM

I've never understood why they're there either so I'm not best-qualified to say. I've never used it when adding my own tests. As @tmatheson said, maybe it's used externally?

I'm also not sure why the rvv tests use no-aliases. I think the majority were generated by a tool developed before I get here. I'll ask around internally.

If you conclude they can go, I have the patch ready to push. I could put it in Phab, but I doubt anyone wants to read the 25309 changed lines; the full summary of all the changes is very boring:

waltham:llvm-project-upstream jrtc4% git diff | grep '^[-+][^-+]' | sort | uniq -c
  24844 -; CHECK-NEXT:    jalr zero, 0(ra)
  24844 +; CHECK-NEXT:    ret
      8 -; CHECK-NEXT:    vl4re8.v v28, (a0)
      8 +; CHECK-NEXT:    vl4r.v v28, (a0)
     64 -; CHECK-NEXT:    vl8re8.v v24, (a0)
     64 +; CHECK-NEXT:    vl8r.v v24, (a0)
    392 -; RUN:   --riscv-no-aliases < %s | FileCheck %s
    392 +; RUN:   < %s | FileCheck %s
      1 -; RUN:   -verify-machineinstrs --riscv-no-aliases < %s \
      1 +; RUN:   -verify-machineinstrs < %s \

So, can we just delete them all?

I think so in the RVV tests, but not everywhere. Not aliasing may have a place in assembler tests, for instance, but not only in these.

So, can we just delete them all?

I think so in the RVV tests, but not everywhere. Not aliasing may have a place in assembler tests, for instance, but not only in these.

Yes, I'm only talking about llvm/test/CodeGen/RISCV/rvv/*.ll (and llvm/test/CodeGen/RISCV/spill-fpr-scalar.ll which should probably be under rvv/). All the MC tests, and the special llvm/test/CodeGen/RISCV/patchable-function-entry.ll test, are excluded.

MaskRay marked an inline comment as done.May 25 2021, 12:33 PM

I'm also not sure why the rvv tests use no-aliases. I think the majority were generated by a tool developed before I get here. I'll ask around internally.

I believe that they were lifted from existing tests by default. When looking for specific instructions, having the actual instruction makes it clearer what the test expects. But this option is probably redundant in tests that don't check for instructions.

Does this patch look good?

luismarques accepted this revision.May 26 2021, 8:55 AM

I'm not very happy that we now have to consistently check two variables (error-prone, etc.), but I suppose that's OK if we are going to remove -riscv-no-aliases soon.
Other than that, the patch LGTM.

This revision is now accepted and ready to land.May 26 2021, 8:55 AM

I've never understood why they're there either so I'm not best-qualified to say. I've never used it when adding my own tests. As @tmatheson said, maybe it's used externally?

I'm also not sure why the rvv tests use no-aliases. I think the majority were generated by a tool developed before I get here. I'll ask around internally.

If you conclude they can go, I have the patch ready to push. I could put it in Phab, but I doubt anyone wants to read the 25309 changed lines; the full summary of all the changes is very boring:

waltham:llvm-project-upstream jrtc4% git diff | grep '^[-+][^-+]' | sort | uniq -c
  24844 -; CHECK-NEXT:    jalr zero, 0(ra)
  24844 +; CHECK-NEXT:    ret
      8 -; CHECK-NEXT:    vl4re8.v v28, (a0)
      8 +; CHECK-NEXT:    vl4r.v v28, (a0)
     64 -; CHECK-NEXT:    vl8re8.v v24, (a0)
     64 +; CHECK-NEXT:    vl8r.v v24, (a0)
    392 -; RUN:   --riscv-no-aliases < %s | FileCheck %s
    392 +; RUN:   < %s | FileCheck %s
      1 -; RUN:   -verify-machineinstrs --riscv-no-aliases < %s \
      1 +; RUN:   -verify-machineinstrs < %s \

They can go.

I've never understood why they're there either so I'm not best-qualified to say. I've never used it when adding my own tests. As @tmatheson said, maybe it's used externally?

I'm also not sure why the rvv tests use no-aliases. I think the majority were generated by a tool developed before I get here. I'll ask around internally.

If you conclude they can go, I have the patch ready to push. I could put it in Phab, but I doubt anyone wants to read the 25309 changed lines; the full summary of all the changes is very boring:

waltham:llvm-project-upstream jrtc4% git diff | grep '^[-+][^-+]' | sort | uniq -c
  24844 -; CHECK-NEXT:    jalr zero, 0(ra)
  24844 +; CHECK-NEXT:    ret
      8 -; CHECK-NEXT:    vl4re8.v v28, (a0)
      8 +; CHECK-NEXT:    vl4r.v v28, (a0)
     64 -; CHECK-NEXT:    vl8re8.v v24, (a0)
     64 +; CHECK-NEXT:    vl8r.v v24, (a0)
    392 -; RUN:   --riscv-no-aliases < %s | FileCheck %s
    392 +; RUN:   < %s | FileCheck %s
      1 -; RUN:   -verify-machineinstrs --riscv-no-aliases < %s \
      1 +; RUN:   -verify-machineinstrs < %s \

They can go.

Done :) https://reviews.llvm.org/rGd63d662d3cc51219fb08908ebea8d5851e53adb8