aboutsummaryrefslogtreecommitdiff
path: root/clang/test/OpenMP/parallel_codegen.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-04-30[OMPIRBuilder] Don't discard the debug record from entry block. (#135161)Abid Qadeer1-0/+2
When we get a function back from `CodeExtractor`, we discard its entry block after coping its instructions into the entry block we prepared. While copying the instructions, the terminator is discarded for obvious reasons. But if there were some debug values attached to the terminator, those are useful and needs to be copied.
2025-03-07[mlir][OpenMP] fix crash outlining infinite loop (#129872)Tom Eccles1-16/+8
Previously an extra block was created by splitting the previous exit block. This produced incorrect results when the outlined region statically never terminated because then there wouldn't be a valid exit block for the outlined region, this caused this newly added block to have an incoming edge from outside of the outlining region, which caused outlining to fail. So far as I can tell this extra block no longer serves any purpose. The comment says it is supposed to collate multiple control flow edges into one place, but the code as it is now does not achieve this. In fact, as can be seen from the changes to lit tests, this block was not actually outlined in the end. This is because there are actually two code extractors: one in the callback for creating a parallel op which is used to find what the input/output variables are (which does have this block added to it), and another one which actually does the outlining (which this block was not added to). Tested with the gfortran and fujitsu test suites. Fixes #112884
2024-07-23[OpenMP] Ensure the actual kernel is annotated with launch bounds (#99927)Johannes Doerfert1-146/+146
In debug mode there is a wrapper (the kernel) around the function in which we generate the kernel code. We worked around this before to get the correct kernel name, but now we really distinguish both to attach the launch bounds to the kernel, not the inner function.
2024-06-14 [RemoveDIs] Print IR with debug records by default (#91724)Stephen Tozer1-135/+135
This patch makes the final major change of the RemoveDIs project, changing the default IR output from debug intrinsics to debug records. This is expected to break a large number of tests: every single one that tests for uses or declarations of debug intrinsics and does not explicitly disable writing records. If this patch has broken your downstream tests (or upstream tests on a configuration I wasn't able to run): 1. If you need to immediately unblock a build, pass `--write-experimental-debuginfo=false` to LLVM's option processing for all failing tests (remember to use `-mllvm` for clang/flang to forward arguments to LLVM). 2. For most test failures, the changes are trivial and mechanical, enough that they can be done by script; see the migration guide for a guide on how to do this: https://llvm.org/docs/RemoveDIsDebugInfo.html#test-updates 3. If any tests fail for reasons other than FileCheck check lines that need updating, such as assertion failures, that is most likely a real bug with this patch and should be reported as such. For more information, see the recent PSA: https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578
2024-06-05[OpenMP][LLVM] Update alloca IP after `PrivCB` in `OMPIRBUIlder` (#93920)Kareem Ergawy1-2/+2
Fixes a crash uncovered by [pr77666.f90](https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/gomp/pr77666.f90) in the test suite when delayed privatization is enabled by default. In particular, whenever `PrivCB` (the callback responsible for generating privatizaiton logic for an OMP variable) generates a multi-block privatization region, the insertion point diverges: the BB component of the IP can become a different BB from the parent block of the instruction iterator component of the IP. This PR updates the IP to make sure that the BB is the parent block of the instruction iterator.
2023-11-03[NFC][OpenMP][Clang]Update OpenMP clang testsDominik Adamski1-2/+2
Replace hardcoded constants by regular expressions
2023-10-20Diagnose use of VLAs in C++ by defaultAaron Ballman1-8/+8
Reapplication of 7339c0f782d5c70e0928f8991b0c05338a90c84c with a fix for a crash involving arrays without a size expression. Clang supports VLAs in C++ as an extension, but we currently only warn on their use when you pass -Wvla, -Wvla-extension, or -pedantic. However, VLAs as they're expressed in C have been considered by WG21 and rejected, are easy to use accidentally to the surprise of users (e.g., https://ddanilov.me/default-non-standard-features/), and they have potential security implications beyond constant-size arrays (https://wiki.sei.cmu.edu/confluence/display/c/ARR32-C.+Ensure+size+arguments+for+variable+length+arrays+are+in+a+valid+range). C++ users should strongly consider using other functionality such as std::vector instead. This seems like sufficiently compelling evidence to warn users about VLA use by default in C++ modes. This patch enables the -Wvla-extension diagnostic group in C++ language modes by default, and adds the warning group to -Wall in GNU++ language modes. The warning is still opt-in in C language modes, where support for VLAs is somewhat less surprising to users. RFC: https://discourse.llvm.org/t/rfc-diagnosing-use-of-vlas-in-c/73109 Fixes https://github.com/llvm/llvm-project/issues/62836 Differential Revision: https://reviews.llvm.org/D156565
2023-10-20Revert "Diagnose use of VLAs in C++ by default"Aaron Ballman1-8/+8
This reverts commit 7339c0f782d5c70e0928f8991b0c05338a90c84c. Breaks bots: https://lab.llvm.org/buildbot/#/builders/139/builds/51875 https://lab.llvm.org/buildbot/#/builders/164/builds/45262
2023-10-20Diagnose use of VLAs in C++ by defaultAaron Ballman1-8/+8
Clang supports VLAs in C++ as an extension, but we currently only warn on their use when you pass -Wvla, -Wvla-extension, or -pedantic. However, VLAs as they're expressed in C have been considered by WG21 and rejected, are easy to use accidentally to the surprise of users (e.g., https://ddanilov.me/default-non-standard-features/), and they have potential security implications beyond constant-size arrays (https://wiki.sei.cmu.edu/confluence/display/c/ARR32-C.+Ensure+size+arguments+for+variable+length+arrays+are+in+a+valid+range). C++ users should strongly consider using other functionality such as std::vector instead. This seems like sufficiently compelling evidence to warn users about VLA use by default in C++ modes. This patch enables the -Wvla-extension diagnostic group in C++ language modes by default, and adds the warning group to -Wall in GNU++ language modes. The warning is still opt-in in C language modes, where support for VLAs is somewhat less surprising to users. RFC: https://discourse.llvm.org/t/rfc-diagnosing-use-of-vlas-in-c/73109 Fixes https://github.com/llvm/llvm-project/issues/62836 Differential Revision: https://reviews.llvm.org/D156565
2023-08-09Intrinsics: Add type overload to stacksave and stackstoreMatt Arsenault1-12/+12
This allows use with non-0 address space stacks. llvm_ptr_ty should never be used. This could use some more percolation up through mlir, but this is enough to fix existing tests. https://reviews.llvm.org/D156666
2023-04-19[OpenMP] Prefix outlined and reduction func names with original func's nameItay Bookstein1-36/+36
This patch prefixes omp outlined helpers and reduction funcs with the original function's name. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D140722
2023-04-19Revert "[OpenMP] Prefix outlined and reduction func names with original ↵Itay Bookstein1-36/+36
func's name" This reverts commit 029bfc311d4d7d3cd90be81bb08c046848796d02.
2023-04-19[OpenMP] Prefix outlined and reduction func names with original func's nameItay Bookstein1-36/+36
This patch attempts to prefix omp outlined helpers and reduction funcs with the original function's name. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D140722
2023-01-09[OpenMP][NFC] Rerun the update_cc_test_checks on most OpenMP testsJohannes Doerfert1-11/+19
The script changes over time and unrelated changes to the test check lines should not pollute future revisions.
2022-11-29[clang][CodeGen] Add default attributes to __clang_call_terminateJohn Brawn1-2/+2
When generating __clang_call_terminate use SetLLVMFunctionAttributes to set the default function attributes, like we do for all the other functions generated by clang. This fixes a problem where target features from the command line weren't being applied to this function. Differential Revision: https://reviews.llvm.org/D138679
2022-10-07[OpenMP] Convert tests to opaque pointers (NFC)Nikita Popov1-575/+575
Conversion performed using the script at: https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34 These are only tests where no manual fixup was required.
2022-09-15Revert "[OpenMP] Codegen aggregate for outlined function captures"Dhruva Chakrabarti1-333/+403
This reverts commit 7539e9cf811e590d9f12ae39673ca789e26386b4.
2022-09-15[OpenMP] Codegen aggregate for outlined function capturesGiorgis Georgakoudis1-403/+333
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3) forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call. Reviewed By: jdoerfert, jhuber6, ABataev Differential Revision: https://reviews.llvm.org/D102107
2022-04-07[OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)Nikita Popov1-12/+12
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-01-25[OMPIRBuilder] Generate aggregate argument for parallel region outlined ↵Giorgis Georgakoudis1-289/+316
functions Summary: This patch modifies code generation in OpenMPIRBuilder to pass arguments to the parallel region outlined function in an aggregate (struct), besides the global_tid and bound_tid arguments. It depends on the updated CodeExtractor (see D96854) for support. It mirrors functionality of Clang codegen (see D102107). Differential Revision: https://reviews.llvm.org/D110114
2022-01-16[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and ↵hyeongyu kim1-50/+50
turn it off by default Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions. I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default. Test updates are made as a separate patch: D108453 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D105169
2021-11-09Revert "[Clang/Test]: Rename enable_noundef_analysis to ↵hyeongyu kim1-50/+50
disable-noundef-analysis and turn it off by default" This reverts commit aacfbb953eb705af2ecfeb95a6262818fa85dd92. Revert "Fix lit test failures in CodeGenCoroutines" This reverts commit 63fff0f5bffe20fa2c84a45a41161afa0043cb34.
2021-11-06[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and ↵hyeongyukim1-50/+50
turn it off by default Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions. I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default. Test updates are made as a separate patch: D108453 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D105169 [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2) This patch updates test files after D105169. Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows: (1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached. (2) The remaining tests are updated manually. Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D108453 Resolve lit failures in clang after 8ca4b3e's land Fix lit test failures in clang-ppc* and clang-x64-windows-msvc Fix missing failures in clang-ppc64be* and retry fixing clang-x64-windows-msvc Fix internal_clone(aarch64) inline assembly
2021-11-06Revert "[Clang/Test]: Rename enable_noundef_analysis to ↵Juneyoung Lee1-50/+50
disable-noundef-analysis and turn it off by default" This reverts commit 7584ef766a7219b6ee5a400637206d26e0fa98ac.
2021-11-06[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and ↵Juneyoung Lee1-50/+50
turn it off by default Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions. I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default. Test updates are made as a separate patch: D108453 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D105169
2021-10-18Revert D105169 due to the two-stage failure in ASANJuneyoung Lee1-50/+50
This reverts the following commits: 37ca7a795b277c20c02a218bf44052278c03344b 9aa6c72b92b6c89cc6d23b693257df9af7de2d15 705387c5074bcca36d626882462ebbc2bcc3bed4 8ca4b3ef19fe82d7ad6a6e1515317dcc01b41515 80dba72a669b5416e97a42fd2c2a7bc5a6d3f44a
2021-10-16[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and ↵Juneyoung Lee1-50/+50
turn it off by default (2) This patch updates test files after D105169. Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows: (1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached. (2) The remaining tests are updated manually. Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D108453
2021-09-21Revert "[OpenMP] Codegen aggregate for outlined function captures"Giorgis Georgakoudis1-389/+468
This reverts commit 1d66649adf28d48ae1731516d87fb899426e3349. Revert to fix AMG GPU issue.
2021-09-21[OpenMP] Codegen aggregate for outlined function capturesGiorgis Georgakoudis1-468/+389
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3) forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call. Reviewed By: jdoerfert, jhuber6 Differential Revision: https://reviews.llvm.org/D102107
2021-08-25[CodeExtractor] Preserve topological order for the return blocks.Vyacheslav Zakharin1-9/+9
Differential Revision: https://reviews.llvm.org/D108673
2021-07-19Revert "[OpenMP] Codegen aggregate for outlined function captures"Giorgis Georgakoudis1-323/+402
This reverts commit e9c7291cb25f071f1a1dfa4049ed9f5a8a217b3e. Fix failing tests
2021-07-16[OpenMP] Codegen aggregate for outlined function capturesGiorgis Georgakoudis1-402/+323
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3) forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D102107
2021-05-19[OpenMP][NFC] Remove SIMD check lines for non-simd testsJohannes Doerfert1-494/+5
If a test does not contain an " simd" but -fopenmp-simd RUN lines we can just check that we do not create __kmpc|__tgt calls. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D101973
2021-05-05[OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checksGiorgis Georgakoudis1-137/+1401
This patch refactors a subset of Clang OpenMP tests, generating checklines using the update_cc_test_checks script. This refactoring facilitates updating the Clang OpenMP code generation codebase by automating test generation. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101849
2021-05-04Revert "[OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks"Giorgis Georgakoudis1-1401/+137
This reverts commit 956cae2f09b21429dbcb02066c99e35a239aa4bf.
2021-05-04[OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checksGiorgis Georgakoudis1-137/+1401
This patch refactors a subset of Clang OpenMP tests, generating checklines using the update_cc_test_checks script. This refactoring facilitates updating the Clang OpenMP code generation codebase by automating test generation. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101849
2021-01-01test/OpenMP/parallel_codegen.cpp: Allow multiple result attributesFangrui Song1-1/+1
On many targets the matched line is `define dso_local i32 @main` while on ppc64 it is `define dso_local signext i32 @main`.
2020-12-31[test] Add {{.*}} to make ELF tests immune to ↵Fangrui Song1-1/+1
dso_local/dso_preemptable/(none) differences For a default visibility external linkage definition, dso_local is set for ELF -fno-pic/-fpie and COFF and Mach-O. Since default clang -cc1 for ELF is similar to -fpic ("PIC Level" is not set), this nuance causes unneeded binary format differences. To make emitted IR similar, ELF -cc1 -fpic will default to -fno-semantic-interposition, which sets dso_local for default visibility external linkage definitions. To make this flip smooth and enable future (dso_local as definition default), this patch replaces (function) `define ` with `define{{.*}} `, (variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `.
2020-12-02[OpenMPIRBuilder] forward arguments as pointers to outlined functionAlex Zinenko1-4/+8
OpenMPIRBuilder::createParallel outlines the body region of the parallel construct into a new function that accepts any value previously defined outside the region as a function argument. This function is called back by OpenMP runtime function __kmpc_fork_call, which expects trailing arguments to be pointers. If the region uses a value that is not of a pointer type, e.g. a struct, the produced code would be invalid. In such cases, make createParallel emit IR that stores the value on stack and pass the pointer to the outlined function instead. The outlined function then loads the value back and uses as normal. Reviewed By: jdoerfert, llitchev Differential Revision: https://reviews.llvm.org/D92189
2020-08-10[OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in ClangJohannes Doerfert1-16/+8
Replace the `ident_t` handling in Clang with the methods offered by the OMPIRBuilder. This cuts down on the clang code as well as the differences between the two, making further transitions easier. Tests have changed but there should not be a real functional change. The most interesting difference is probably that we stop generating local ident_t allocations for now and just use globals. Given that this happens only with debug info, the location part of the `ident_t` is probably bigger than the test anyway. As the location part is already a global, we can avoid the allocation, memcpy, and store in favor of a constant global that is slightly bigger. This can be revisited if there are complications. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D80735
2020-07-05[Driver] Pass -gno-column-info instead of -dwarf-column-infoFangrui Song1-1/+1
Making -g[no-]column-info opt out reduces the length of a typical CC1 command line. Additionally, in a non-debug compile, we won't see -dwarf-column-info.
2020-05-19[CGCall] Annotate references with "align" attribute.Eli Friedman1-3/+3
If we're going to assume references are dereferenceable, we should also assume they're aligned: otherwise, we can't actually dereference them. See also D80072. Differential Revision: https://reviews.llvm.org/D80166
2020-04-09[OPENMP]Fix the test to pacify buildbots, NFC.Alexey Bataev1-3/+3
2020-04-09[OPENMP]Fix capturing of global variables in OpenMP regions.Alexey Bataev1-6/+34
Summary: The global variable should be captured in the region only if it was privitized in the region or in any of the outer regions. Otherwise, it should not be captured. Reviewers: jdoerfert Subscribers: yaxunl, guansong, cfe-commits, caomhin Tags: #clang Differential Revision: https://reviews.llvm.org/D77731
2020-04-07[OPENMP]Do not capture global marked as shared in OpenMP region.Alexey Bataev1-4/+5
No need to capture the global variable marked as shared in the OpenMP region, the original variable can be used.
2020-02-19Reapply [IRBuilder] Always respect inserter/folderNikita Popov1-4/+2
Some IRBuilder methods that were originally defined on IRBuilderBase do not respect custom IRBuilder inserters/folders, because those were not accessible prior to D73835. Fix this by making use of existing (and now accessible) IRBuilder methods, which will handle inserters/folders correctly. There are some changes in OpenMP and Instrumentation tests, where bitcasts now get constant folded. I've also highlighted one InstCombine test which now finishes in two rather than three iterations, thanks to new instructions being inserted into the worklist. Differential Revision: https://reviews.llvm.org/D74787
2020-02-19Revert "[IRBuilder] Always respect inserter/folder"Nikita Popov1-2/+4
This reverts commit f12fb2d99b8dd0dbef1c79f1d401200150f2d0bd. I missed some changes in instrumentation test cases.
2020-02-19[IRBuilder] Always respect inserter/folderNikita Popov1-4/+2
Some IRBuilder methods that were originally defined on IRBuilderBase do not respect custom IRBuilder inserters/folders, because those were not accessible prior to D73835. Fix this by making use of existing (and now accessible) IRBuilder methods, which will handle inserters/folders correctly. There are some changes in OpenMP tests, where bitcasts now get constant folded. I've also highlighted one InstCombine test which now finishes in two rather than three iterations, thanks to new instructions being inserted into the worklist. Differential Revision: https://reviews.llvm.org/D74787
2020-02-03Revert "[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition"Fangrui Song1-1/+1
This reverts commit 789a46f2d742e11edaade28cb59a0f4d2a1d770e. Accidentally committed.
2020-02-03[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interpositionFangrui Song1-1/+1
Summary: Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults to -fsemantic-interposition). Users need to specify -fsemantic-interposition to get semantic interposition behavior. Semantic interposition is currently a best-effort feature. There may still be some cases where it is not handled well. Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73865