summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* InstrProf: Cede ownership of createProfileWeights to CGFJustin Bogner2015-05-026-26/+28
| | | | | | | | 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
* Fix -fobjc-arc doesn't work with -save-tempsSteven Wu2015-05-021-2/+1
| | | | | | | | | | The underlying problem is that there is currently no way to run ObjCARCContract from llvm bitcode which is required by ObjC ARC. This fix the problem by always enable ObjCARCContract pass if optimization is enabled. The ObjCARC Contract pass has almost no overhead on code that is not using ARC. llvm-svn: 236372
* InstrProf: Use a locally tracked current count in ComputeRegionCountsJustin Bogner2015-05-022-38/+35
| | | | | | | | No functional change. This just makes it more obvious that the logic in ComputeRegionCounts only depends on the counter map and local state. llvm-svn: 236370
* InstrProf: Replace the RegionCounter class with a simpler direct approachJustin Bogner2015-05-012-203/+111
| | | | | | | | | This removes the RegionCounter class, which is only used as a helper in teh ComputeRegionCounts stmt visitor. This class is just an extra layer of abstraction that makes the code harder to follow at this point, and removing it makes the logic quite a bit more direct. llvm-svn: 236364
* InstrProf: Fix a coverage crash where a macro begins in an unreachable blockJustin Bogner2015-05-011-1/+4
| | | | llvm-svn: 236335
* Make helper functions static. NFC.Benjamin Kramer2015-05-012-9/+9
| | | | llvm-svn: 236315
* InstrProf: This call does nothing, remove itJustin Bogner2015-05-011-1/+0
| | | | llvm-svn: 236298
* InstrProf: Support for setting profile output from command lineJustin Bogner2015-04-301-0/+1
| | | | | | | | | | | | | | | | This change is the third of 3 patches to add support for specifying the profile output from the command line via -fprofile-instr-generate=<path>, where the specified output path/file will be overridden by the LLVM_PROFILE_FILE environment variable. This patch adds the necessary support to the clang frontend, and adds a new test. The compiler-rt and llvm parts are r236055 and r236288, respectively. Patch by Teresa Johnson. Thanks! llvm-svn: 236289
* Fix -Wpessimizing-move by removing call to std::moveRichard Trieu2015-04-301-1/+1
| | | | llvm-svn: 236281
* InstrProf: Fix handling of profile counters in the body of range based forJustin Bogner2015-04-301-3/+2
| | | | | | | | | We were assigning the counter for the body of the loop to the loop variable initialization for some reason here, but our tests completely lacked coverage for range-for loops. This fixes that and makes the logic generally more similar to the logic for a regular for. llvm-svn: 236277
* Revert most of r236271, leaving only the datalayout change in ↵Reid Kleckner2015-04-303-174/+93
| | | | | | lib/Basic/Targets.cpp llvm-svn: 236274
* Use 4 byte preferred aggregate alignment in datalayout on x86 Win32Reid Kleckner2015-04-303-93/+174
| | | | llvm-svn: 236271
* InstrProf: Make sure coverage propagates out of foreach loops correctlyJustin Bogner2015-04-301-4/+8
| | | | llvm-svn: 236264
* [OPENMP] Codegen for 'private' clause in 'task' directive.Alexey Bataev2015-04-303-29/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For tasks codegen for private/firstprivate variables are different rather than for other directives. 1. Build an internal structure of privates for each private variable: struct .kmp_privates_t. { Ty1 var1; ... Tyn varn; }; 2. Add a new field to kmp_task_t type with list of privates. struct kmp_task_t { void * shareds; kmp_routine_entry_t routine; kmp_int32 part_id; kmp_routine_entry_t destructors; .kmp_privates_t. privates; }; 3. Create a function with destructors calls for all privates after end of task region. kmp_int32 .omp_task_destructor.(kmp_int32 gtid, kmp_task_t *tt) { ~Destructor(&tt->privates.var1); ... ~Destructor(&tt->privates.varn); return 0; } 4. Perform default initialization of all private fields (no initialization for POD data, default constructor calls for classes) + provide address of a destructor function after kmpc_omp_task_alloc() and before kmpc_omp_task() calls. kmp_task_t *new_task = __kmpc_omp_task_alloc(ident_t *, kmp_int32 gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds, kmp_routine_entry_t *task_entry); DefaultConstructor(new_task->privates.var1); new_task->shareds.var1_ref = &new_task->privates.var1; ... DefaultConstructor(new_task->privates.varn); new_task->shareds.varn_ref = &new_task->privates.varn; new_task->destructors = .omp_task_destructor.; kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid, kmp_task_t *new_task) Differential Revision: http://reviews.llvm.org/D9322 llvm-svn: 236207
* [OPENMP] Fixed codegen for 'copyprivate' clause.Alexey Bataev2015-04-302-7/+8
| | | | | | Fixed initialization of 'single' region completion + changed type of the third argument of __kmpc_copyprivate() runtime function to size_t. llvm-svn: 236198
* Revert r236128, LLVM isn't falling back in the right wayReid Kleckner2015-04-293-174/+93
| | | | llvm-svn: 236167
* [opaque pointer type] update for LLVM API changeDavid Blaikie2015-04-295-11/+10
| | | | llvm-svn: 236161
* PR23373: A defaulted union copy constructor that is not trivial must still beRichard Smith2015-04-293-27/+40
| | | | | | emitted as a memcpy. llvm-svn: 236142
* Re-land r236052, the linker errors were fixed by LLVM r236123Reid Kleckner2015-04-293-93/+174
| | | | | | | Basic __finally blocks don't cause linker errors anymore (although they are miscompiled). llvm-svn: 236128
* Debug Info: Represent local anonymous unions as anonymous unionsAdrian Prantl2015-04-291-2/+9
| | | | | | | | | | | | | | | | and as artificial local variables in the debug info. This is a follow-up to r236059. We can't get rid of the local variables entirely because the gdb buildbot depends on them, but we can mark them as artificial while still emitting the correct debug info. As I learned from review comments other compilers also follow this model. A paired commit in LLVM temporarily relaxes the debug info verifier to not check the integrity of DW_OP_bit_pieces of artificial variables. rdar://problem/20730771 llvm-svn: 236125
* DebugInfo: Metadata constructs now start with DI*Duncan P. N. Exon Smith2015-04-292-400/+399
| | | | | | | | | | LLVM r236120 renamed debug info IR constructs to use a `DI` prefix, now that the `DIDescriptor` hierarchy has been gone for about a week. This commit was generated using the rename-md-di-nodes.sh upgrade script attached to PR23080, followed by running clang-format-diff.py on the `lib/` portion of the patch. llvm-svn: 236121
* Revert "Debug Info: Represent local anonymous unions as anonymous unions"Adrian Prantl2015-04-291-0/+25
| | | | | | This reverts commit r236059 as it breaks the gdb buildbot. llvm-svn: 236110
* Revert code changes made under r235976.Bradley Smith2015-04-291-17/+0
| | | | | | | | This issue was fixed elsewhere in r235396 in a more general way, hence these changes no longer do anything. Keep the testcase however, to ensure that we don't regress this for ARM. llvm-svn: 236104
* [OPENMP] Fix crash on reductions codegen for short circuit reduction operations.Alexey Bataev2015-04-291-2/+2
| | | | llvm-svn: 236084
* Revert r236052, it caused linker errors when building 32-bit applications.Nico Weber2015-04-293-174/+93
| | | | llvm-svn: 236082
* Debug Info: Represent local anonymous unions as anonymous unionsAdrian Prantl2015-04-281-25/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the debug info. This patch deletes a hack that emits the members of local anonymous unions as local variables. Besides being morally wrong, the existing representation using local variables breaks internal assumptions about the local variables' storage size. Compiling ``` void fn1() { union { int i; char c; }; i = c; } ``` with -g -O3 -verify will cause the verifier to fail after SROA splits the 32-bit storage for the "local variable" c into two pieces because the second piece is clearly outside the 8-bit range that is expected for a variable of type char. Given the choice I'd rather fix the debug representation than weaken the verifier. Debuggers generally already know how to deal with anonymous unions when they are members of C++ record types, but they may have problems finding the local anonymous struct members in the expression evaluator. rdar://problem/20730771 llvm-svn: 236059
* [SEH] Add 32-bit lowering code for __tryReid Kleckner2015-04-283-93/+174
| | | | | | | | | | | | | | | | | | | | 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
* Implemented support for testing the ASTImporter'sSean Callanan2015-04-281-0/+5
| | | | | | | | | ability to generate code that CodeGen likes. Test cases can use this functionality by calling // RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s llvm-svn: 236011
* Fix typo in comment.Nico Weber2015-04-281-1/+1
| | | | llvm-svn: 236010
* [OPENMP] Fix crash on loop control vars explicitly marked as private.Alexey Bataev2015-04-281-4/+1
| | | | | | It is allowed to mark loop control vars as private in 'private' or 'lastprivate' clause, so no need to assert here. llvm-svn: 235985
* [ARM/AArch64] Enforce alignment for bitfielded structsBradley Smith2015-04-281-0/+17
| | | | | | | | | When creating a global variable with a type of a struct with bitfields, we must forcibly set the alignment of the global from the RecordDecl. We must do this so that the proper bitfield alignment makes its way down to LLVM, since clang will mangle the bitfields into one large type. llvm-svn: 235976
* InstrProf: Mark code regions after throw expressions as unreachableJustin Bogner2015-04-282-0/+15
| | | | | | | We weren't setting regions as being unreachable after C++ throw expressions, leading to incorrect count propagations. llvm-svn: 235967
* ms_struct does not imply the MS base-layout ABI; separate theseJohn McCall2015-04-281-6/+23
| | | | | | | | conditions in the IRGen struct layout code. rdar://20636558 llvm-svn: 235949
* Always add the target-cpu and target-features sets if they're non-null.Eric Christopher2015-04-271-9/+9
| | | | | | | | This makes sure that the front end is specific about what they're expecting the backend to produce. Update a FIXME with the idea that the target-features could be more precise using backend knowledge. llvm-svn: 235936
* [cuda] treat file scope __asm as __host__ and ignore it during device-side ↵Artem Belevich2015-04-271-0/+3
| | | | | | | | | | | | | | | | compilation. Currently clang emits file-scope asm during *both* host and device compilation modes which is usually a wrong thing to do. There's no way to attach any attribute to an __asm statement, so there's no way to differentiate between host-side and device-side file-scope asm. This patch makes clang to match nvcc behavior and emit file-scope-asm only during host-side compilation. Differential Revision: http://reviews.llvm.org/D9270 llvm-svn: 235905
* [OPENMP] Simplified iteration over clauses, NFC.Alexey Bataev2015-04-271-66/+21
| | | | llvm-svn: 235838
* [OPENMP] Codegen for 'taskwait' directive.Alexey Bataev2015-04-273-2/+25
| | | | | | | | Emit the following code for 'taskwait' directive within tied task: call i32 @__kmpc_omp_taskwait(<loc>, i32 <thread_id>); Differential Revision: http://reviews.llvm.org/D9245 llvm-svn: 235836
* [OPENMP] Codegen for 'reduction' clause in 'sections' directive.Alexey Bataev2015-04-271-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>]) { *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]); ... *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1], *(Type<n>-1*)rhs[<n>-1]); } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: <LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]); ... <LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]); __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: Atomic(<LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0])); ... Atomic(<LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1])); 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. If sections directive has only single section, then original shared variables are used instead with barrier at the end of the directive. Differential Revision: http://reviews.llvm.org/D9242 llvm-svn: 235835
* [OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.Alexey Bataev2015-04-271-5/+31
| | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp sections lastprivate(<var>) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <init for lastprivates>; <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) { <final copy for lastprivate>; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. If there is only one section, there is no special code generation, original shared variables are used + barrier is emitted at the end of the directive. Differential Revision: http://reviews.llvm.org/D9240 llvm-svn: 235834
* [OPENMP] Codegen for 'private' clause in 'sections' directive.Alexey Bataev2015-04-271-0/+2
| | | | | | | | | | | | | | | | | | If there are 2 or more sections in a 'section' directive the following code is generated: <default init for privates> @__kmpc_for_static_init_4(); <BODY for sections directive> @__kmpc_for_static_fini() If there is only one section, the following code is generated: if (@__kmpc_single()) { <default init for privates> @__kmpc_end_single(); } Differential Revision: http://reviews.llvm.org/D9239 llvm-svn: 235833
* [OPENMP] Codegen for 'private' clause in 'single' directive.Alexey Bataev2015-04-271-0/+1
| | | | | | | | | | | | Emit the following code for 'single' directive with 'private' clause: if (@__kmpc_single()) { <default init for privates> @__kmpc_end_single(); } Differential Revision: http://reviews.llvm.org/D9238 llvm-svn: 235832
* Correctly handle zero-sized but non-empty base classes in IRGen.John McCall2015-04-261-1/+5
| | | | | | | | | | | | | | | | Fixes rdar://20621065. A more elegant fix would preclude this case by defining the rules such that zero-size classes are always formally empty. I believe the only extensions which create zero-size classes right now are flexible arrays and zero-length arrays; it's not abstractly unreasonable to say that those don't count as members for the purposes of emptiness, just as zero-width bitfields don't count. But that's an ABI-affecting change and requires further discussion; in the meantime, let's not assert / miscompile. llvm-svn: 235815
* InstrProf: Fix coverage maps for conditional operatorsJustin Bogner2015-04-241-1/+7
| | | | | | | | | This fixes a crash when we're emitting coverage and a macro appears between two binary conditional operators, ie, "foo ?: MACRO ?: bar", and fixes the interaction of macros and conditional operators in general. llvm-svn: 235793
* [OPENMP] Codegen for 'firstprivate' clause in 'single' directive.Alexey Bataev2015-04-241-5/+13
| | | | | | | | | | | | | Emit the following code for 'single' directive with 'firtstprivate' clause: if (@__kmpc_single()) { <init for firstprivates> @__kmpc_end_single(); } @__kmpc_cancel_barrier(); // To avoid data race in firstprivate init Differential Revision: http://reviews.llvm.org/D9223 llvm-svn: 235694
* [OPENMP] Do not emit implicit barrier for single directive with ↵Alexey Bataev2015-04-241-2/+3
| | | | | | | | | 'copyprivate' clause(s). Runtime function for 'copyprivate' directive generates implicit barriers, so no need to emit it. Differential Revision: http://reviews.llvm.org/D9215 llvm-svn: 235692
* [OPENMP] Codegen for 'firstprivate' clause in 'sections' directive.Alexey Bataev2015-04-241-1/+25
| | | | | | | | | | | | | | | | | | | | If there are 2 or more sections in a 'section' directive the following code is generated: <init for firstprivates> @__kmpc_cancel_barrier();// To avoid data race in firstprivate init @__kmpc_for_static_init_4(); <BODY for sections directive> @__kmpc_for_static_fini() If there is only one section, the following code is generated: if (@__kmpc_single()) { <init for firstprivates> @__kmpc_end_single(); } @__kmpc_cancel_barrier(); // To avoid data race in firstprivate init Differential Revision: http://reviews.llvm.org/D9214 llvm-svn: 235691
* Replace getPointeeType()->isFunctionType with isMemberDataPointerTypeDavid Majnemer2015-04-243-4/+3
| | | | llvm-svn: 235682
* [MS ABI] Fix the preferred alignment of member pointersDavid Majnemer2015-04-241-2/+1
| | | | | | | Member pointers in the MS ABI have different alignment depending on whether they were created on the stack or live in a record. llvm-svn: 235681
* InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)Justin Bogner2015-04-2314-169/+145
| | | | | | | | | 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
* Don't emit lifetime markers when msan is enabledReid Kleckner2015-04-231-0/+5
| | | | | | | | | | In r235553, Clang started emitting lifetime markers more often. This caused false negative in MSan, because MSan only poisons all allocas once at function entry. Eventually, MSan should poison allocas at lifetime start and probably also lifetime end, but until then, let's not emit markers that aren't going to be useful. llvm-svn: 235613
OpenPOWER on IntegriCloud