This patch adds support for variadic argument for loongarch64,
which is based on MIPS64. And check-msan all pass.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
5840 | It looks like exact clone of Mips64 helper. Why not just use Mips64 then? |
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
5840 | Yes, the VarArg convention in LoongArch's ABI is similar to that of Mips, so VarArgLoongArch64Helper is here based on Mips. If use Mips64 helper, like this: + else if (TargetTriple.isMIPS64() || TargetTriple.isLoongArch64()) return new VarArgMIPS64Helper(Func, Msan, Visitor); VarArgMIPS64Helper is a MIPS64-specific implementation. Adding loongarch64 here, does it seem somewhat ambiguous, suggesting LoongArch as a variant of MIPS architecture? I don't know if it's good to use it directly like mentioned above. So is it okay like above or have any better suggestions? Thanks for your time. |
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
5840 | How about something line this: // Loongarch64 is not a MIPS, but the current vargs calling convention matches the MIPS. Another alternative is to rename VarArgMIPS64Helper into something more general, maybe there is a name for this calling convention already? | |
llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg-loongarch64.ll | ||
4 | even if we use MIPS helper, please keep this new test, in case someone modify Mips part ignoring loongarch64 |
I'm not looking at this in more detail right now (it's 3 am here), but isn't the LoongArch psABI mostly resembling RISCV, and not Mips?
I have read varargs part in the RISCV psABI at https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#va_list-va_start-and-va_arg and in Mips "elf64-2.4.pdf". That of LoongArch psABI is indeed very similar to that of RISCV, and also similar to MIPS.
RISCV is not yet supported in the MSan vararg instrumentation, so i referred to the implementation based on Mips here. After testing and verifying, the Mips-based vararg implementation in LoongArch works fine.
The ABI similarities between architectures could be coincidental, therefore we can't ignore the potential risks of sharing code. I should pay attention and update it accordingly if there are any changes in the future.
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
5840 | Thanks for your suggestions. I'm inclined towards the first alternative. As for renaming VarArgMIPS64Helper, we did consider renaming it to something more generic, but we haven't found a better name yet, and it's worth taking some time to research and find a suitable name. So for now, I will go with the first option. |
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | ||
---|---|---|
5840 | Please add a comment to the VarArgMIPS64Helper definition that explains that this is also used for Loongarch. |
It looks like exact clone of Mips64 helper.
Only if (TargetTriple.getArch() == Triple::mips64) { is missing
Why not just use Mips64 then?