summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* convert builtin_unpredictable on a switch into metadata for LLVMSanjay Patel2015-09-091-0/+19
| | | | llvm-svn: 247203
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-09-097-124/+238
| | | | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479. After this patch got reverted because of ScalarEvolution bug (D12719) Merged after John McCall big patch (Added Address). http://reviews.llvm.org/D11859 llvm-svn: 247199
* [MS ABI] Don't crash on references to pointers to members in argsDavid Majnemer2015-09-091-2/+2
| | | | | | | | | | | | | We know that a reference can always be dereferenced. However, we don't always know the number of bytes if the reference's pointee type is incomplete. This case was correctly handled but we didn't consider the case where the type is complete but we cannot calculate its size for ABI specific reasons. In this specific case, a member pointer's size is available only under certain conditions. This fixes PR24703. llvm-svn: 247188
* Fix vld1_lane intrinsic generationSteven Wu2015-09-091-2/+1
| | | | | | | Fix a bug introduced in r246985 which causes assertion when generating vld1_lane. llvm-svn: 247117
* CodeGen: Add CFI unrelated cast checks to the new pointer code path.Peter Collingbourne2015-09-091-0/+8
| | | | llvm-svn: 247105
* Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.Michael Zolotukhin2015-09-084-6/+54
| | | | | | | | | | | | | Summary: Currently clang provides no general way to generate nontemporal loads/stores. There are some architecture specific builtins for doing so (e.g. in x86), but there is no way to generate non-temporal store on, e.g. AArch64. This patch adds generic builtins which are expanded to a simple store with '!nontemporal' attribute in IR. Differential Revision: http://reviews.llvm.org/D12313 llvm-svn: 247104
* CodeGen: Introduce CodeGenModule::CreateMetadataIdentifierForType.Peter Collingbourne2015-09-082-0/+30
| | | | | | | | | This function can be used to create a metadata identifier for a specific type. No functionality change, but this will be used by D11857 and D12026. Differential Revision: http://reviews.llvm.org/D12038 llvm-svn: 247098
* Remove unneeded #include.Adrian Prantl2015-09-081-1/+0
| | | | llvm-svn: 247081
* Collect SEH captures in a set instead of a vector to avoidJohn McCall2015-09-081-4/+4
| | | | | | | | doing redundant work if a variable is used multiple times. Fixes PR24751. llvm-svn: 247075
* Module Debugging: Emit debug type information into clang ObjC modules.Adrian Prantl2015-09-083-3/+97
| | | | | | | | | | When -fmodule-format is set to "obj", emit debug info for all types declared in a module or referenced by a declaration into the module's object file container. This patch adds support for Objective-C types and methods. llvm-svn: 247068
* Module Debugging: Emit debug type information into clang modules.Adrian Prantl2015-09-081-0/+58
| | | | | | | | | | When -fmodule-format is set to "obj", emit debug info for all types declared in a module or referenced by a declaration into the module's object file container. This patch adds support for C and C++ types. llvm-svn: 247049
* findDominatingStoreToReturn in CGCall.cpp didn't check if a candidate storeJakub Kuderski2015-09-081-11/+14
| | | | | | | | | | | | | | instruction used the ReturnValue as pointer operand or value operand. This led to wrong code gen - in later stages (load-store elision code) the found store and its operand would be erased, causing ReturnValue to become a <badref>. The patch adds a check that makes sure that ReturnValue is a pointer operand of store instruction. Regression test is also added. This fixes PR24386. Differential Revision: http://reviews.llvm.org/D12400 llvm-svn: 247003
* clangCodeGen: Fix comments. [-Wdocumentation]NAKAMURA Takumi2015-09-083-7/+8
| | | | llvm-svn: 246995
* When building the alloca for a local variable, set its nameJohn McCall2015-09-081-1/+5
| | | | | | | | | | separately from building the instruction so that it's preserved even in -Asserts builds. Employ C++'s mystical "comment" feature to discourage breaking this in the future. llvm-svn: 246991
* Remove unnecessary braces; this resolves against aJohn McCall2015-09-081-2/+2
| | | | | | single-pointer overload instead of the ArrayRef one. llvm-svn: 246988
* Move BlockByrefHelpers back to CodeGenModule.h to placate MSVC.John McCall2015-09-082-29/+30
| | | | llvm-svn: 246986
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-0844-4680/+6087
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an Address type to bundle a pointer value with an alignment. Introduce APIs on CGBuilderTy to work with Address values. Change core APIs on CGF/CGM to traffic in Address where appropriate. Require alignments to be non-zero. Update a ton of code to compute and propagate alignment information. As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment helper function to CGF and made use of it in a number of places in the expression emitter. The end result is that we should now be significantly more correct when performing operations on objects that are locally known to be under-aligned. Since alignment is not reliably tracked in the type system, there are inherent limits to this, but at least we are no longer confused by standard operations like derived-to-base conversions and array-to-pointer decay. I've also fixed a large number of bugs where we were applying the complete-object alignment to a pointer instead of the non-virtual alignment, although most of these were hidden by the very conservative approach we took with member alignment. Also, because IRGen now reliably asserts on zero alignments, we should no longer be subject to an absurd but frustrating recurring bug where an incomplete type would report a zero alignment and then we'd naively do a alignmentAtOffset on it and emit code using an alignment equal to the largest power-of-two factor of the offset. We should also now be emitting much more aggressive alignment attributes in the presence of over-alignment. In particular, field access now uses alignmentAtOffset instead of min. Several times in this patch, I had to change the existing code-generation pattern in order to more effectively use the Address APIs. For the most part, this seems to be a strict improvement, like doing pointer arithmetic with GEPs instead of ptrtoint. That said, I've tried very hard to not change semantics, but it is likely that I've failed in a few places, for which I apologize. ABIArgInfo now always carries the assumed alignment of indirect and indirect byval arguments. In order to cut down on what was already a dauntingly large patch, I changed the code to never set align attributes in the IR on non-byval indirect arguments. That is, we still generate code which assumes that indirect arguments have the given alignment, but we don't express this information to the backend except where it's semantically required (i.e. on byvals). This is likely a minor regression for those targets that did provide this information, but it'll be trivial to add it back in a later patch. I partially punted on applying this work to CGBuiltin. Please do not add more uses of the CreateDefaultAligned{Load,Store} APIs; they will be going away eventually. llvm-svn: 246985
* Don't crash on a self-alias declarationHal Finkel2015-09-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were crashing in CodeGen given input like this: int self_alias(void) __attribute__((weak, alias("self_alias"))); such a self-alias is invalid, but instead of diagnosing the situation, we'd proceed to produce IR for both the function declaration and the alias. Because we already had a function named 'self_alias', the alias could not be named the same thing, and so LLVM would pick a different name ('self_alias1' for example) for that value. When we later called CodeGenModule::checkAliases, we'd look up the IR value corresponding to the alias name, find the function declaration instead, and then assert in a cast to llvm::GlobalAlias. The easiest way to prevent this is simply to avoid creating the wrongly-named alias value in the first place and issue the diagnostic there (instead of in checkAliases). We detect a related cycle case in CodeGenModule::EmitAliasDefinition already, so this just adds a second such check. Even though the other test cases for this 'alias definition is part of a cycle' diagnostic are in test/Sema/attr-alias-elf.c, I've added a separate regression test for this case. This is because I can't add this check to test/Sema/attr-alias-elf.c without disturbing the other test cases in that file. In order to avoid construction of the bad IR values, this diagnostic is emitted from within CodeGenModule::EmitAliasDefinition (and the relevant declaration is not added to the Aliases vector). The other cycle checks are done within the CodeGenModule::checkAliases function based on the Aliases vector, called from CodeGenModule::Release. However, if there have been errors earlier, HandleTranslationUnit does not call Release, and so checkAliases is never called, and so none of the other diagnostics would be produced. Fixes PR23509. llvm-svn: 246882
* Don't use unreachable as a placeholder, it confuses EmitBlockReid Kleckner2015-09-041-1/+3
| | | | | | | | | | This fixes an issue raised in D12412, where we generated invalid IR. Thanks to Vedant Kumar for coming up with the initial work around. Differential Revision: http://reviews.llvm.org/D12412 llvm-svn: 246880
* [OPENMP] Fix for http://llvm.org/PR24674: assertion failed and and abort trapAlexey Bataev2015-09-043-5/+25
| | | | | | Fix processing of shared variables with reference types in OpenMP constructs. Previously, if the variable was not marked in one of the private clauses, the reference to this variable was emitted incorrectly and caused an assertion later. llvm-svn: 246846
* Fix a couple of \param(s) in r246815. [-Wdocumentation]NAKAMURA Takumi2015-09-041-2/+2
| | | | llvm-svn: 246838
* Refactored dtor sanitizing into EHScopeStackNaomi Musgrave2015-09-033-59/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Dtor sanitization handled amidst other dtor cleanups, between cleaning bases and fields. Sanitizer call pushed onto stack of cleanup operations. Reviewers: eugenis, kcc Differential Revision: http://reviews.llvm.org/D12022 Refactoring dtor sanitizing emission order. - Support multiple inheritance by poisoning after member destructors are invoked, and before base class destructors are invoked. - Poison for virtual destructor and virtual bases. - Repress dtor aliasing when sanitizing in dtor. - CFE test for dtor aliasing, and repression of aliasing in dtor code generation. - Poison members on field-by-field basis, with collective poisoning of trivial members when possible. - Check msan flags and existence of fields, before dtor sanitizing, and when determining if aliasing is allowed. - Testing sanitizing bit fields. llvm-svn: 246815
* [WebAssembly] Initial WebAssembly support in clangDan Gohman2015-09-035-3/+126
| | | | | | | | | | This implements basic support for compiling (though not yet assembling or linking) for a WebAssembly target. Note that ABI details are not yet finalized, and may change. Differential Revision: http://reviews.llvm.org/D12002 llvm-svn: 246814
* Fix PR23472þ by emitting initialized variable and its guard in the same ↵Yaron Keren2015-09-031-3/+5
| | | | | | | | | | COMDAT only for ELF objects. http://llvm.org/pr23472 Reviewed by Reid Kleckner. llvm-svn: 246803
* [ARM] Allow passing/returning of __fp16 argumentsOliver Stannard2015-09-031-0/+20
| | | | | | | | | | | | | | | | | | | | | The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be used as a functon argument or return type (ACLE 1.1 did not). The current public release of the AAPCS (2.09) states that __fp16 values should be converted to single-precision before being passed or returned, but AAPCS 2.10 (to be released shortly) changes this, so that they are passed in the least-significant 16 bits of either a GPR (for base AAPCS) or a single-precision register (for AAPCS-VFP). This does not change how arguments are passed if they get passed on the stack. This patch brings clang up to compliance with the latest versions of both of these specs. We can now set the __ARM_FP16_ARGS ACLE predefine, and we have always been able to set the __ARM_FP16_FORMAT_IEEE predefine (we do not support the alternative format). llvm-svn: 246764
* Revert 246755 as it breaks buildbotsOliver Stannard2015-09-031-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | Original commit message: [ARM] Allow passing/returning of __fp16 arguments The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be used as a functon argument or return type (ACLE 1.1 did not). The current public release of the AAPCS (2.09) states that __fp16 values should be converted to single-precision before being passed or returned, but AAPCS 2.10 (to be released shortly) changes this, so that they are passed in the least-significant 16 bits of either a GPR (for base AAPCS) or a single-precision register (for AAPCS-VFP). This does not change how arguments are passed if they get passed on the stack. This patch brings clang up to compliance with the latest versions of both of these specs. We can now set the __ARM_FP16_ARGS ACLE predefine, and we have always been able to set the __ARM_FP16_FORMAT_IEEE predefine (we do not support the alternative format). llvm-svn: 246760
* [ARM] Allow passing/returning of __fp16 argumentsOliver Stannard2015-09-031-0/+18
| | | | | | | | | | | | | | | | | | | | | The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be used as a functon argument or return type (ACLE 1.1 did not). The current public release of the AAPCS (2.09) states that __fp16 values should be converted to single-precision before being passed or returned, but AAPCS 2.10 (to be released shortly) changes this, so that they are passed in the least-significant 16 bits of either a GPR (for base AAPCS) or a single-precision register (for AAPCS-VFP). This does not change how arguments are passed if they get passed on the stack. This patch brings clang up to compliance with the latest versions of both of these specs. We can now set the __ARM_FP16_ARGS ACLE predefine, and we have always been able to set the __ARM_FP16_FORMAT_IEEE predefine (we do not support the alternative format). llvm-svn: 246755
* [OPENMP 4.1] Codegen for extended format of 'if' clause.Alexey Bataev2015-09-031-4/+12
| | | | | | Fixed codegen for extended format of 'if' clauses with special 'directive-name-modifier' + ast-print tests for extended format of 'if' clause. llvm-svn: 246748
* Migrate the target attribute parsing code to returning an instanceEric Christopher2015-09-021-11/+11
| | | | | | | | every time it's called rather than attempting to cache the result. It's unlikely to be called frequently and the overhead of using it in the first place is already factored out. llvm-svn: 246706
* add __builtin_unpredictable and convert to metadataSanjay Patel2015-09-022-1/+24
| | | | | | | | | | | | | | | | | | | | | | | This patch depends on r246688 (D12341). The goal is to make LLVM generate different code for these functions for a target that has cheap branches (see PR23827 for more details): int foo(); int normal(int x, int y, int z) { if (x != 0 && y != 0) return foo(); return 1; } int crazy(int x, int y) { if (__builtin_unpredictable(x != 0 && y != 0)) return foo(); return 1; } Differential Revision: http://reviews.llvm.org/D12458 llvm-svn: 246699
* [OpenMP] Make helper functoin static. NFC.Benjamin Kramer2015-09-021-1/+1
| | | | llvm-svn: 246657
* Migrate the target attribute parsing code into an extension off ofEric Christopher2015-09-021-29/+8
| | | | | | | | | | the main attribute and cache the results so we don't have to parse a single attribute more than once. This reapplies r246596 with a fix for an uninitialized class member, and a couple of cleanups and formatting changes. llvm-svn: 246610
* Revert "Migrate the target attribute parsing code into an extension off of"Eric Christopher2015-09-011-8/+29
| | | | | | | | This is failing in release mode. Revert while I figure out what's happening. This reverts commit r246596. llvm-svn: 246598
* Migrate the target attribute parsing code into an extension off ofEric Christopher2015-09-011-29/+8
| | | | | | | the main attribute and cache the results so we don't have to parse a single attribute more than once. llvm-svn: 246596
* Use hasAttr, not getAttr if we're just checking for presence.Eric Christopher2015-09-011-1/+1
| | | | llvm-svn: 246595
* [PowerPC] Support __builtin_ppc_get_timebaseHal Finkel2015-08-311-0/+5
| | | | | | | | | | GCC 4.8+ has a PowerPC-specific intrinsic, __builtin_ppc_get_timebase, to do what Clang's __builtin_readcyclecounter does. For compatibility with code that uses GCC's spelling (including glibc), support it as well. Partially fixes PR23681. llvm-svn: 246510
* Revert "Pull the target attribute parsing out of CGCall and onto TargetInfo."Eric Christopher2015-08-311-9/+35
| | | | | | This reverts commit r246468 while we figure out what to do about Basic and AST. llvm-svn: 246508
* Pull the target attribute parsing out of CGCall and onto TargetInfo.Eric Christopher2015-08-311-35/+9
| | | | | | | | | Also: - Add a typedef to make working with the result easier. - Update callers to use the new function. - Make initFeatureMap out of line. llvm-svn: 246468
* [CUDA] fix codegen for __nvvm_atom_min/max_gen_u*Jingyue Wu2015-08-311-2/+6
| | | | | | | | | | | | Summary: Clang should emit "atomicrmw umin/umax" instead of "atomicrmw min/max". Reviewers: eliben, tra Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12487 llvm-svn: 246455
* PR17829: Proper diagnostic of mangled names conflictsAndrey Bokhanko2015-08-314-98/+154
| | | | | | | | | | Proper diagnostic and resolution of mangled names conflicts between C++ methods and C functions. This patch implements support for functions/methods only; support for variables is coming separately. Differential Revision: http://reviews.llvm.org/D11297 llvm-svn: 246438
* [OPENMP 4.0] Codegen for array sections.Alexey Bataev2015-08-313-7/+193
| | | | | | Added codegen for array section in 'depend' clause of 'task' directive. It emits to pointers, one for the begin of array section and another for the end of array section. Size of the section is calculated as (end + 1 - start) * sizeof(basic_element_type). llvm-svn: 246422
* [OpenMP] Make the filetered clause iterator a real iterator and type safe.Benjamin Kramer2015-08-301-64/+42
| | | | | | | | | This replaces the filtered generic iterator with a type-specfic one based on dyn_cast instead of comparing the kind enum. This allows us to use range-based for loops and eliminates casts. No functionality change intended. llvm-svn: 246384
* Allow TLS vars in dllimport/export functions; only inline dllimport ↵Hans Wennborg2015-08-281-0/+38
| | | | | | | | | | | | | | | | | | | | | functions when safe (PR24593) This patch does two things: 1) Don't error about dllimport/export on thread-local static local variables. We put those attributes on static locals in dllimport/export functions implicitly in case the function gets inlined. Now, for TLS variables this is a problem because we can't import such variables, but it's a benign problem becase: 2) Make sure we never inline a dllimport function TLS static locals. In fact, never inline a dllimport function that references a non-imported function or variable (because these are not defined in the importing library). This seems to match MSVC's behaviour. Differential Revision: http://reviews.llvm.org/D12422 llvm-svn: 246338
* Revert "[OPENMP 4.0] Codegen for array sections."Daniel Jasper2015-08-283-169/+7
| | | | | | | The test is currently failing on bots: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/12747/ llvm-svn: 246288
* Revert r246214 and r246213Steven Wu2015-08-287-235/+120
| | | | | | These two commits causes llvm LTO bootstrap to hang in ScalarEvolution. llvm-svn: 246282
* [OPENMP 4.0] Codegen for array sections.Alexey Bataev2015-08-283-7/+169
| | | | | | Added codegen for array section in 'depend' clause of 'task' directive. It emits to pointers, one for the begin of array section and another for the end of array section. Size of the section is calculated as (end + 1 - start) * sizeof(basic_element_type). llvm-svn: 246278
* Merge the two feature map setting functions into a single functionEric Christopher2015-08-281-2/+1
| | | | | | and replace all callers. llvm-svn: 246259
* CGDebugInfo: Instead of uniquing RetainedTypes, just refrain from retainingAdrian Prantl2015-08-271-6/+7
| | | | | | them more than once. (NFC) llvm-svn: 246231
* Use an explicit assignment.Eric Christopher2015-08-271-2/+2
| | | | llvm-svn: 246225
* Assume loads fix #2Piotr Padlewski2015-08-275-11/+18
| | | | | | | | | | | | | There was linker problem, and it turns out that it is not always safe to refer to vtable. If the vtable is used, then we can refer to it without any problem, but because we don't know when it will be used or not, we can only check if vtable is external or it is safe to to emit it speculativly (when class it doesn't have any inline virtual functions). It should be fixed in the future. http://reviews.llvm.org/D12385 llvm-svn: 246214
OpenPOWER on IntegriCloud