Skip to content

When using AArch64 instructions without their feature enabled, clang error is misleading for MTE and SPE #151473

@DavidSpickett

Description

@DavidSpickett

Compiler explorer:
SPE
MTE

When compiling an SPE instruction without SPE enabled via. -march:

void fn() {
    asm volatile ("psb csync");
}
$ ./bin/clang -target aarch64-linux-gnu -march=armv9.6-a /tmp/test.c -o /tmp/test.o -c
/tmp/test.c:2:19: error: instruction requires: spe
    2 |     asm volatile ("psb csync");
      |                   ^
<inline asm>:1:2: note: instantiated into assembly here
    1 |         psb csync
      |         ^
1 error generated

Except that spe is the name llvm-mc uses, clang wants profile:

$ ./bin/clang -target aarch64-linux-gnu -march=armv9.6-a+profile /tmp/test.c -o /tmp/test.o -c

Same thing happens with MTE:

void fn() {
    asm volatile ("ldg x8, [x8]");
}

This tells you it requires mte but the clang option is actually memtag.

I know that mte vs. memtag is a historical artifact where different compilers implemented it at different times and clang ended up changing to match gcc, but not in the backend.

SPE could be the same story, or it could be that spe is bundled with other features, into profile.

Either way, the error message is useful when the name is correct, so it's a shame it is not for these ones. It comes straight from llvm-mc, so I see why it is using the -mattr names at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:AArch64clangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions