How to make clang call `__kmpc_threadprivate_register` with a not NULL copy constructor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make clang call `__kmpc_threadprivate_register` with a not NULL copy constructor

Richard Smith via cfe-dev

Hi guys,

 

I am having some trouble making clang++ generate a call to `__kmpc_threadprivate_register` where the copy constructor is not NULL.

Looking at the generated LLVM IR it seems that clang approach, not matter how an object (declared as OpenMP threadprivate) is initialized, it will always generate a `__kmpc_global_ctor` and pass that to the ctor arg of ` __kmpc_threadprivate_register`.

The `__kmpc_global_ctor` will then do the object initialization in whatever way is specified by the program.

 

For example, in the C++ program attached, we have an object `x` of class `myclass` initialized with another object `a` of type `myclass`, so the copy constructor of `myclass` will be called to initialize the instance of x.

Then x is declared as `omp threadprivate`.

 

In the LLVM IR (also attached, I put only the interesting LLVM IR) there is a `__kmpc_global_ctor_` which calls inside the copy constructor. The `__kmpc_global_ctor_` is passed to the kmpc function `__kmpc_threadprivate_register` as ctor arg, while NULL is passed in the cctor arg position.

 

My question is, is this an implementation choice or there is actually a way to make clang pass a copy constructor as a argument to `__kmpc_threadprivate_register`?

 

Maybe I am writing the wrong example and I am missing some knowledge about how C++ OpenMP threadprivate is supposed to work.

 

Thank you!

Simone

 


This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

threadprivate_class_cctor.cpp (2K) Download Attachment
threadprivate_class_cctor.ll (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to make clang call `__kmpc_threadprivate_register` with a not NULL copy constructor

Richard Smith via cfe-dev
Clang does not use this parameter as it is not required. All the required initialization can be performed using only the first ctor parameter.

Best regards,
Alexey Bataev

20 дек. 2018 г., в 17:24, Simone Atzeni via cfe-dev <[hidden email]> написал(а):

Hi guys,

 

I am having some trouble making clang++ generate a call to `__kmpc_threadprivate_register` where the copy constructor is not NULL.

Looking at the generated LLVM IR it seems that clang approach, not matter how an object (declared as OpenMP threadprivate) is initialized, it will always generate a `__kmpc_global_ctor` and pass that to the ctor arg of ` __kmpc_threadprivate_register`.

The `__kmpc_global_ctor` will then do the object initialization in whatever way is specified by the program.

 

For example, in the C++ program attached, we have an object `x` of class `myclass` initialized with another object `a` of type `myclass`, so the copy constructor of `myclass` will be called to initialize the instance of x.

Then x is declared as `omp threadprivate`.

 

In the LLVM IR (also attached, I put only the interesting LLVM IR) there is a `__kmpc_global_ctor_` which calls inside the copy constructor. The `__kmpc_global_ctor_` is passed to the kmpc function `__kmpc_threadprivate_register` as ctor arg, while NULL is passed in the cctor arg position.

 

My question is, is this an implementation choice or there is actually a way to make clang pass a copy constructor as a argument to `__kmpc_threadprivate_register`?

 

Maybe I am writing the wrong example and I am missing some knowledge about how C++ OpenMP threadprivate is supposed to work.

 

Thank you!

Simone

 


This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

<threadprivate_class_cctor.cpp>
<threadprivate_class_cctor.ll>

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev