Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom lowering of vaarg for xtensa. #201

Closed
wants to merge 1 commit into from

Conversation

plietar
Copy link

@plietar plietar commented Oct 18, 2023

LLVM does not include an implementation of the va_arg instruction for Xtensa. From what I understand, this is a conscious decision and instead language frontends are encouraged to implement it themselves. The rationale seems to be that loading values correctly requires language and ABI-specific knowledge that LLVM lacks.

This is true of most architectures, and rustc already provides implementation for a number of them. This commit extends the support to include Xtensa.

See https://lists.llvm.org/pipermail/llvm-dev/2017-August/116337.html for some discussion on the topic.

Unfortunately there does not seem to be a reference document for the semantics of the va_list and va_arg on Xtensa. The most reliable source is the GCC implementation, which this commit tries to follow. Clang also provides its own compatible implementation.

This was tested for all the types that rustc allows in variadics, including larger types such as u64 and f64. I am also able to run the esp-wifi examples with formatted logs from the wifi stack.

Fixes #177

LLVM does not include an implementation of the va_arg instruction for
Xtensa. From what I understand, this is a conscious decision and
instead language frontends are encouraged to implement it themselves.
The rationale seems to be that loading values correctly requires
language and ABI-specific knowledge that LLVM lacks.

This is true of most architectures, and rustc already provides
implementation for a number of them. This commit extends the support to
include Xtensa.

See https://lists.llvm.org/pipermail/llvm-dev/2017-August/116337.html
for some discussion on the topic.

Unfortunately there does not seem to be a reference document for the
semantics of the va_list and va_arg on Xtensa. The most reliable source
is the GCC implementation, which this commit tries to follow. Clang also
provides its own compatible implementation.

This was tested for all the types that rustc allows in variadics.
@MabezDev
Copy link
Member

Thank you so much for taking the time to fix this! I have to admit I was completely stumped with this issue so I really appreciate the time you spent finding and fixing the problem. I compiled this and ran a few examples, including esp-wifi with wifi-logs enabled and everything has worked perfectly.

I've added your commit (keeping you as the author) to a new release branch, 1.73.0.1. We will begin producing builds for this branch soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems with C variadics
2 participants