summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* [OPENMP] Improved code for generating debug info + generation of all OpenMP ↵Alexey Bataev2015-03-103-23/+29
| | | | | | | | | regions in termination scope Patch adds proper generation of debug info for all OpenMP regions. Also, all OpenMP regions are generated in a termination scope, because standard does not allow to throw exceptions out of structured blocks, associated with the OpenMP regions Differential Revision: http://reviews.llvm.org/D7935 llvm-svn: 231752
* Update for LLVM API change: getOrEnforceKnownAlignment() requires a DataLayoutMehdi Amini2015-03-101-2/+2
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 231739
* [UBSan] Split -fsanitize=shift into -fsanitize=shift-base and ↵Alexey Samsonov2015-03-091-26/+37
| | | | | | | | | | | | | | | | -fsanitize=shift-exponent. This is a recommit of r231150, reverted in r231409. Turns out that -fsanitize=shift-base check implementation only works if the shift exponent is valid, otherwise it contains undefined behavior itself. Make sure we check that exponent is valid before we proceed to check the base. Make sure that we actually report invalid values of base or exponent if -fsanitize=shift-base or -fsanitize=shift-exponent is specified, respectively. llvm-svn: 231711
* ARM: use ABI-specified alignment for byval parameters.Tim Northover2015-03-091-6/+3
| | | | | | | | | | | | | | | | When passing a type with large alignment byval, we were specifying the type's alignment rather than the alignment that the backend is actually capable of producing (ABIAlign). This would be OK (if odd) assuming the backend dealt with it prooperly, unfortunately it doesn't and trying to pass types with "byval align 16" can cause it to set fp incorrectly and trash the stack during the prologue. I'll be fixing that in a separate patch, but Clang should still be emitting IR that's as close to its intent as possible. rdar://20059039 llvm-svn: 231706
* Reapply r231508 "CodeGen: Emit constant temporaries into read-only globals."Benjamin Kramer2015-03-071-2/+20
| | | | | | | | | | | | I disabled putting the new global into the same COMDAT as the function for now. There's a fundamental problem when we inline references to the global but still have the global in a COMDAT linked to the inlined function. Since this is only an optimization there may be other versions of the COMDAT around that are missing the new global and hell breaks loose at link time. I hope the chromium build doesn't break this time :) llvm-svn: 231564
* Revert r231508 "CodeGen: Emit constant temporaries into read-only globals."Hans Wennborg2015-03-071-22/+2
| | | | | | | | | This broke the Chromium build. Links were failing with messages like: obj/dbus/libdbus_test_support.a(obj/dbus/dbus_test_support.mock_object_proxy.o):../../dbus/mock_object_proxy.cc:function dbus::MockObjectProxy::Detach(): warning: relocation refers to discarded section /usr/local/google/work/chromium/src/third_party/binutils/Linux_x64/Release/bin/ld.gold: error: treating warnings as errors llvm-svn: 231541
* Replace Sema's map of locally-scoped extern "C" declarations with a DeclContextRichard Smith2015-03-071-0/+1
| | | | | | | | | | of extern "C" declarations. This is simpler and vastly more efficient for modules builds (we no longer need to load *all* extern "C" declarations to determine if we have a redeclaration). No functionality change intended. llvm-svn: 231538
* MS ABI: Stick throw-related data into the .xdata sectionDavid Majnemer2015-03-061-3/+6
| | | | | | | This is a little nicer as it keeps the contents of .xdata away from normal .rdata; we expect .xdata to be far colder than .rdata. llvm-svn: 231534
* MS ABI: Correctly generate throw-info for pointer to const qual typesDavid Majnemer2015-03-061-2/+14
| | | | | | | We didn't create type info based on the unqualified pointee type, causing RTTI mismatches. llvm-svn: 231533
* CodeGen: Emit constant temporaries into read-only globals.Benjamin Kramer2015-03-061-2/+22
| | | | | | | | | | | | | | | | | | | | | | | Instead of creating a copy on the stack just stash them in a private constant global. This saves both the copying overhead and the stack space, and gives the optimizer more room to constant fold. This tries to make array temporaries more similar to regular arrays, they can't use the same logic because a temporary has no VarDecl to be bound to so we roll our own version here. The original use case for this optimization was code like for (int i : {1, 2, 3, 4, 5, 6, 7, 8, 10}) foo(i); where without this patch (assuming that the loop is not unrolled) we would alloca an array on the stack, copy the 10 values over and iterate on that. With this patch we put the array in .text use it directly. Apart from that case this helps on virtually any passing of a constant std::initializer_list as a function argument. Differential Revision: http://reviews.llvm.org/D8034 llvm-svn: 231508
* MS ABI: Insert copy-constructors into the CatchableTypeDavid Majnemer2015-03-061-8/+11
| | | | | | | | | | | | | | | | Find all unambiguous public classes of the exception object's class type and reference all of their copy constructors. Yes, this is not conforming but it is necessary in order to implement their ABI. This is because the copy constructor is actually referenced by the metadata describing which catch handlers are eligible to handle the exception object. N.B. This doesn't yet handle the copy constructor closure case yet, that work is ongoing. Differential Revision: http://reviews.llvm.org/D8101 llvm-svn: 231499
* Revert "[UBSan] Split -fsanitize=shift into -fsanitize=shift-base and ↵Alexey Samsonov2015-03-051-32/+28
| | | | | | | | | | | -fsanitize=shift-exponent." It's not that easy. If we're only checking -fsanitize=shift-base we still need to verify that exponent has sane value, otherwise UBSan-inserted checks for base will contain undefined behavior themselves. llvm-svn: 231409
* MS ABI: Implement support for throwing a C++ exceptionDavid Majnemer2015-03-055-123/+443
| | | | | | | | | | | | | | | | | | | | | | | Throwing a C++ exception, under the MS ABI, is implemented using three components: - ThrowInfo structure which contains information like CV qualifiers, what destructor to call and a pointer to the CatchableTypeArray. - In a significant departure from the Itanium ABI, copying by-value occurs in the runtime and not at the catch site. This means we need to enumerate all possible types that this exception could be caught as and encode the necessary information to convert from the exception object's type to the catch handler's type. This includes complicated derived to base conversions and the execution of copy-constructors. N.B. This implementation doesn't support the execution of a copy-constructor from within the runtime for now. Adding support for that functionality is quite difficult due to things like default argument expressions which may evaluate arbitrary code hiding in the copy-constructor's parameters. Differential Revision: http://reviews.llvm.org/D8066 llvm-svn: 231328
* Add Clang support for PPC cryptography builtinsNemanja Ivanovic2015-03-041-0/+29
| | | | | | Review: http://reviews.llvm.org/D7951 llvm-svn: 231291
* Fix test/CodeGen/builtins.c for platforms that don't lower sjljReid Kleckner2015-03-041-0/+4
| | | | | | | | Opt in Win64 to supporting sjlj lowering. We have the backend lowering, so I think this was just an oversight because WinX86_64TargetCodeGenInfo doesn't inherit from X86_64TargetCodeGenInfo. llvm-svn: 231280
* Try to fix the build after removing DataLayoutPassReid Kleckner2015-03-041-3/+0
| | | | llvm-svn: 231278
* Adjust the changes from r230255 to bail out if the backend can't lowerJoerg Sonnenberger2015-03-042-7/+11
| | | | | | | __builtin_setjmp/__builtin_longjmp and don't fall back to the libc functions. llvm-svn: 231245
* [UBSan] Split -fsanitize=shift into -fsanitize=shift-base and ↵Alexey Samsonov2015-03-031-28/+32
| | | | | | | | | | | | | | | | | | | | | -fsanitize=shift-exponent. -fsanitize=shift is now a group that includes both these checks, so exisiting users should not be affected. This change introduces two new UBSan kinds that sanitize only left-hand side and right-hand side of shift operation. In practice, invalid exponent value (negative or too large) tends to cause more portability problems, including inconsistencies between different compilers, crashes and inadequeate results on non-x86 architectures etc. That is, -fsanitize=shift-exponent failures should generally be addressed first. As a bonus, this change simplifies CodeGen implementation for emitting left shift (separate checks for base and exponent are now merged by the existing generic logic in EmitCheck()), and LLVM IR for these checks (the number of basic blocks is reduced). llvm-svn: 231150
* Split catch IRgen into ItaniumCXXABI and MicrosoftCXXABIReid Kleckner2015-03-036-381/+434
| | | | | | | | | Use llvm.eh.begincatch for Microsoft-style catches. This moves lots of CGException code into ItaniumCXXABI. Sorry for the blame pain. llvm-svn: 231105
* Lower _mm256_broadcastsi128_si256 directly to a vector shuffle.Juergen Ributzka2015-03-031-7/+0
| | | | | | | | | | | | | | Originally we were using the same GCC builtins to lower this AVX2 vector intrinsic. Instead we will now lower it directly to a vector shuffle. This will not only allow LLVM to generate better code, but it will also allow us to remove the GCC intrinsics. Reviewed by Andrea This is related to rdar://problem/18742778. llvm-svn: 231081
* CodeGen: Fix passing of classes with only one AVX vector member in AVX registersBenjamin Kramer2015-03-021-15/+4
| | | | | | | | | | | | | | isSingleElementStruct was a bit too tight in its definition of struct so we got a mismatch between classify() and the actual code generation. To make matters worse the code in GetByteVectorType still defaulted to <2 x double> if it encountered a type it didn't know, making this a silent miscompilation (PR22753). Completely remove the "preferred type" stuff from GetByteVectorType and make it fail an assertion if someone tries to use it with a type not suitable for a vector register. llvm-svn: 230971
* Replace loop with equivalent ArrayRef function. NFC.Benjamin Kramer2015-03-021-6/+1
| | | | llvm-svn: 230949
* DebugInfo: Give externally defined types a size and alignment wherePeter Collingbourne2015-03-011-1/+9
| | | | | | possible. Fixes PR22736. llvm-svn: 230914
* DebugInfo: hoist definition into global context when neededSaleem Abdulrasool2015-02-281-3/+12
| | | | | | | | | | | | When generating debug info for a static inline member which is initialized for the DLLExport storage class, hoist the definition into a non-composite type context. Otherwise, we would trigger an assertion when generating the DIE for the associated global value as the debug context has a type association. This addresses PR22669. Thanks to David Blakie for help in coming up with a solution to this! llvm-svn: 230816
* Silence an MSVC warning about not all control paths returning a value; NFC.Aaron Ballman2015-02-271-0/+1
| | | | llvm-svn: 230754
* [OPENMP] Codegen for "#pragma omp atomic write"Alexey Bataev2015-02-272-185/+405
| | | | | | | | | | For global reg lvalue - use regular store through global register. For simple lvalue - use simple atomic store. For bitfields, vector element, extended vector elements - the original value of the whole storage (for vector elements) or of some aligned value (for bitfields) is atomically read, the part of this value for the given lvalue is modified and then use atomic compare-and-exchange operation to try to atomically write modified value (if it was not modified). Also, changes in this patch fix the bug for '#pragma omp atomic read' applied to extended vector elements. Differential Revision: http://reviews.llvm.org/D7369 llvm-svn: 230736
* MS ABI: Simplify the code which performs base adjustmentsDavid Majnemer2015-02-271-19/+17
| | | | llvm-svn: 230722
* Don't crash on leaving nested __finally blocks through an EH edge.Nico Weber2015-02-261-19/+12
| | | | | | | | | | | | | | | The __finally emission block tries to be clever by removing unused continuation edges if there's an unconditional jump out of the __finally block. With exception edges, the EH continuation edge isn't always unused though and we'd crash in a few places. Just don't be clever. That makes the IR for __finally blocks a bit longer in some cases (hence small and behavior-preserving changes to existing tests), but it makes no difference in general and it fixes the last crash from PR22553. http://reviews.llvm.org/D7918 llvm-svn: 230697
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-261-3/+4
| | | | llvm-svn: 230682
* [OPENMP] Fixed codegen for directives without function outlining.Alexey Bataev2015-02-264-87/+142
| | | | | | Fixed crash on codegen for directives like 'omp for', 'omp single' etc. inside of the 'omp parallel', 'omp task' etc. regions. llvm-svn: 230621
* CGDebugInfo: Use DIImportedEntity default constructor, NFCDuncan P. N. Exon Smith2015-02-261-2/+2
| | | | | | | | | | | | | | | | Use the newly minted `DIImportedEntity` default constructor (r230609) rather than explicitly specifying `nullptr`. The latter will become ambiguous when the new debug info hierarchy is committed, since we'll have both of the following: explicit DIImportedEntity(const MDNode *); DIImportedEntity(const MDImportedEntity *); (Currently we just have the former.) A default constructor is just as clear. llvm-svn: 230610
* Improvement on sized deallocation from r230160:Larisse Voufo2015-02-251-5/+82
| | | | | | Do not declare sized deallocation functions dependently on whether it is found in global scope. Instead, enforce the branching in emitted code by (1) declaring the functions extern_weak and (2) emitting sized delete expressions as a branching between both forms delete. llvm-svn: 230580
* UBSan: Use the correct function prologue for x32.Peter Collingbourne2015-02-251-4/+15
| | | | llvm-svn: 230571
* MS ABI: Turn throw into std::terminate for now, make try/catch "work"David Majnemer2015-02-251-7/+19
| | | | | | | This lets us compile programs which make use of exceptional constructs statically without executing any of them dynamically. llvm-svn: 230568
* Sema: Parenthesized bound destructor member expressions can be calledDavid Majnemer2015-02-256-17/+17
| | | | | | | | | We would wrongfully reject (a.~A)() in both the destructor and pseudo-destructor cases. This fixes PR22668. llvm-svn: 230512
* Reland r230460 with a test fix for -Asserts builds.Nico Weber2015-02-251-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | Original CL description: Produce less broken basic block sequences for __finally blocks. The way cleanups (such as PerformSEHFinally) get emitted is that codegen generates some initialization code, then calls the cleanup's Emit() with the insertion point set to a good place, then the cleanup is supposed to emit its stuff, and then codegen might tack in a jump or similar to where the insertion point is after the cleanup. The PerformSEHFinally cleanup tries to just stash away the block it's supposed to codegen into, and then does codegen later, into that stashed block. However, after codegen'ing the __finally block, it used to set the insertion point to the finally's continuation block (where the __finally cleanup goes when its body is completed after regular, non-exceptional control flow). That's not correct, as that block can (and generally does) already ends in a jump. Instead, remember the insertion point that was current before the __finally got emitted, and restore that. Fixes two of the crashes in PR22553. llvm-svn: 230503
* Revert "Produce less broken basic block sequences for __finally blocks."Daniel Jasper2015-02-251-4/+3
| | | | | | | | | The test is broken on buildbots: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/2279/ This reverts commit adda738b6dc533c42db5f5f5b31344098a3aba7d. llvm-svn: 230472
* [OPENMP] Rename methods of OpenMPRuntime class. NFC. Alexey Bataev2015-02-257-218/+199
| | | | llvm-svn: 230470
* Produce less broken basic block sequences for __finally blocks.Nico Weber2015-02-251-3/+4
| | | | | | | | | | | | | | | | | | | | | The way cleanups (such as PerformSEHFinally) get emitted is that codegen generates some initialization code, then calls the cleanup's Emit() with the insertion point set to a good place, then the cleanup is supposed to emit its stuff, and then codegen might tack in a jump or similar to where the insertion point is after the cleanup. The PerformSEHFinally cleanup tries to just stash away the block it's supposed to codegen into, and then does codegen later, into that stashed block. However, after codegen'ing the __finally block, it used to set the insertion point to the finally's continuation block (where the __finally cleanup goes when its body is completed after regular, non-exceptional control flow). That's not correct, as that block can (and generally does) already ends in a jump. Instead, remember the insertion point that was current before the __finally got emitted, and restore that. Fixes two of the crashes in PR22553. llvm-svn: 230460
* Add comments for two CleanupKinds.Nico Weber2015-02-251-0/+6
| | | | llvm-svn: 230459
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-252-152/+0
| | | | llvm-svn: 230454
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-252-0/+152
| | | | | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. This reapplies r230044 with a fixed configure+make build and updated dependencies and testcase requirements. Over the last iteration this version adds - missing target requirements for testcases that specify an x86 triple, - a missing clangCodeGen.a dependency to libClang.a in the make build. rdar://problem/19104245 llvm-svn: 230423
* ARM: Simplify PCS handling.Tim Northover2015-02-241-179/+9
| | | | | | | | The backend should now be able to handle all AAPCS rules based on argument type, which means Clang no longer has to duplicate the register-counting logic and the CodeGen can be significantly simplified. llvm-svn: 230349
* [OPENMP] Update codegen for 'omp flush' directive.Alexey Bataev2015-02-242-9/+5
| | | | | | | __kmpc_omp_flush() runtime library now has only one argument and is not a vararg anymore. This update makes the codegen compatible with these changes. llvm-svn: 230331
* [WinX86_64 ABI] Treat C99 _Complex as a structMichael Kuperstein2015-02-241-1/+1
| | | | | | | | | MSVC does not support C99 _Complex. ICC, however, does support it on windows x86_64, and treats it, for purposes of parameter passing, as equivalent to a struct containing two fields (for the real and imaginary part). Differential Revision: http://reviews.llvm.org/D7825 llvm-svn: 230315
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-242-152/+0
| | | | | | | This reverts commit r230305. Off to fix another round of missing dependencies on various platforms. llvm-svn: 230309
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-242-0/+152
| | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
* InstrProf: Make sure counts in lambdas don't escape to the parent scopeJustin Bogner2015-02-241-0/+5
| | | | | | | | When generating coverage maps, we were traversing the body as if it were part of the parent function, but this doesn't make sense since we're currently counting lambdas as separate functions. llvm-svn: 230304
* CodeGenModule::EmitVTableBitSetEntries: Add check for identical bit set entries.Peter Collingbourne2015-02-241-0/+3
| | | | | | | No two elements of this array should be the same, but the standard library may pass the same element as both arguments to this function. llvm-svn: 230293
* Only lower __builtin_setjmp / __builtin_longjmp toJoerg Sonnenberger2015-02-233-0/+36
| | | | | | | | | | llvm.eh.sjlj.setjmp / llvm.eh.sjlj.longjmp, if the backend is known to support them outside the Exception Handling context. The default handling in LLVM codegen doesn't work and will create incorrect code. The ARM backend on the other hand will assert if the intrinsics are used. llvm-svn: 230255
OpenPOWER on IntegriCloud