summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert 241171, 241187, 241199 (32-bit SEH).Nico Weber2015-07-021-20/+8
| | | | | | | It still doesn't produce quite the right code, test binaries built with this enabled fail some tests. llvm-svn: 241244
* [OPENMP 4.0] Codegen for 'cancellation point' directive.Alexey Bataev2015-07-021-1/+3
| | | | | | | | | | The next code is generated for this construct: ``` if (__kmpc_cancellationpoint(ident_t *loc, kmp_int32 global_tid, kmp_int32 cncl_kind) != 0) <exit from outer innermost construct>; ``` llvm-svn: 241239
* [SEH] Delete the 32-bit IR lowering for __finally blocks and use x64Reid Kleckner2015-07-011-8/+0
| | | | | | | | | | | | | | | | 32-bit finally funclets are intended to be called both directly from the parent function and indirectly from the EH runtime. Because we aren't contorting LLVM's X86 prologue to match MSVC's, calling the finally block directly passes in a different value of EBP than the one that the runtime provides. We need an adapter thunk to adjust EBP to the expected value. However, WinEHPrepare already has to solve this problem when cleanups are not pre-outlined, so we can go ahead and rely on it rather than duplicating work. Now we only do the llvm.x86.seh.recoverfp dance for 32-bit SEH filter functions. llvm-svn: 241187
* [SEH] Add 32-bit lowering for SEH __tryReid Kleckner2015-07-011-8/+28
| | | | | | | | | | | | | | | | | | | This re-lands r236052 and adds support for __exception_code(). In 32-bit SEH, the exception code is not available in eax. It is only available in the filter function, and now we arrange to load it and store it into an escaped variable in the parent frame. As a consequence, we have to disable the "catch i8* null" optimization on 32-bit and always generate a filter function. We can re-enable the optimization if we detect an __except block that doesn't use the exception code, but this probably isn't worth optimizing. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D10852 llvm-svn: 241171
* [OPENMP 4.0] Initial support for 'omp cancellation point' construct.Alexey Bataev2015-07-011-0/+2
| | | | | | Add parsing and sema analysis for 'omp cancellation point' directive. llvm-svn: 241145
* CodeGen: Resize LifetimeExtendedCleanupHeader to avoid alignment issuesJustin Bogner2015-07-011-4/+6
| | | | | | | | | | | | | The LifetimeExtendedCleanupHeader is carefully fit into 32 bytes, meaning that cleanups on the LifetimeExtendedCleanupStack are *always* allocated at a misaligned address and cause undefined behaviour. There are two ways to solve this - add padding after the header when we allocated our cleanups, or just simplify the header and let it use 64 bits in the first place. I've opted for the latter, and added a static assert to avoid the issue in the future. llvm-svn: 241133
* Fix use-after-free.Peter Collingbourne2015-06-301-2/+3
| | | | llvm-svn: 241121
* [CUDA] Implemented __nvvm_atom_*_gen_* builtins.Artem Belevich2015-06-251-0/+1
| | | | | | | | | | | Integer variants are implemented as atomicrmw or cmpxchg instructions. Atomic add for floating point (__nvvm_atom_add_gen_f()) is implemented as a call to an overloaded @llvm.nvvm.atomic.load.add.f32.* LVVM intrinsic. Differential Revision: http://reviews.llvm.org/D10666 llvm-svn: 240669
* Proper changing/restoring for CapturedStmtInfo, NFC.Alexey Bataev2015-06-241-0/+14
| | | | | | Added special RAII class for proper values changing/restoring in CodeGenFunction::CapturedStmtInfo. llvm-svn: 240517
* AMDGPU: Fix places missed in renameMatt Arsenault2015-06-191-1/+1
| | | | llvm-svn: 240148
* Implement diagnostic mode for -fsanitize=cfi*, -fsanitize=cfi-diag.Peter Collingbourne2015-06-191-3/+13
| | | | | | | | | | | | | | | | | This causes programs compiled with this flag to print a diagnostic when a control flow integrity check fails instead of aborting. Diagnostics are printed using UBSan's runtime library. The main motivation of this feature over -fsanitize=vptr is fidelity with the -fsanitize=cfi implementation: the diagnostics are printed under exactly the same conditions as those which would cause -fsanitize=cfi to abort the program. This means that the same restrictions apply regarding compiling all translation units with -fsanitize=cfi, cross-DSO virtual calls are forbidden, etc. Differential Revision: http://reviews.llvm.org/D10268 llvm-svn: 240109
* [OPENMP] Support for '#pragma omp taskgroup' directive.Alexey Bataev2015-06-181-0/+1
| | | | | | | | | | | | | Added parsing, sema analysis and codegen for '#pragma omp taskgroup' directive (OpenMP 4.0). The code for directive is generated the following way: #pragma omp taskgroup <body> void __kmpc_taskgroup(<loc>, thread_id); <body> void __kmpc_end_taskgroup(<loc>, thread_id); llvm-svn: 240011
* [OPENMP] Add support for 'omp parallel for' directive.Alexey Bataev2015-06-181-0/+5
| | | | | | Codegen for this directive is a combined codegen for 'omp parallel' region with 'omp for simd' region inside. Clauses are supported. llvm-svn: 240006
* [OPENMP] Add support for 'omp for simd' directive.Alexey Bataev2015-06-181-1/+3
| | | | | | Added codegen for combined 'omp for simd' directives, that is a combination of 'omp for' directive followed by 'omp simd' directive. Includes support for all clauses. llvm-svn: 239990
* [OPENMP] Code reformatting for omp simd codegen, NFC.Alexey Bataev2015-06-171-1/+0
| | | | llvm-svn: 239889
* [OPENMP] Support lastprivate clause in omp simd directive.Alexey Bataev2015-06-161-2/+2
| | | | | | Added codegen for lastprivate clauses within simd loop-based directives. llvm-svn: 239813
* [OPENMP] Remove last iteration separation for loop-based constructs.Alexey Bataev2015-06-161-2/+1
| | | | | | Previously the last iteration for simd loop-based OpenMP constructs were generated as a separate code. This feature is not required and codegen is simplified. llvm-svn: 239810
* Revert "Re-land r236052, "[SEH] Add 32-bit lowering code for __try""Reid Kleckner2015-06-091-17/+3
| | | | | | | This reverts commit r239415. This was committed accidentally, LLVM isn't ready for this. llvm-svn: 239417
* Re-land r236052, "[SEH] Add 32-bit lowering code for __try"Reid Kleckner2015-06-091-3/+17
| | | | | | | | This reverts r236167. LLVM should be ready for this now. llvm-svn: 239415
* ubsan: Check for null pointers given to certain builtins, suchNuno Lopes2015-05-301-0/+5
| | | | | | | | | | as memcpy, memset, memmove, and bzero. Reviewed by: Richard Smith Differential Revision: http://reviews.llvm.org/D9673 llvm-svn: 238657
* wip: Remove some unused functionsJustin Bogner2015-05-291-7/+0
| | | | llvm-svn: 238538
* [OPENMP] Fix codegen for ordered loop directives.Alexey Bataev2015-05-201-3/+3
| | | | | | loops with ordered clause must be generated the same way as dynamic loops, but with static scheduleing. llvm-svn: 237788
* [OPENMP] Fixed bug in atomic update/capture/write constructs.Alexey Bataev2015-05-151-1/+1
| | | | | | Fixed a bug with codegen for destination atomic l-value with padding and junk in this padding bytes. llvm-svn: 237422
* Unify sanitizer kind representation between the driver and the rest of the ↵Peter Collingbourne2015-05-111-1/+1
| | | | | | | | | | compiler. No functional change. Differential Revision: http://reviews.llvm.org/D9618 llvm-svn: 237055
* InstrProf: Cede ownership of createProfileWeights to CGFJustin Bogner2015-05-021-0/+6
| | | | | | | | The fact that PGO has a say in how these branch weights are determined isn't interesting to most of CodeGen, so it makes more sense for this API to be accessible via CodeGenFunction rather than CodeGenPGO. llvm-svn: 236380
* Revert most of r236271, leaving only the datalayout change in ↵Reid Kleckner2015-04-301-17/+3
| | | | | | lib/Basic/Targets.cpp llvm-svn: 236274
* Use 4 byte preferred aggregate alignment in datalayout on x86 Win32Reid Kleckner2015-04-301-3/+17
| | | | llvm-svn: 236271
* Revert r236128, LLVM isn't falling back in the right wayReid Kleckner2015-04-291-17/+3
| | | | llvm-svn: 236167
* Re-land r236052, the linker errors were fixed by LLVM r236123Reid Kleckner2015-04-291-3/+17
| | | | | | | Basic __finally blocks don't cause linker errors anymore (although they are miscompiled). llvm-svn: 236128
* Revert r236052, it caused linker errors when building 32-bit applications.Nico Weber2015-04-291-17/+3
| | | | llvm-svn: 236082
* [SEH] Add 32-bit lowering code for __tryReid Kleckner2015-04-281-3/+17
| | | | | | | | | | | | | | | | | | | | This is just the clang-side of 32-bit SEH. LLVM still needs work, and it will determinstically fail to compile until it's feature complete. On x86, all outlined handlers have no parameters, but they do implicitly take the EBP value passed in and use it to address locals of the parent frame. We model this with llvm.frameaddress(1). This works (mostly), but __finally block inlining can break it. For now, we apply the 'noinline' attribute. If we really want to inline __finally blocks on 32-bit x86, we should teach the inliner how to untangle frameescape and framerecover. Promote the error diagnostic from codegen to sema. It now rejects SEH on non-Windows platforms. LLVM doesn't implement SEH on non-x86 Windows platforms, but there's nothing preventing it. llvm-svn: 236052
* InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)Justin Bogner2015-04-231-7/+27
| | | | | | | | | The RegionCounter type does a lot of legwork, but most of it is only meaningful within the implementation of CodeGenPGO. The uses elsewhere in CodeGen generally just want to increment or read counters, so do that directly. llvm-svn: 235664
* [OPENMP] Codegen for 'atomic capture'.Alexey Bataev2015-04-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds codegen for 'atomic capture' constructs with the following forms of expressions/statements: v = x binop= expr; v = x++; v = ++x; v = x--; v = --x; v = x = x binop expr; v = x = expr binop x; {v = x; x = binop= expr;} {v = x; x++;} {v = x; ++x;} {v = x; x--;} {v = x; --x;} {x = x binop expr; v = x;} {x binop= expr; v = x;} {x++; v = x;} {++x; v = x;} {x--; v = x;} {--x; v = x;} {x = x binop expr; v = x;} {x = expr binop x; v = x;} {v = x; x = expr;} If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted. Update of 'v' is not required to be be atomic with respect to the read or write of the 'x'. bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: atomic store <old/new x>, <v> ... Differential Revision: http://reviews.llvm.org/D9049 llvm-svn: 235573
* Revert "Revert r234581, it might have caused a few miscompiles in Chromium."David Majnemer2015-04-221-0/+3
| | | | | | | | This reverts commit r234700. It turns out that the lifetime markers were not the cause of Chromium failing but a bug which was uncovered by optimizations exposed by the markers. llvm-svn: 235553
* [OPENMP] Codegen for 'ordered' directive.Alexey Bataev2015-04-221-4/+15
| | | | | | | | | | | | | | | | | | | Add codegen for 'ordered' directive: __kmpc_ordered(ident_t *, gtid); <associated statement>; __kmpc_end_ordered(ident_t *, gtid); Also for 'for' directives with the dynamic scheduling and an 'ordered' clause added a call to '__kmpc_dispatch_fini_(4|8)[u]()' function after increment expression for loop control variable: while(__kmpc_dispatch_next(&LB, &UB)) { idx = LB; while (idx <= UB) { BODY; ++idx; __kmpc_dispatch_fini_(4|8)[u](); // For ordered loops only. } // inner loop } Differential Revision: http://reviews.llvm.org/D9070 llvm-svn: 235496
* [OPENMP] Codegen for 'copyin' clause in 'parallel' directive.Alexey Bataev2015-04-161-0/+12
| | | | | | | | | | | | | | | Emits the following code for the clause at the beginning of the outlined function for implicit threads: if (<not a master thread>) { ... <thread local copy of var> = <master thread local copy of var>; ... } <sync point>; Checking for a non-master thread is performed by comparing of the address of the thread local variable with the address of the master's variable. Master thread always uses original variables, so you always know the address of the variable in the master thread. Differential Revision: http://reviews.llvm.org/D9026 llvm-svn: 235075
* [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.Alexey Bataev2015-04-161-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp for lastprivate(<var>) for (i = a; i < b; ++b) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <lastprivate_var> = alloca <type> <last_iter> = 0 ; No initializer for simple variables or a default constructor is called for objects. ; For arrays perform element by element initialization by the call of the default constructor. ... OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration. <BODY> ... OMP_FOR_END if (<last_iter> != 0) { <var> = <lastprivate_var> ; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. Differential Revision: http://reviews.llvm.org/D8658 llvm-svn: 235074
* [OPENMP] Codegen for 'firstprivate' clause in 'for' directive.Alexey Bataev2015-04-151-1/+1
| | | | | | | | Adds proper codegen for 'firstprivate' clause in for directive. Initially codegen for 'firstprivate' clause was implemented for 'parallel' directive only. Also this patch emits sync point only after initialization of firstprivate variables, not all private variables. This sync point is not required for privates, lastprivates etc., only for initialization of firstprivate variables. Differential Revision: http://reviews.llvm.org/D8660 llvm-svn: 234978
* Reland r234613 (and follow-ups 234614, 234616, 234618)Reid Kleckner2015-04-141-17/+13
| | | | | | | The frameescape intrinsic cannot be inlined, so I fixed the inliner in r234937. This should address PR23216. llvm-svn: 234942
* [OPENMP] Fixed codegen for arrays in 'copyprivate' clause.Alexey Bataev2015-04-141-3/+27
| | | | | | | Fixed a bug with codegen of variables with array types specified in 'copyprivate' clause of 'single' directive. Differential Revision: http://reviews.llvm.org/D8914 llvm-svn: 234856
* [OPENMP] Initial codegen for 'parallel sections' directive.Alexey Bataev2015-04-141-4/+5
| | | | | | | | | | | | | | | Emits code for outlined 'parallel' directive with the implicitly inlined 'sections' directive: ... call __kmpc_fork_call(..., outlined_function, ...); ... define internal void outlined_function(...) { <code for implicit sections directive>; } Differential Revision: http://reviews.llvm.org/D8997 llvm-svn: 234849
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-13/+17
| | | | llvm-svn: 234789
* Revert r234786, it contained a bunch of stuff I did not mean to commit.Nico Weber2015-04-131-17/+13
| | | | llvm-svn: 234787
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-13/+17
| | | | llvm-svn: 234786
* Revert r234581, it might have caused a few miscompiles in Chromium.Nico Weber2015-04-111-3/+0
| | | | | | | If the revert helps, I'll get a repro this Monday. Else I'll put the change back in. llvm-svn: 234700
* [SEH] Re-land r234532, but use internal linkage for all SEH helpersReid Kleckner2015-04-101-17/+13
| | | | | | | | | | Even though these symbols are in a comdat group, the Microsoft linker really wants them to have internal linkage. I'm planning to tweak the mangling in a follow-up change. This is a straight revert with a 1-line fix. llvm-svn: 234613
* [OPENMP] Codegen for 'reduction' clause in 'parallel' directive.Alexey Bataev2015-04-101-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { ... *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]); ... } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: ... <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]); ... __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: ... Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i])); ... break; default: ; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D8915 llvm-svn: 234583
* Remove threshold for inserting lifetime markers for named temporariesArnaud A. de Grandmaison2015-04-101-0/+3
| | | | | | | | | | | | | | | | | | | Now that TailRecursionElimination has been fixed with r222354, the threshold on size for lifetime marker insertion can be removed. This only affects named temporary though, as the patch for unnamed temporaries is still in progress. My previous commit (r222993) was not handling debuginfo correctly, but this could only be seen with some asan tests. Basically, lifetime markers are just instrumentation for the compiler's usage and should not affect debug information; however, the cleanup infrastructure was assuming it contained only destructors, i.e. actual code to be executed, and was setting the breakpoint for the end of the function to the closing '}', and not the return statement, in order to show some destructors have been called when leaving the function. This is wrong when the cleanups are only lifetime markers, and this is now fixed. llvm-svn: 234581
* [OPENMP] Refactoring of codegen for OpenMP directives.Alexey Bataev2015-04-101-4/+5
| | | | | | | Refactored API of OpenMPRuntime for compatibility with combined directives. Differential Revision: http://reviews.llvm.org/D8859 llvm-svn: 234564
* Revert r234532 for a bit, it very likely caused http://crbug.com/475768Nico Weber2015-04-101-13/+17
| | | | llvm-svn: 234563
OpenPOWER on IntegriCloud