summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Generate !llvm.mem.loop_parallel_access metadata for loops with ↵Alexey Bataev2015-05-071-0/+5
| | | | | | | | | | dynamic/guided scheduling. Inner bodies of OpenMP worksharing loop-based constructs with dynamic or guided scheduling are allowed to be marked with !llvm.mem.parallel_loop_access metadata for better optimization. Worksharing constructs with static scheduling cannot be marked this way (according to OpenMP standard "A data dependence between the same logical iterations in two such loops is guaranteed"). Constructs with auto and runtime scheduling are also not marked because automatically chosen scheduling may be static also. Differential Revision: http://reviews.llvm.org/D9518 llvm-svn: 236693
* [OPENMP] Fixed codegen for 'reduction' clause.Alexey Bataev2015-05-071-9/+25
| | | | | | | | Fixed codegen for reduction operations min, max, && and ||. Codegen for them is quite similar and I was confused by this similarity. Also added a call to kmpc_end_reduce() in atomic part of reduction codegen (call to kmpc_end_reduce_nowait() is not required). Differential Revision: http://reviews.llvm.org/D9513 llvm-svn: 236689
* CGCXX: Use cast in getAddrOfCXXStructor()Duncan P. N. Exon Smith2015-05-061-2/+1
| | | | | | | | All callers should be passing `CXXConstructorDecl` or `CXXDestructorDecl` here, so use `cast<>` instead of `dyn_cast<>` when setting up the `GlobalDecl`. llvm-svn: 236651
* InstrProf: Don't start or end coverage regions inside of system macrosJustin Bogner2015-05-051-4/+4
| | | | | | | | | | | It doesn't make much sense to try to show coverage inside system macros, and source locations in builtins confuses the coverage mapping. Just avoid doing this. Fixes an assert that fired when a __block storage specifier starts a region. llvm-svn: 236547
* [SystemZ] Add support for z13 low-level vector builtinsUlrich Weigand2015-05-051-0/+205
| | | | | | | | | | | | | | | | | | | | | | | | | This adds low-level builtins to allow access to all of the z13 vector instructions. Note that instructions whose semantics can be described by standard C (including clang extensions) do not get any builtins. For each instructions whose semantics *cannot* (fully) be described, we define a builtin named __builtin_s390_<insn> that directly maps to this instruction. These are intended to be compatible with GCC. For instructions that also set the condition code, the builtin will take an extra argument of type "int *" at the end. The integer pointed to by this argument will be set to the post-instruction CC value. For many instructions, the low-level builtin is mapped to the corresponding LLVM IR intrinsic. However, a number of instructions can be represented in standard LLVM IR without requiring use of a target intrinsic. Some instructions require immediate integer operands within a certain range. Those are verified at the Sema level. Based on a patch by Richard Sandiford. llvm-svn: 236532
* [SystemZ] Add support for z13 and its vector facilityUlrich Weigand2015-05-051-26/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the z13 architecture type. For compatibility with GCC, a pair of options -mvx / -mno-vx can be used to selectively enable/disable use of the vector facility. When the vector facility is present, we default to the new vector ABI. This is characterized by two major differences: - Vector types are passed/returned in vector registers (except for unnamed arguments of a variable-argument list function). - Vector types are at most 8-byte aligned. The reason for the choice of 8-byte vector alignment is that the hardware is able to efficiently load vectors at 8-byte alignment, and the ABI only guarantees 8-byte alignment of the stack pointer, so requiring any higher alignment for vectors would require dynamic stack re-alignment code. However, for compatibility with old code that may use vector types, when *not* using the vector facility, the old alignment rules (vector types are naturally aligned) remain in use. These alignment rules are not only implemented at the C language level, but also at the LLVM IR level. This is done by selecting a different DataLayout string depending on whether the vector ABI is in effect or not. Based on a patch by Richard Sandiford. llvm-svn: 236531
* [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-17/+24
| | | | | | | Destructors are never called for cleanups, so we can't use SmallVector as a member. Differential Revision: http://reviews.llvm.org/D9399 llvm-svn: 236491
* Revert revision 236487: [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-19/+17
| | | | llvm-svn: 236490
* [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-17/+19
| | | | | | | Destructors are never called for cleanups, so we can't use SmallVector as a member. Differential Revision: http://reviews.llvm.org/D9399 llvm-svn: 236487
* Revert revision 236482: [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-19/+13
| | | | | | Due to some incompatibilities with Windows. llvm-svn: 236483
* [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-13/+19
| | | | | | | Destructors are never called for cleanups, so we can't use SmallVector as a member. Differential Revision: http://reviews.llvm.org/D9399 llvm-svn: 236482
* Revert revision 236480: [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-16/+10
| | | | | | Due to some incompatibilities with Windows. llvm-svn: 236481
* [OPENMP] Fixed incorrect work with cleanups, NFC.Alexey Bataev2015-05-051-10/+16
| | | | | | | Destructors are never called for cleanups, so we can't use SmallVector as a member. Differential Revision: http://reviews.llvm.org/D9399 llvm-svn: 236480
* [OPENMP] Codegen for 'firstprivate' clause in 'task' directive.Alexey Bataev2015-05-053-24/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 initialization of all firstprivate fields (by simple copying for POD data, copy 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); CopyConstructor(new_task->privates.var1, *new_task->shareds.var1_ref); new_task->shareds.var1_ref = &new_task->privates.var1; ... CopyConstructor(new_task->privates.varn, *new_task->shareds.varn_ref); 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/D9370 llvm-svn: 236479
* 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
OpenPOWER on IntegriCloud