<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - code moved out of omp critical region"
href="https://bugs.llvm.org/show_bug.cgi?id=45854">45854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>code moved out of omp critical region
</td>
</tr>
<tr>
<th>Product</th>
<td>OpenMP
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Clang Compiler Support
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>michael.p.rice@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>After the recent changes to capture fewer globals this test started failing
possibly due to an optimization firing that wasn't before:
extern void omp_set_num_threads (int);
extern void omp_set_dynamic (int);
extern int omp_get_max_threads (void);
int errors = 0;
int thds;
int shrd;
int main ()
{
int i;
omp_set_num_threads(2);
thds = omp_get_max_threads();
omp_set_dynamic(0);
shrd = 0;
#pragma omp parallel for default(shared) schedule(static)
for (i=0; i<thds; i++) {
#pragma omp critical
shrd += 1;
}
if (shrd != thds) errors += 1;
return errors;
}
It appears an optimization pass has moved some of the increment of 'shrd'
outside the critical region.
# %bb.2: # %omp.inner.for.body.preheader
cmpl %eax, %ebp
cmovll %eax, %ebp
movl .Lshrd$local(%rip), %ebx
addl $1, %ebx
subl %eax, %ebp
addl $1, %ebp
.p2align 4, 0x90
.LBB1_3: # %omp.inner.for.body
# =>This Inner Loop Header: Depth=1
movl $.L__unnamed_1, %edi
movl $.gomp_critical_user_.var, %edx
movl %r14d, %esi
callq __kmpc_critical
movl %ebx, .Lshrd$local(%rip)
movl $.L__unnamed_1, %edi
movl $.gomp_critical_user_.var, %edx
movl %r14d, %esi
callq __kmpc_end_critical
addl $1, %ebx
addl $-1, %ebp
jne .LBB1_3
.LBB1_4: # %omp.loop.exit
Also here:
<a href="https://godbolt.org/z/2YPJ4P">https://godbolt.org/z/2YPJ4P</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>