This is an archive of the discontinued LLVM Phabricator instance.

[PoC][RISCV] Define a symbol flags and a dynamic tag to avoid lazy binding for vector calls.
Needs ReviewPublic

Authored by HsiangKai on May 31 2021, 11:08 PM.

Details

Summary

This is the primitive work for https://github.com/riscv/riscv-elf-psabi-doc/pull/190.

Functions with vector arguments will use vector registers to pass
arguments, In the dynamic linker resolver, we plan not to save/restore
the vector argument registers for lazy binding efficiency. To avoid
ruining the vector arguments by the dynamic linker resolver, functions
with vector arguments will not go through the resolver.

To achieve the goal, we will annotate the function symbols with
STO_RISCV_VARIANT_CC flag and add DT_RISCV_VARIANT_CC tag in the dynamic
section. For assembler, we add a new directive, .variant_cc, to annotate
the symbol has special calling convention and does not go through the
resolver.

Diff Detail

Event Timeline

HsiangKai created this revision.May 31 2021, 11:08 PM
HsiangKai requested review of this revision.May 31 2021, 11:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 31 2021, 11:08 PM
craig.topper added inline comments.Jun 1 2021, 12:43 PM
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
156

Put with the other emitDirective* methods?

llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
42

Maybe put this with the other emitDirective* declarations?

llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
205

Use a reference liek the two functions right above this for consistency.

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
358 ↗(On Diff #348885)

This is incorrect if the element size of the vector is larger than i64. Not sure how much that matters in practice since it would be pretty unusual to have such a vector argument/return.

I was really hoping to find a way to get this from Machine IR directly. MachineRegisterInfo does have a list of livein physical registers, but I can't find anywhere that knows what physical registers are used for returns

Could you please split this patch into a patch that adds the new enum values, which would include the llvm-readobj and yaml2obj/obj2yaml changes, and then another patch (or patches) with the rest in? The latter builds on the former, but the former doesn't need the latter to work.

llvm/tools/llvm-readobj/ELFDumper.cpp
1605

Nit: clang-format

jrtc27 added inline comments.Jun 7 2021, 5:02 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
3776

So if STO_RISCV_VARIANT_CC isn't set but another bit is we now don't print anything? This looks like a bug in the AArch64 code you've copied?

HsiangKai updated this revision to Diff 356430.Jul 4 2021, 10:41 PM

Address comments.

HsiangKai updated this revision to Diff 356431.Jul 4 2021, 10:44 PM
HsiangKai marked 3 inline comments as done.

clang-format.

HsiangKai marked 2 inline comments as done.Jul 4 2021, 10:46 PM
HsiangKai updated this revision to Diff 356433.Jul 4 2021, 11:14 PM

Record IsVectorCall in RISCVMachineFunctionInfo.

HsiangKai marked an inline comment as done.Jul 4 2021, 11:15 PM
HsiangKai updated this revision to Diff 356435.Jul 4 2021, 11:27 PM

Move RISCVTargetStreamer::emitDirectiveVariantCC near to emitDirectiveXXX.

jrtc27 added inline comments.Nov 14 2022, 5:42 PM
llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
203

RMFI?

MaskRay added inline comments.Nov 19 2022, 2:18 PM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
2210

unneeded blank line

2216

unneeded blank line

2221

Delete // Eat the symbol which does not convey more information than the code

2223

comments are usually full sentences ending with .

2225

addErrorSuffix is generally not useful because the error contains the source line.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
106

If Symbol is non-null, prefer a reference.