summaryrefslogtreecommitdiff
path: root/clang/test/OpenMP/depobj_codegen.cpp
AgeCommit message (Collapse)Author
2024-11-11Fix for codegen Crash in Clang when using locator omp_all_memory with depobj ↵CHANDRA GHALE
construct (#114221) A codegen crash is occurring when a depend object was initialized with omp_all_memory in the depobj directive. https://github.com/llvm/llvm-project/issues/114214(url) The root cause of issue looks to be the improper handling of the dependency list when omp_all_memory was specified. The change introduces the use of OMPTaskDataTy to manage dependencies. The buildDependences function is called to construct the dependency list, and the list is iterated over to emit and store the dependencies. Reduced Test Case : ``` #include <omp.h> int main() { omp_depend_t obj; #pragma omp depobj(obj) depend(inout: omp_all_memory) } ``` ``` #1 0x0000000003de6623 SignalHandler(int) Signals.cpp:0:0 #2 0x00007f8e4a6b990f (/lib64/libpthread.so.0+0x1690f) #3 0x00007f8e4a117d2a raise (/lib64/libc.so.6+0x4ad2a) #4 0x00007f8e4a1193e4 abort (/lib64/libc.so.6+0x4c3e4) #5 0x00007f8e4a10fc69 __assert_fail_base (/lib64/libc.so.6+0x42c69) #6 0x00007f8e4a10fcf1 __assert_fail (/lib64/libc.so.6+0x42cf1) #7 0x0000000004114367 clang::CodeGen::CodeGenFunction::EmitOMPDepobjDirective(clang::OMPDepobjDirective const&) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x4114367) #8 0x00000000040f8fac clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x40f8fac) #9 0x00000000040ff4fb clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x40ff4fb) #10 0x00000000041847b2 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x41847b2) #11 0x0000000004199e4a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x4199e4a) #12 0x00000000041f7b9d clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x41f7b9d) #13 0x00000000041f16a3 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x41f16a3) #14 0x00000000041fd954 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x41fd954) #15 0x0000000004200277 clang::CodeGen::CodeGenModule::Release() (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x4200277) #16 0x00000000046b6a49 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0 #17 0x00000000046b4cb6 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x46b4cb6) #18 0x0000000006204d5c clang::ParseAST(clang::Sema&, bool, bool) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x6204d5c) #19 0x000000000496b278 clang::FrontendAction::Execute() (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x496b278) #20 0x00000000048dd074 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x48dd074) #21 0x0000000004a38092 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0x4a38092) #22 0x0000000000fd4e9c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0xfd4e9c) #23 0x0000000000fcca73 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0 #24 0x0000000000fd140c clang_main(int, char**, llvm::ToolContext const&) (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0xfd140c) #25 0x0000000000ee2ef3 main (/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/bin/clang-18+0xee2ef3) #26 0x00007f8e4a10224c __libc_start_main (/lib64/libc.so.6+0x3524c) #27 0x0000000000fcaae9 _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:120:0 clang: error: unable to execute command: Aborted ``` --------- Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2024-08-09[IRBuilder] Generate nuw GEPs for struct member accesses (#99538)Hari Limaye
Generate nuw GEPs for struct member accesses, as inbounds + non-negative implies nuw. Regression tests are updated using update scripts where possible, and by find + replace where not.
2023-05-15[clang] Convert a few OpenMP tests to use opaque pointersSergei Barannikov
Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D150530
2022-05-24[OpenMP] Add codegen for 'omp_all_memory' reserved locator.Mike Rice
This creates an entry with address=nullptr and flag=0x80. When an 'omp_all_memory' entry is specified any other 'out' or 'inout' entries are not needed and are not passed to the runtime. Differential Revision: https://reviews.llvm.org/D126321
2022-04-07[OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)Nikita Popov
This adds -no-opaque-pointers to clang tests whose output will change when opaque pointers are enabled by default. This is intended to be part of the migration approach described in https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9. The patch has been produced by replacing %clang_cc1 with %clang_cc1 -no-opaque-pointers for tests that fail with opaque pointers enabled. Worth noting that this doesn't cover all tests, there's a remaining ~40 tests not using %clang_cc1 that will need a followup change. Differential Revision: https://reviews.llvm.org/D123115
2022-03-23[CodeGen][OpenMP] Add alignment to test (NFC)Nikita Popov
Check which alignments are generated for loads/stores.
2022-03-23[CGOpenMPRuntime] Specify correct type in EmitLoadOfPointerLValue()Nikita Popov
Perform a bitcast first, so we can specify the correct pointer type inf EmitLoadOfPointerLValue(), rather than using a dummy void pointer.
2021-06-09Revert "[OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type"AndreyChurbanov
This reverts commit a1f550e052543f75acac9089b760cbc61729131f. Revert in order to fix backwards compatibility breakage caused by type size change for task dependence flag.
2021-06-07[OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence typeAndreyChurbanov
Refactored code of dependence processing and added new inoutset dependence type. Compiler can set dependence flag to 0x8 when call __kmpc_omp_task_with_deps. Size of type of the dependence flag changed from 1 to 4 bytes in clang. All dependence flags library gets so far and corresponding dependence types: 1 - IN, 2 - OUT, 3 - INOUT, 4 - MUTEXINOUTSET, 8 - INOUTSET. Differential Revision: https://reviews.llvm.org/D97085
2020-08-27[OpenMP] Ensure testing for versions 4.5 and default - Part 3Saiyedul Islam
This third patch in the series removes version 5.0 string from test cases making them check for default version. It also add test cases for version 4.5. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D85214
2020-04-07[OPENMP50]Codegen for iterator construct.Alexey Bataev
Implemented codegen for the iterator expression in the depend clauses. Iterator construct is emitted the following way: iterator(cnt1, cnt2, ...), in : <dep> <TotalNumDeps> = <cnt1_size> * <cnt2_size> * ...; kmp_depend_t deps[<TotalNumDeps>]; deps_counter = 0; for (cnt1) { for (cnt2) { ... deps[deps_counter].base_addr = &<dep>; deps[deps_counter].size = sizeof(<dep>); deps[deps_counter].flags = in; deps_counter += 1; ... } } For depobj construct the codegen is very similar, but the memory is allocated dynamically and added extra first item reserved for internal use.
2020-03-31[OPENMP50]Fix size calculation for array shaping expression in theAlexey Bataev
codegen. Need to include the size of the pointee type when trying to calculate the total size of the array shaping expression.
2020-03-30[OPENMP50]Add codegen support for array shaping expression in dependAlexey Bataev
clauses. Implemented codegen for array shaping operation in depend clauses. The begin of the expression is the pointer itself, while the size of the dependence data is the mukltiplacation of all dimensions in the array shaping expression.
2020-03-06[OPENMP50]Add 'depobj' modifier in 'depend' clauses.Alexey Bataev
Added basic support (parsing/sema/serialization) for depobj dependency kind in depend clauses.
2020-03-05[OPENMP50]Add codegen for update clause in depobj directive.Alexey Bataev
Added codegen for update clause in depobj. Reads the number of the elements from the first element and updates flags for each element in the loop. ``` omp_depend_t x; kmp_depend_info *base = (kmp_depend_info *)x; intptr_t num = x[-1].base_addr; kmp_depend_info *end = x + num; kmp_depend_info *el = base; do { el.flags = new_flag; el = &el[1]; } while (el != end); ```
2020-03-05[OPENMP50]Skip the first element when storing the list of dependenciesAlexey Bataev
in depobj object. The first element in the list of the dependencies is used for internal purposes to store the number of the elements in the provided list. The first element now is skipped and depobj object poits exactly to the list of dependencies.
2020-03-04[OPENMP50]Codegen for 'destroy' clause in depobj directive.Alexey Bataev
If the destroy clause is appplied, the previously allocated memory for the dependency object must be destroyed.
2020-03-04[OPENMP50]Codegen for 'depend' clause in depobj directive.Alexey Bataev
Added codegen for 'depend' clause in depobj directive. The depend clause is emitted as kmp_depend_info <deps>[<number_of_items_in_clause> + 1]. The first element in this array is reserved for storing the number of elements in this array: <deps>[0].base_addr = <number_of_items_in_clause>; This extra element is required to implement 'update' and 'destroy' clauses. It is required to know the size of array to destroy it correctly and to update depency kind.