Issue 87466
Summary [clang][OpenMP] omp scan code gen does not initialize allocas
Labels clang
Assignees
Reporter Dinistro
    We stumbled over an issue in the code gen for `omp scan`. For a simple example like the following, the "inscan variable" is not properly initialized.

```
int curr_scan = 0;
#pragma omp parallel shared(thread_data, scan, curr_scan)
{
    int n = omp_get_num_threads();
    #pragma omp for reduction(inscan, + : curr_scan)
    for (int i = 0; i < n; ++i) {
        scan[i] = curr_scan;
        #pragma omp scan exclusive(curr_scan)
 curr_scan += thread_data[i];
    }
}
```

For a properly initialized `thread_data`, `scan` is filled up with random data. 
Looking at the generated IR shows that there are a few basic blocks in the outlined function that are unreachable, which seems suspicious.

Full example w: https://godbolt.org/z/rna6K8T6Y
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to