llvm-project
2f755c54 - [OpenMP] Conditional modifier on lastprivate clause is producing incorrect result in C mode (#156004)

Commit
137 days ago
[OpenMP] Conditional modifier on lastprivate clause is producing incorrect result in C mode (#156004) Conditional modifier on lastprivate clause is producing incorrect result when compiled with clang( C compiler). IR is not emitting while compilation with C compiler. However it is working correctly with clang++ The OpenMP hook that emits the conditional modifier (checkAndEmitLastprivateConditional) is skipped in C because assignment is a prvalue and takes the scalar path. Original Codegen Support : [eddb8](https://github.com/llvm/llvm-project/commit/a58da1a2ff039dd3bb4c43db3919995cf4a74cc7#diff-629e03f730f901cdf96b6b48fb0aed8ef156590aaff37857b8e5ad0694beddb8) ``` C = → prvalue → EmitAnyExpr(TEK_Scalar) → ScalarExprEmitter::VisitBinAssign (hook not reached) C++ = → lvalue → EmitBinaryOperatorLValue ``` ``` Failing Test Case : #include <stdio.h> #define N 10 int A[N]; void condlastprivate() { int x, y, z, k; x = y = z = k = 0; #pragma omp parallel for lastprivate(conditional: x,y, z) lastprivate(k) for( k=0; k<N; k++){ if ((k >2 ) && (k <6)) { x = A[k]; z = A[k]+111; } else { y = A[k]+222; } } printf("Expecting: x=5, y=231, z=116 k=10 Got: x=%d y=%d z=%d k=%d \n", x,y,z,k); } int main() { for( int i=0; i<N; i++) { A[i] = i; } condlastprivate(); return 0; } ``` ``` #>./clang -fopenmp cond_c.c #> ./a.out Expecting: x=5, y=231, z=116 k=10 **Got: x=-1376379760 y=231 z=631465600** k=10 ``` --------- Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
Author
Parents
Loading