Skip to content

[OpenMP] Fix __builtin_return_address calls for SPARC #138520

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

Merged
merged 1 commit into from
May 14, 2025

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented May 5, 2025

libomp uses __builtin_return_address in two places. However, on some targets those calls need to wrapped in ___builtin_extract_return_addr to get at the actual return address. SPARC is among those targets and the only one where clang actually implements this, cf. [clang][Sparc] Fix __builtin_extract_return_addr etc.. compiler-rt needed the same adjustment, cf. [sanitizer_common][test] Enable tests on SPARC. On other targets, this is a no-op. However, there are more targets that have the same issue and gcc, unlike clang, correctly implements it, so there might be issues when building libomp with gcc.

This patch adds the necessary calls.

Tested on sparcv9-sun-solaris2.11, sparc64-unknown-linux-gnu, amd64-pc-solaris2.11, and x86_64-pc-linux-gnu.

`libomp` uses `__builtin_return_address` in two places.  However, on some
targets those calls need to wrapped in `___builtin_extract_return_addr` to
get at the actual return address.  SPARC is among those targets and the
only one where `clang` actually implements this, cf.
[[clang][Sparc] Fix __builtin_extract_return_addr etc.](https://reviews.llvm.org/D91607).
On other targets, this is a no-op.  However, there are more targets that
have the same issue and `gcc`, unlike `clang`, correctly implements it, so
there might be issues when building `libomp` with `gcc`.

This patch adds the necessary calls.

Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`,
`amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
@rorth rorth requested review from MaskRay and brad0 May 5, 2025 12:36
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label May 5, 2025
@brad0
Copy link
Contributor

brad0 commented May 7, 2025

cc @MaskRay

@rorth rorth requested review from koachan and jprotze May 14, 2025 07:24
@rorth
Copy link
Collaborator Author

rorth commented May 14, 2025

It occured to me that I should refer to the patch where compiler-rt got the same adjustment.

Copy link
Collaborator

@jprotze jprotze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rorth rorth merged commit a2a280e into llvm:main May 14, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants