This is an archive of the discontinued LLVM Phabricator instance.

[LLVM][AArch64] Explain that X19 is used as the frame base pointer register
ClosedPublic

Authored by DavidSpickett on Sep 2 2022, 8:55 AM.

Details

Summary

Fixes #50098

LLVM uses X19 as the frame base pointer, if it needs to. Meaning you
can get warnings if you clobber that with inline asm.

However, it doesn't explain why. The frame base register is not part
of the ABI so it's pretty confusing why you get that warning out of the blue.

This adds a method to explain a reserved register with X19 as the first one.
The logic is the same as getReservedRegs.

I could have added a return parameter to isASMClobberable and friends
but found that there's a lot of things that call isReservedReg in various
ways.

So while one more method on the pile isn't great design, it is simpler
right now to do it this way and only pay the cost if you are actually using
a reserved register.

Diff Detail

Event Timeline

DavidSpickett created this revision.Sep 2 2022, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2022, 8:55 AM
DavidSpickett requested review of this revision.Sep 2 2022, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2022, 8:55 AM

Obviously it would be cool to add the other reserved registers e.g. straight line speculation but let's see if I have the API right first.

If reserved regs were a static map I'd just make it a map of register string pair. However, it can change per function so I decided to go with a separate call you can make if you want/are able to print the reason.

HsiangKai added inline comments.
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
315

"X16" => "X19"

llvm/test/CodeGen/AArch64/inline-asm-clobber-base-frame-pointer.ll
5

"X16" => "X19"

tschuett added inline comments.
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
529

You could use an Optional<std::string> instead. It will be seldom used.

llvm/test/CodeGen/AArch64/inline-asm-clobber-base-frame-pointer.ll
16

line break

DavidSpickett added inline comments.Sep 5 2022, 1:55 AM
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
529

Well in some sense char* is optional string as long as that "string" is constant, and for this specific case I didn't need to format a string so std::string wasn't needed.

That said, you're right this is seldom used so pointer plus bool isn't a concern space wise. In addition, if I add further explanations they *will* need to format a new string e.g. when you try to clobber an SME tile.

So I will do this thanks for the suggestion.

llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
315

Doh, yeah I don't know why I keep mistyping it as 16.

  • Return optional<string>
  • Cleanup IR test
  • Correct X16 -> X19
DavidSpickett marked 4 inline comments as done.Sep 5 2022, 2:38 AM

@lenary ping! Any thoughts?

lenary accepted this revision.Sep 10 2022, 2:12 AM

LGTM. This seems the simplest and cleanest way to add this information, and fuller error messages are better!

This revision is now accepted and ready to land.Sep 10 2022, 2:12 AM