| Issue |
240323
|
| Summary |
[CIR][OpenMP] Implement codegen for OpenMP `critical` directive in ClangIR
|
| Labels |
openmp,
ClangIR
|
| Assignees |
|
| Reporter |
Shrisha4real
|
Currently, Clang throws a not-yet-implemented error and crashes when the `critical` directive is used in a program.
Reproducer : https://godbolt.org/z/h5Wob4Pqc
Test case :
```cpp
void work(void);
void example(void) {
#pragma omp parallel
{
#pragma omp critical
work();
}
}
```
Command: `clang++ -fclangir -emit-cir -fopenmp test.cpp -o test.cir`
Output:
```
❯ 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
❯ clang++ -fclangir -emit-cir -fopenmp test.cpp -o test.cir
lessons/test.cpp:20:1: error: ClangIR code gen Not Yet Implemented: OpenMP OMPCriticalDirective
20 | #pragma omp critical
| ^~~~~~~~~~~~~~~~~~~~
should have emitted these statements as simple
UNREACHABLE executed at llvm-project/clang/lib/CIR/CodeGen/CIRGenStmt.cpp:237!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: clang++ -fclangir -emit-cir -fopenmp lessons/test.cpp -o lessons/test2.cir
1. <eof> parser at end of file
...
#10 0x00005df2d4a4456e (llvm-install/Release/bin/clang-24+0x241356e)
#11 0x00005df2d6d71960 clang::CIRGen::CIRGenFunction::emitStmt(clang::Stmt const*, bool, llvm::ArrayRef<clang::Attr const*>) (/home/shrikuma/LLVM-Code-Generation/llvm-install/Release/bin/clang-24+0x4740960)
#12 0x00005df2d6d9dc1f clang::CIRGen::CIRGenFunction::emitOMPParallelDirective(clang::OMPParallelDirective const&) (llvm-install/Release/bin/clang-24+0x476cc1f)
#13 0x00005df2d6d74aff clang::CIRGen::CIRGenFunction::emitCompoundStmtWithoutScope(clang::CompoundStmt const&, clang::CIRGen::Address*, clang::CIRGen::AggValueSlot) (llvm-install/Release/bin/clang-24+0x4743aff)
#14 0x00005df2d6d0b0ad clang::CIRGen::CIRGenFunction::emitFunctionBody(clang::Stmt const*) (llvm-install/Release/bin/clang-24+0x46da0ad)
#15 0x00005df2d6d0dd2c clang::CIRGen::CIRGenFunction::generateCode(clang::GlobalDecl, cir::FuncOp, cir::FuncType) (llvm-install/Release/bin/clang-24+0x46dcd2c)
#16 0x00005df2d6d30699 clang::CIRGen::CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl, mlir::Operation*) (llvm-install/Release/bin/clang-24+0x46ff699)
#17 0x00005df2d6d34d9d clang::CIRGen::CIRGenModule::emitDeferred() (llvm-install/Release/bin/clang-24+0x4703d9d)
#18 0x00005df2d6d350a0 clang::CIRGen::CIRGenModule::release() (llvm-install/Release/bin/clang-24+0x47040a0)
#19 0x00005df2d5b3bdf2 cir::CIRGenConsumer::HandleTranslationUnit(clang::ASTContext&) (llvm-install/Release/bin/clang-24+0x350adf2)
#20 0x00005df2d8b903bc clang::ParseAST(clang::Sema&, bool, bool) (llvm-install/Release/bin/clang-24+0x655f3bc)
...
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs