[flang][OpenMP] Fix the use-associated bug in threadprivate directive lowering
authorPeixin Qiao <qiaopeixin@huawei.com>
Mon, 17 Oct 2022 11:46:18 +0000 (19:46 +0800)
committerPeixin Qiao <qiaopeixin@huawei.com>
Mon, 17 Oct 2022 11:46:18 +0000 (19:46 +0800)
commit240b85b1a8540f1ac000dda9042ac2fbccd9bc69
treeae8695826e5544d7fa65d3ec5b9764b8d8355fb7
parent233659c7ae9b83b64a9f739d340736bca39c3d2e
[flang][OpenMP] Fix the use-associated bug in threadprivate directive lowering

The symbol may be used by use-association for multiple times such
as one in module specification part and one in module procedure.
Then in module procedure, the variable instantiation will be called
for multiple times. But we only need to threadprivatize it once and
use the threadprivatized value for the second time.

Fix #58379.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D136035
flang/lib/Lower/OpenMP.cpp
flang/test/Lower/OpenMP/threadprivate-use-association-2.f90 [new file with mode: 0644]