[Openmp-commits] [PATCH] D95769: [OpenMP][Libomptarget] Remove possible harmful copy constructor call for RTLsTy

Atmn Patel via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Jan 31 16:47:56 PST 2021


atmnpatel created this revision.
atmnpatel added reviewers: sylvestre.ledru, jdoerfert.
Herald added subscribers: guansong, kristof.beyls, yaxunl.
atmnpatel requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

>From https://bugs.llvm.org/show_bug.cgi?id=48973, we know that
`std::call_once(PM->RTLs.initFlag, &RTLsTy::LoadRTLs, PM->RTLs)` causes compile
time problems in libstdc++v3 5.3.1. This is because there was a defect in the
standard regarding the `call_once` (LWG 2442). This was fixed in libstdc++ soon
thereafter, but there are likely other standard libraries where this will fail.

It seems to me that the latest libstdc++ reads `PM->RTLs` and knows to move
PM->RTLs, while earlier implementations try to copy it, but this seems to fix
it for me at least locally, but given how finicky this could be, it'd be great
if @sylvestre.ledru could confirm it for me. The alternative is to change the
LoadRTLs signature but this should be fine.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95769

Files:
  openmp/libomptarget/src/interface.cpp


Index: openmp/libomptarget/src/interface.cpp
===================================================================
--- openmp/libomptarget/src/interface.cpp
+++ openmp/libomptarget/src/interface.cpp
@@ -94,7 +94,7 @@
 /// adds a target shared library to the target execution image
 EXTERN void __tgt_register_lib(__tgt_bin_desc *desc) {
   TIMESCOPE();
-  std::call_once(PM->RTLs.initFlag, &RTLsTy::LoadRTLs, PM->RTLs);
+  std::call_once(PM->RTLs.initFlag, &RTLsTy::LoadRTLs, &PM->RTLs);
   for (auto &RTL : PM->RTLs.AllRTLs) {
     if (RTL.register_lib) {
       if ((*RTL.register_lib)(desc) != OFFLOAD_SUCCESS) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95769.320386.patch
Type: text/x-patch
Size: 614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210201/3a3255b1/attachment-0001.bin>


More information about the Openmp-commits mailing list