Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -fno-verbose-asm to clang #6462

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

verhovsky
Copy link
Contributor

@verhovsky verhovsky commented May 9, 2024

This removes useless comments (namely repeated function/label names, <n>-byte Folded Spill and others) from the generated assembly.

Fixes #5964

@verhovsky verhovsky changed the title Always add -fno-verbose-asm to clang Add -fno-verbose-asm to clang May 9, 2024
@partouf
Copy link
Contributor

partouf commented May 10, 2024

This is maybe an Ok change, but calling in @OfekShilon and @mattgodbolt

It might be appropriate to only hide these when comments are filtered out, but not sure

@OfekShilon
Copy link
Member

Great find! I wasn't aware of this switch. I looked in the llvm source and indeed it controls only comments, but I'm not sure all are useless. One random example (first in the list): https://github.com/llvm/llvm-project/blob/31774b6a8a88b435ce79f9ba048ef8bb00e2817e/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp#L96-L110

  bool VerboseAsm = Asm->OutStreamer->isVerboseAsm();

  int Entry = 0;
  // Emit the Catch TypeInfos.
  if (VerboseAsm && !TypeInfos.empty()) {
    Asm->OutStreamer->AddComment(">> Catch TypeInfos <<");
    Asm->OutStreamer->addBlankLine();
    Entry = TypeInfos.size();
  }

  for (const GlobalValue *GV : reverse(TypeInfos)) {
    if (VerboseAsm)
      Asm->OutStreamer->AddComment("TypeInfo " + Twine(Entry--));
    Asm->emitTTypeReference(GV, TTypeEncoding);
  }

Can certainly be useful to anyone debugging ARM exceptions.

So I'd say this switch would be activated only when the comments-filter is checked, but that might require a server roundtrip where (I think?) today it isn't required. Do you think that's doable?

@mattgodbolt
Copy link
Member

Yeah doing it when comments are filtered out? I dunno. We've had folks asking before for -fverbose-asm to be the default before now, #4130, #297, #1004

I think I'm ok to merge this, but

  • perhaps a more sane/unified approach to verbosity
  • there's an argument we've used before that "we do whatever the compiler does by default"

@OfekShilon
Copy link
Member

Suggestion: maybe add a checkbox specific to this switch, defaulting to checked? Like the fno-discard-value-names in llvm ir :
image

That one also triggers a re-compilation so I guess it's doable.

@mattgodbolt
Copy link
Member

That sounds like a winner, Ofek; and if we do it right fixes a number of those linked issues too!

@partouf
Copy link
Contributor

partouf commented May 12, 2024

Interestingly #4130, #297, #1004 are about GCC, and there it's off by default and if on - most comments are removed by comment filter

I don't know, I'm conflicted. The extra checkbox might be the only correct way to go.

@OfekShilon
Copy link
Member

Interestingly #4130, #297, #1004 are about GCC, and there it's off by default and if on - most comments are removed by comment filter

I don't know, I'm conflicted. The extra checkbox might be the only correct way to go.

Actually I take it back - after looking at the old issues I think it would be best to indeed link -fverbose-asm/-fno-verbose-asm to the existing 'comments' checkbox.
i.e.: if it's checked - add -fno-verbose-asm to the build switches (for supporting compilers) AND apply the regular comment-cleanup-logic. If it is unchecked - add -fverbose-asm to the build switches (for supporting compilers) and don't apply comment-cleanup-logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: armv8-a clang doesn't filter out function comment
4 participants