Couple of weeks ago Jim Cownie <jcownie@gmail.com> effectively answered your question.
Let me try to re-iterate:
For each static_init_4 call, there is a static_fini call. Is this specific to its static_init_4 call?
Yes.
Is there a pairing of calls that can not be broken?
Yes, though I am not completely sure what you are asking about here. You can break the code any way you want, but why?
If we look at the static_fini call, the function arguments are the same.
Same as what? They are probably same location info and global thread id as in the corresponding static_init call, if I got your question right.
It seems that if we have two static_init_4 function calls, we can interchange their static_fini calls. Does that make sense?
Not sure what is your goal here… All you can achieve by such broken code generation is to confuse an OMPT tool with unspecified results, possibly break statistics gathering, break checking of consistency of the OpenMP constructs, - all the code of static_fini does.
If I move the static_fini call beyond Loop-B in IR; Should Loop-B be part of the Work Sharing environment and its iteration should be distributed similarly to Loop-A over the available threads?
All you can achive here is again to get broken code generation, and as a result to confuse an OMPT tool with unspecified results, etc. The static_fini call does not affect parallelization in any way, so your second Loop-B will remain to be serial loop and will be redundantly executed by all threads of the team, regardless of the location of the static_fini call. To make a loop work sharing, it should be parallelized (e.g. by adding “#pragma omp for” in the source code, given there exist enclosing parallel region).
As Jim suggested earlier, look at the code!
And please first describe the problem you want to solve. As opposed to trying to shuffle statements by guess.
Regards,
Andrey