summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGOpenMPRuntime.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.Alexey Bataev2016-03-171-13/+45
| | | | | | | | OpenMP 4.0 allows to define custom reduction operations using '#pragma omp declare reduction' construct. Patch allows to use this custom defined reduction operations in 'reduction' clauses. llvm-svn: 263701
* [OPENMP] Support for codegen of private clause of target, host sideCarlo Bertolli2016-03-161-1/+5
| | | | | | | | This patch adds support for codegen of private clause of target and a regression test for host code generation, when the host is used as target device. I believe that code generation for nvptx backend would not require anything additional or different to what is done for the host. http://reviews.llvm.org/D18105 llvm-svn: 263654
* Revert commit http://reviews.llvm.org/D17877 to fix tests on x86.Arpith Chacko Jacob2016-03-151-10/+0
| | | | llvm-svn: 263589
* [OpenMP] Base support for target directive codegen on NVPTX device.Arpith Chacko Jacob2016-03-151-0/+10
| | | | | | | | | | | Summary: This patch adds base support for codegen of the target directive on the NVPTX device. Reviewers: ABataev Differential Revision: http://reviews.llvm.org/D17877 llvm-svn: 263587
* Reverted http://reviews.llvm.org/D17877 to fix tests.Arpith Chacko Jacob2016-03-151-10/+0
| | | | llvm-svn: 263555
* [OpenMP] Base support for target directive codegen on NVPTX device.Arpith Chacko Jacob2016-03-151-0/+10
| | | | | | | | | | | Summary: This patch adds base support for codegen of the target directive on the NVPTX device. Reviewers: ABataev Differential Revision: http://reviews.llvm.org/D17877 llvm-svn: 263552
* Preserve ExtParameterInfos into CGFunctionInfo.John McCall2016-03-111-26/+11
| | | | | | | | | As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
* Reapply r262741 [OPENMP] Codegen for distribute directiveCarlo Bertolli2016-03-071-35/+87
| | | | | | | | This patch provide basic implementation of codegen for teams directive, excluding all clauses except dist_schedule. It also fixes parts of AST reader/writer to enable correct pre-compiled header handling. http://reviews.llvm.org/D17170 llvm-svn: 262832
* Revert r262741 - [OPENMP] Codegen for distribute directiveSamuel Antao2016-03-041-87/+35
| | | | | | Was causing a failure in one of the buildbot slaves. llvm-svn: 262744
* [OPENMP] Codegen for distribute directiveCarlo Bertolli2016-03-041-35/+87
| | | | | | | | This patch provide basic implementation of codegen for teams directive, excluding all clauses except dist_schedule. It also fixes parts of AST reader/writer to enable correct pre-compiled header handling. http://reviews.llvm.org/D17170 llvm-svn: 262741
* [OPENMP 4.0] Codegen for 'declare reduction' construct.Alexey Bataev2016-03-041-2/+83
| | | | | | | Emit function for 'combiner' part of 'declare reduction' construct and 'initialilzer' part, if any. llvm-svn: 262699
* Add code generation for teams directive inside target regionCarlo Bertolli2016-03-031-1/+67
| | | | llvm-svn: 262652
* [OpenMP] Code generation for teams - kernel launchingSamuel Antao2016-03-031-6/+211
| | | | | | | | | | | | | | | Summary: This patch implements the launching of a target region in the presence of a nested teams region, i.e calls tgt_target_teams with the required arguments gathered from the enclosed teams directive. The actual codegen of the region enclosed by the teams construct will be contributed in a separate patch. Reviewers: hfinkel, arpith-jacob, kkwli0, carlo.bertolli, ABataev Subscribers: cfe-commits, caomhin, fraggamuffin Differential Revision: http://reviews.llvm.org/D17019 llvm-svn: 262625
* [OPENMP] Improved layout of CGOpenMPRuntime class, NFC.Alexey Bataev2016-02-191-67/+249
| | | | llvm-svn: 261315
* Remove use of builtin comma operator.Richard Trieu2016-02-181-5/+14
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
* [OpenMP] Rename the offload entry points.Samuel Antao2016-02-131-48/+33
| | | | | | | | | | | | | | | Summary: Unlike other outlined regions in OpenMP, offloading entry points have to have be visible (external linkage) for the device side. Using dots in the names of the entries can be therefore problematic for some toolchains, e.g. NVPTX. Also the patch drops the column information in the unique name of the entry points. The parsing of directives ignore unknown tokens, preventing several target regions to be implemented in the same line. Therefore, the line information is sufficient for the name to be unique. Also, the preprocessor printer does not preserve the column information, causing offloading-entry detection issues if the host uses an integrated preprocessor and the target doesn't (or vice versa). Reviewers: hfinkel, arpith-jacob, carlo.bertolli, kkwli0, ABataev Subscribers: cfe-commits, fraggamuffin, caomhin Differential Revision: http://reviews.llvm.org/D17179 llvm-svn: 260837
* Fix some Clang-tidy readability-redundant-control-flow warnings; other minor ↵Eugene Zelenko2016-02-101-9/+10
| | | | | | | | fixes. Differential revision: http://reviews.llvm.org/D17060 llvm-svn: 260414
* [OPENMP 4.0] Fixed support of array sections/array subscripts.Alexey Bataev2016-02-041-19/+14
| | | | | | Codegen for array sections/array subscripts worked only for expressions with arrays as base. Patch fixes codegen for bases with pointer/reference types. llvm-svn: 259776
* Move DebugInfoKind into its own header to cut the cyclic dependency edge ↵Benjamin Kramer2016-02-021-1/+1
| | | | | | from Driver to Frontend. llvm-svn: 259489
* Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes.Eugene Zelenko2016-01-261-4/+5
| | | | | | Differential revision: http://reviews.llvm.org/D16567 llvm-svn: 258836
* [OPENMP 4.5] Allow arrays in 'reduction' clause.Alexey Bataev2016-01-261-44/+21
| | | | | | OpenMP 4.5, alogn with array sections, allows to use variables of array type in reductions. llvm-svn: 258804
* [OPENMP] Generalize codegen for 'sections'-based directive.Alexey Bataev2016-01-221-11/+4
| | | | | | If 'sections' directive has only one sub-section, the code for 'single'-based directive was emitted. Removed this codegen, because it causes crashes in different cases. llvm-svn: 258495
* [OPENMP] Fix crash on reduction for complex variables.Alexey Bataev2016-01-211-7/+9
| | | | | | reworked codegen for reduction operation for complex types to avoid crash llvm-svn: 258394
* [OPENMP 4.0] Fix for codegen of 'cancel' directive within 'sections' directive.Alexey Bataev2016-01-201-2/+0
| | | | | | Allow to emit code for 'cancel' directive within 'sections' directive with single sub-section. llvm-svn: 258307
* Don't store CGOpenMPRegionInfo::CodeGen as a reference (PR26078)Hans Wennborg2016-01-121-1/+1
| | | | | | | The referenced llvm::function_ref<void(CodeGenFunction &)> object can go away before CodeGen is used, resulting in a crash. llvm-svn: 257516
* [OpenMP] Reapply rL256842: [OpenMP] Offloading descriptor registration and ↵Samuel Antao2016-01-061-27/+730
| | | | | | | | | | | | device codegen. This patch attempts to fix the regressions identified when the patch was committed initially. Thanks to Michael Liao for identifying the fix in the offloading metadata generation related with side effects in evaluation of function arguments. llvm-svn: 256933
* [OpenMP] Revert rL256842: [OpenMP] Offloading descriptor registration and ↵Samuel Antao2016-01-051-731/+27
| | | | | | | | device codegen. It was causing two regression, so I'm reverting until the cause is found. llvm-svn: 256858
* [OpenMP] Offloading descriptor registration and device codegen.Samuel Antao2016-01-051-27/+731
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In order to offloading work properly two things need to be in place: - a descriptor with all the offloading information (device entry functions, and global variable) has to be created by the host and registered in the OpenMP offloading runtime library. - all the device functions need to be emitted for the device and a convention has to be in place so that the runtime library can easily map the host ID of an entry point with the actual function in the device. This patch adds support for these two things. However, only entry functions are being registered given that 'declare target' directive is not yet implemented. About offloading descriptor: The details of the descriptor are explained with more detail in http://goo.gl/L1rnKJ. Basically the descriptor will have fields that specify the number of devices, the pointers to where the device images begin and end (that will be defined by the linker), and also pointers to a the begin and end of table whose entries contain information about a specific entry point. Each entry has the type: ``` struct __tgt_offload_entry{ void *addr; char *name; int64_t size; }; ``` and will be implemented in a pre determined (ELF) section `.omp_offloading.entries` with 1-byte alignment, so that when all the objects are linked, the table is in that section with no padding in between entries (will be like a C array). The code generation ensures that all `__tgt_offload_entry` entries are emitted in the same order for both host and device so that the runtime can have the corresponding entries in both host and device in same index of the table, and efficiently implement the mapping. The resulting descriptor is registered/unregistered with the runtime library using the calls `__tgt_register_lib` and `__tgt_unregister_lib`. The registration is implemented in a high priority global initializer so that the registration happens always before any initializer (that can potentially include target regions) is run. The driver flag -omptargets= was created to specify a comma separated list of devices the user wants to support so that the new functionality can be exercised. Each device is specified with its triple. About target codegen: The target codegen is pretty much straightforward as it reuses completely the logic of the host version for the same target region. The tricky part is to identify the meaningful target regions in the device side. Unlike other programming models, like CUDA, there are no already outlined functions with attributes that mark what should be emitted or not. So, the information on what to emit is passed in the form of metadata in host bc file. This requires a new option to pass the host bc to the device frontend. Then everything is similar to what happens in CUDA: the global declarations emission is intercepted to check to see if it is an "interesting" declaration. The difference is that instead of checking an attribute, the metadata information in checked. Right now, there is only a form of metadata to pass information about the device entry points (target regions). A class `OffloadEntriesInfoManagerTy` was created to manage all the information and queries related with the metadata. The metadata looks like this: ``` !omp_offload.info = !{!0, !1, !2, !3, !4, !5, !6} !0 = !{i32 0, i32 52, i32 77426347, !"_ZN2S12r1Ei", i32 479, i32 13, i32 4} !1 = !{i32 0, i32 52, i32 77426347, !"_ZL7fstatici", i32 461, i32 11, i32 5} !2 = !{i32 0, i32 52, i32 77426347, !"_Z9ftemplateIiET_i", i32 444, i32 11, i32 6} !3 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 99, i32 11, i32 0} !4 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 272, i32 11, i32 3} !5 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 127, i32 11, i32 1} !6 = !{i32 0, i32 52, i32 77426347, !"_Z3fooi", i32 159, i32 11, i32 2} ``` The fields in each metadata entry are (in sequence): Entry 1) an ID of the type of metadata - right now only zero is used meaning "OpenMP target region". Entry 2) a unique ID of the device where the input source file that contain the target region lives. Entry 3) a unique ID of the file where the input source file that contain the target region lives. Entry 4) a mangled name of the function that encloses the target region. Entries 5) and 6) line and column number where the target region was found. Entry 7) is the order the entry was emitted. Entry 2) and 3) are required to distinguish files that have the same function name. Entry 4) is required to distinguish different instances of the same declaration (usually templated ones) Entries 5) and 6) are required to distinguish the particular target region in body of the function (it is possible that a given target region is not an entry point - if clause can evaluate always to zero - and therefore we need to identify the "interesting" target regions. ) This patch replaces http://reviews.llvm.org/D12306. Reviewers: ABataev, hfinkel, tra, rjmccall, sfantao Subscribers: FBrygidyn, piotr.rak, Hahnfeld, cfe-commits Differential Revision: http://reviews.llvm.org/D12614 llvm-svn: 256842
* [OPENMP 4.5] Parsing/sema for 'depend(sink:vec)' clause in 'ordered' directive.Alexey Bataev2015-12-231-0/+1
| | | | | | OpenMP 4.5 adds 'depend(sink:vec)' in 'ordered' directive for doacross loop synchronization. Patch adds parsing and semantic analysis for this clause. llvm-svn: 256330
* [OPENMP] Revert r256238 to fix the problem with tests on Linux.Alexey Bataev2015-12-221-1/+0
| | | | llvm-svn: 256239
* [OPENMP 4.5] Parsing/sema for 'depend(sink:vec)' clause in 'ordered' directive.Alexey Bataev2015-12-221-0/+1
| | | | | | OpenMP 4.5 adds 'depend(sink:vec)' in 'ordered' directive for doacross loop synchronization. Patch adds parsing and semantic analysis for this clause. llvm-svn: 256238
* [OPENMP] Fix for http://llvm.org/PR25878: Error compiling an OpenMP programAlexey Bataev2015-12-181-0/+48
| | | | | | OpenMP codegen tried to emit the code for its constructs even if it was detected as a dead-code. Added checks to ensure that the code is emitted if the code is not dead. llvm-svn: 255990
* [OPENMP 4.5] Parsing/sema analysis for 'depend(source)' clause in 'ordered' ↵Alexey Bataev2015-12-181-0/+1
| | | | | | | | directive. OpenMP 4.5 adds 'depend(source)' clause for 'ordered' directive to support cross-iteration dependence. Patch adds parsing and semantic analysis for this construct. llvm-svn: 255986
* [OPENMP 4.5] Codegen for 'hint' clause of 'critical' directiveAlexey Bataev2015-12-151-12/+30
| | | | | | OpenMP 4.5 defines 'hint' clause for 'critical' directive. Patch adds codegen for this clause. llvm-svn: 255639
* [OpenMP] Update target directive codegen to use 4.5 implicit data mappings.Samuel Antao2015-12-021-22/+74
| | | | | | | | | | | | | | | Summary: This patch implements the 4.5 specification for the implicit data maps. OpenMP 4.5 specification changes the default way data is captured into a target region. All the non-aggregate kinds are passed by value by default. This required activating the capturing by value during SEMA for the target region. All the non-aggregate values that can be encoded in the size of a pointer are properly casted and forwarded to the runtime library. On top of fixing the previous weird behavior for mapping pointers in nested data regions (an explicit map was always required), this also improves performance as the number of allocations/transactions to the device per non-aggregate map are reduced from two to only one - instead of passing a reference and the value, only the value passed. Explicit maps will be added later on once firstprivate, private, and map clauses' SEMA and parsing are available. Reviewers: hfinkel, rjmccall, ABataev Subscribers: cfe-commits, carlo.bertolli Differential Revision: http://reviews.llvm.org/D14940 llvm-svn: 254521
* [OPENMP] Fix crash on codegen for 'task' directive with no shared variables.Alexey Bataev2015-11-241-1/+1
| | | | | | If 'task' region does not have shared variables codegen could crash on calculation of size of list of shared variables. llvm-svn: 253977
* [OPENMP] 'out' dependency for 'task' directives must be the same as 'inout'.Alexey Bataev2015-11-231-3/+2
| | | | | | Runtime library requires, that codegen for 'depend' clause for 'out' dependency kind must be the same as codegen for 'depend' clause with 'inout' dependency. llvm-svn: 253866
* [CodeGen] Call SetInternalFunctionAttributes to attach functionAkira Hatanaka2015-10-311-3/+4
| | | | | | | | | | | | | | | | | attributes to internal functions. This patch fixes CodeGenModule::CreateGlobalInitOrDestructFunction to use SetInternalFunctionAttributes instead of SetLLVMFunctionAttributes to attach function attributes to internal functions. Also, make sure the correct CGFunctionInfo is passed instead of always passing what arrangeNullaryFunction returns. rdar://problem/20828324 Differential Revision: http://reviews.llvm.org/D13610 llvm-svn: 251734
* Put global classes into the appropriate namespace.Benjamin Kramer2015-10-281-1/+1
| | | | | | | Most of the cases belong into an anonymous namespace. No functionality change intended. llvm-svn: 251514
* [CodeGen] Attach function attributes to Objective-C and OpenMPAkira Hatanaka2015-10-281-6/+7
| | | | | | | | | | | | | | functions. This commit fixes a bug in CGOpenMPRuntime.cpp and CGObjC.cpp where some of the function attributes are not attached to newly created functions. rdar://problem/20828324 Differential Revision: http://reviews.llvm.org/D13928 llvm-svn: 251476
* [OPENMP 4.1] Codegen for array sections/subscripts in 'reduction' clause.Alexey Bataev2015-10-081-103/+280
| | | | | | OpenMP 4.1 adds support for array sections/subscripts in 'reduction' clause. Patch adds codegen for this feature. llvm-svn: 249672
* [OpenMP] Target directive host codegen.Samuel Antao2015-10-021-0/+303
| | | | | | | | | | | This patch implements the outlining for offloading functions for code annotated with the OpenMP target directive. It uses a temporary naming of the outlined functions that will have to be updated later on once target side codegen and registration of offloading libraries is implemented - the naming needs to be made unique in the produced library. llvm-svn: 249148
* Remove 'const' from some ArrayRef arguments since they're passed by value ↵Craig Topper2015-09-291-6/+5
| | | | | | anyway. NFC llvm-svn: 248774
* [OPENMP 4.1] Codegen for ‘simd’ clause in ‘ordered’ directive.Alexey Bataev2015-09-291-4/+4
| | | | | | | | | | | Description. If the simd clause is specified, the ordered regions encountered by any thread will use only a single SIMD lane to execute the ordered regions in the order of the loop iterations. Restrictions. An ordered construct with the simd clause is the only OpenMP construct that can appear in the simd region. An ordered directive with ‘simd’ clause is generated as an outlined function and corresponding function call to prevent this part of code from vectorization later in backend. llvm-svn: 248772
* [OPENMP 4.0] Add 'if' clause for 'cancel' directive.Alexey Bataev2015-09-181-22/+30
| | | | | | Add parsing, sema analysis and codegen for 'if' clause in 'cancel' directive. llvm-svn: 247976
* [OPENMP] Emit __kmpc_cancel_barrier() and code for 'cancellation point' only ↵Alexey Bataev2015-09-151-51/+75
| | | | | | | | | | | | | | if 'cancel' is found. Patch improves codegen for OpenMP constructs. If the OpenMP region does not have internal 'cancel' construct, a call to 'void __kmpc_barrier()' runtime function is generated for all implicit/explicit barriers. If the region has inner 'cancel' directive, then ``` if (__kmpc_cancel_barrier()) exit from outer construct; ``` code is generated. Also, the code for 'canellation point' directive is not generated if parent directive does not have 'cancel' directive. llvm-svn: 247681
* Revert "Always_inline codegen rewrite" and 2 follow-ups.Evgeniy Stepanov2015-09-141-1/+1
| | | | | | | | | | Revert "Update cxx-irgen.cpp test to allow signext in alwaysinline functions." Revert "[CodeGen] Remove wrapper-free always_inline functions from COMDATs" Revert "Always_inline codegen rewrite." Reason for revert: PR24793. llvm-svn: 247620
* Always_inline codegen rewrite.Evgeniy Stepanov2015-09-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current implementation may end up emitting an undefined reference for an "inline __attribute__((always_inline))" function by generating an "available_externally alwaysinline" IR function for it and then failing to inline all the calls. This happens when a call to such function is in dead code. As the inliner is an SCC pass, it does not process dead code. Libc++ relies on the compiler never emitting such undefined reference. With this patch, we emit a pair of 1. internal alwaysinline definition (called F.alwaysinline) 2a. A stub F() { musttail call F.alwaysinline } -- or, depending on the linkage -- 2b. A declaration of F. The frontend ensures that F.inlinefunction is only used for direct calls, and the stub is used for everything else (taking the address of the function, really). Declaration (2b) is emitted in the case when "inline" is meant for inlining only (like __gnu_inline__ and some other cases). This approach, among other nice properties, ensures that alwaysinline functions are always internal, making it impossible for a direct call to such function to produce an undefined symbol reference. This patch is based on ideas by Chandler Carruth and Richard Smith. llvm-svn: 247494
* Revert "Specify target triple in alwaysinline tests."Evgeniy Stepanov2015-09-111-1/+1
| | | | | | | | | Revert "Always_inline codegen rewrite." Breaks gdb & lldb tests. Breaks on Fedora 22 x86_64. llvm-svn: 247491
* Always_inline codegen rewrite.Evgeniy Stepanov2015-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current implementation may end up emitting an undefined reference for an "inline __attribute__((always_inline))" function by generating an "available_externally alwaysinline" IR function for it and then failing to inline all the calls. This happens when a call to such function is in dead code. As the inliner is an SCC pass, it does not process dead code. Libc++ relies on the compiler never emitting such undefined reference. With this patch, we emit a pair of 1. internal alwaysinline definition (called F.alwaysinline) 2a. A stub F() { musttail call F.alwaysinline } -- or, depending on the linkage -- 2b. A declaration of F. The frontend ensures that F.inlinefunction is only used for direct calls, and the stub is used for everything else (taking the address of the function, really). Declaration (2b) is emitted in the case when "inline" is meant for inlining only (like __gnu_inline__ and some other cases). This approach, among other nice properties, ensures that alwaysinline functions are always internal, making it impossible for a direct call to such function to produce an undefined symbol reference. This patch is based on ideas by Chandler Carruth and Richard Smith. llvm-svn: 247465
OpenPOWER on IntegriCloud