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_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
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
Maybe I am writing the wrong example and I am missing some knowledge about how C++ OpenMP threadprivate is supposed to work.
threadprivate_class_cctor.cpp (1.71 KB)
threadprivate_class_cctor.ll (1.32 KB)