Issue 241294
Summary [CIR][OpenMP] Implement codegen for OpenMP `atomic` directive in ClangIR
Labels new issue
Assignees
Reporter Shrisha4real
    Currently, Clang with clangIR enabled throws a not-yet-implemented error  when the `atomic` directive is used in a program.
```
❯ clang --version
clang version 24.0.0git (https://github.com/llvm/llvm-project.git 95143de0086ec60aff487535ec92c1b8b911f22b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/shrikuma/LLVM-Code-Generation/llvm-install/Release/bin
Build config: +assertions

❯ cat test.cpp
void fail(void) {
  int old_val=0;
  int counter=0;
  #pragma omp atomic capture
  {
      old_val = counter;
      counter++;
  }
}

❯ clang++ -fclangir -emit-cir -fopenmp test.cpp -o test.cir
test.cpp:4:3: error: ClangIR code gen Not Yet Implemented: OpenMP OMPAtomicDirective
    4 |   #pragma omp atomic capture
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

```
---

The [syntax](https://www.openmp.org/spec-html/5.0/openmpsu95.html)  of the atomic construct takes one of the following forms:  

 ```
#pragma omp atomic [clause[[[,] clause] ... ] [,]] atomic-clause 
                   [[,] clause [[[,] clause] ... ]] new-line 
    _expression_-stmt
```
or  

``` 
#pragma omp atomic [clause[[,] clause] ... ] new-line 
    _expression_-stmt
```
or  
```
#pragma omp atomic [clause[[[,] clause] ... ] [,]] capture 
                   [[,] clause [[[,] clause] ... ]] new-line 
    structured-block
```
---



_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to