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

[PowerPC][JITLink] Support R_PPC64_GOT_TLSGD_PCREL34 #68660

Merged
merged 8 commits into from
Oct 14, 2023

Conversation

bzEq
Copy link
Collaborator

@bzEq bzEq commented Oct 10, 2023

R_PPC64_GOT_TLSGD_PCREL34 is generated for pwr10+.

@bzEq bzEq self-assigned this Oct 10, 2023
@bzEq bzEq marked this pull request as draft October 10, 2023 06:50
@bzEq bzEq marked this pull request as ready for review October 11, 2023 08:00
@bzEq
Copy link
Collaborator Author

bzEq commented Oct 11, 2023

Since we don't have pwr10 buildbot, I don't add test in compiler-rt. Here's the simple example I create and runs on pwr10 machine successfully.

#include <stdio.h>
#include <iostream>
#include <thread>
#include <vector>

_Thread_local int id;

int main() {
  std::vector<std::thread> vt;
  for (int i = 0; i < 8; ++i) {
    vt.emplace_back([&]() {
        std::cout << &id << std::endl;
      });
  }
  for (auto &t : vt) t.join();
  return 0;
}
~/llvm/community/build/bin/clang++ -c -O3 -mcpu=pwr10 -fPIC -ftls-model=global-dynamic tls.cc
~/llvm/community/build/bin/llvm-objdump -r tls.o|grep TLS
0000000000000564 R_PPC64_GOT_TLSGD_PCREL34 id
000000000000056c R_PPC64_TLSGD            id
~/llvm/community/build/bin/llvm-jitlink tls.o --orc-runtime=$HOME/llvm/community/build/lib/clang/18/lib/powerpc64le-unknown-linux-gnu/liborc_rt.a
0x760540000c70
0x760538000c70
0x760538000c90
0x760530000c70
0x760530000c90
0x760530000be0
0x760530000c70
0x760530000c90

@bzEq bzEq requested a review from vgvassilev October 12, 2023 14:15
Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

This looks good to me and our use case in cms-sw/cmssw#41658. I'd wait for one more reviewer to approve it. @lhames ping.

@lhames
Copy link
Contributor

lhames commented Oct 12, 2023

Are you able to add a testcase that runs locally? If so then I think it make sense to include one even if there's no builedbot to run it, since at least PPC developers could run it locally.

LGTM though -- if you're not able to add a testcase please go ahead and land anyway.

@bzEq
Copy link
Collaborator Author

bzEq commented Oct 13, 2023

Added TLS test for pwr10. Since requiring different PLT stubs for the same external symbol is rare(need __attribute__((target(...)))), I currently mark it as FIXME.

@lhames
Copy link
Contributor

lhames commented Oct 13, 2023

Thanks very much for adding the testcase!

@bzEq bzEq merged commit 18dc8dc into llvm:main Oct 14, 2023
3 checks passed
@bzEq bzEq deleted the ppc64-got-tlsgd-pcrel34 branch October 14, 2023 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants