This is an archive of the discontinued LLVM Phabricator instance.

[X86][AMX] Support amxpreserve attribute in clang.
Needs ReviewPublic

Authored by LuoYuanke on Dec 6 2021, 4:16 PM.

Details

Summary
Introduce 'amxpreserve' attribute to reduce save/restore AMX register
in register allocation.
Use this attribute to indicate that the specified function has no
caller-saved AMX registers. Compiler doesn't save and restore any
AMX register across function call. It is user's responsibility that
ensure there is no AMX register clobber in the function with "amxpreserve"
attribute.

Like 'no_caller_saved_registers', 'amxpreserve' attribute is not a
calling convention. In fact, it only overrides the decision of which
AMX registers should be saved by the caller.

For example:

  .. code-block:: c

    __attribute__ ((amxpreserve ))
    void f () {
      ...
    }

    void bar () {
      ...
      f();
      ...
    }

In this case compiler doesn't save and restore AMX registers across the
call of f().

Diff Detail

Event Timeline

LuoYuanke created this revision.Dec 6 2021, 4:16 PM
LuoYuanke requested review of this revision.Dec 6 2021, 4:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2021, 4:16 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
LuoYuanke retitled this revision from [X86][AMX] Support amxpreserve attribute in clang. to [WIP][X86][AMX] Support amxpreserve attribute in clang..Dec 7 2021, 4:14 AM
aaron.ballman added inline comments.Dec 7 2021, 9:17 AM
clang/include/clang/Basic/Attr.td
2895

Inherited on what? This attribute needs a Subjects list, I suspect, or it needs to not be using a SimpleHandler.

2896

Does GCC support this attribute? Or MSVC? I don't see any evidence that either compiler supports this, so I think this should be one spelling: Clang.

2897

No new, undocumented attributes please.

clang/lib/Sema/SemaType.cpp
7518

Why are there type system changes for a declaration attribute?

LuoYuanke updated this revision to Diff 393012.Dec 8 2021, 7:11 PM

Updating D115199: [WIP][X86][AMX] Support amxpreserve attribute in clang.

LuoYuanke retitled this revision from [WIP][X86][AMX] Support amxpreserve attribute in clang. to [X86][AMX] Support amxpreserve attribute in clang..Dec 8 2021, 7:42 PM
LuoYuanke edited the summary of this revision. (Show Details)
LuoYuanke edited the summary of this revision. (Show Details)
LuoYuanke added a reviewer: andrew.w.kaylor.
LuoYuanke marked 2 inline comments as done.Dec 8 2021, 10:45 PM

I'm worried about the extra overhead imposed on all users by this change. This appears to be adding another calling convention to Clang (despite the claim that it's not); can you share a motivation for why everyone should pay the price for adding it?

clang/include/clang/AST/Type.h
1588

This is problematic because it increases the cost of forming a type.

1826

(From comment above) this means that every type is now more expensive to create and that has cascading effects on things like template instantiation depth and memory pressures for all users, including people not using this feature.

martong removed a subscriber: martong.Jan 7 2022, 6:37 AM