summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* MS ABI: Don't ICE for pointers to pointers to members of incomplete classesDavid Majnemer2014-09-181-0/+11
| | | | | | | | | | | | | | | | | | | CodeGen would try to come up with an LLVM IR type for a pointer to member type on the way to forming an LLVM IR type for a pointer to pointer to member type. However, if the pointer to member representation has not been locked in yet, we would not be able to come up with a pointer to member IR type. In these cases, make the pointer to member type an incomplete type. This will make the pointer to pointer to member type a pointer to an incomplete type. If the class eventually obtains an inheritance model, we will make the pointer to member type represent the actual inheritance model. Differential Revision: http://reviews.llvm.org/D5373 llvm-svn: 218084
* MS inline asm: Allow __asm blocks to set a return valueReid Kleckner2014-09-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | If control falls off the end of a function after an __asm block, MSVC assumes that the inline assembly filled the EAX and possibly EDX registers with an appropriate return value. This functionality is used in inline functions returning 64-bit integers in system headers, so we need some amount of compatibility. This is implemented in Clang by adding extra output constraints to every inline asm block, and storing the resulting output registers into the return value slot. If we see an asm block somewhere in the function body, we emit a normal epilogue instead of marking the end of the function with a return type unreachable. Normal returns in functions not using this functionality will overwrite the return value slot, and in most cases LLVM should be able to eliminate the dead stores. Fixes PR17201. Reviewed By: majnemer Differential Revision: http://reviews.llvm.org/D5177 llvm-svn: 217187
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-1/+1
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* [clang/asan] call __asan_poison_cxx_array_cookie after operator new[]Kostya Serebryany2014-08-261-5/+2
| | | | | | | | | | | | | | | | | | | | Summary: PR19838 When operator new[] is called and an array cookie is created we want asan to detect buffer overflow bugs that touch the cookie. For that we need to a) poison the shadow for the array cookie (call __asan_poison_cxx_array_cookie). b) ignore the legal accesses to the cookie generated by clang (add 'nosanitize' metadata) Reviewers: timurrrr, samsonov, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4774 llvm-svn: 216434
* Simplify a few loops over CallArgList/FunctionArgList. NFCAlexey Samsonov2014-08-131-3/+2
| | | | llvm-svn: 215571
* Add coverage mapping generation.Alex Lorenz2014-08-041-0/+1
| | | | | | | | | | This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
* Add OpenCL/SPIR kernel_arg_base_type metadata nodeFraser Cormack2014-07-301-0/+28
| | | | | | | | | | | | | | As defined in the SPIR 1.2 specification, this node behaves similarly to kernel_arg_type but will print the underlying type name, e.g., without typedefs. Example: typedef unsigned int myunsignedint; would report: 'myunsignedint' in the kernel_arg_type node 'uint' in the kernel_arg_base_type node llvm-svn: 214308
* Fix OpenCL/SPIR kernel_arg_type metadata nodeFraser Cormack2014-07-301-2/+2
| | | | | | | | | | | | This fixes a bug where kernel_arg_type was always changing 'unsigned ' to 'u' for any parameter type, including non-canonical types. Example: typedef unsigned int myunsignedint; would report: "myunt" llvm-svn: 214305
* MS ABI: Don't push destructor cleanups for aggregate parameters in thunksReid Kleckner2014-07-251-10/+10
| | | | | | | | The target method of the thunk will perform the cleanup. This can't be tested in 32-bit x86 yet because passing something by value would create an inalloca, and we refuse to generate broken code for that. llvm-svn: 213976
* [UBSan] Add !nosanitize metadata to the code generated by UBSan.Alexey Samsonov2014-07-171-4/+22
| | | | | | | | | | This is used to mark the instructions emitted by Clang to implement variety of UBSan checks. Generally, we don't want to instrument these instructions with another sanitizers (like ASan). Reviewed in http://reviews.llvm.org/D4544 llvm-svn: 213291
* Remove unnecessary check for NULLAlexey Samsonov2014-07-081-10/+7
| | | | llvm-svn: 212564
* [Sanitizer] Remove brittle cache variable and slightly simplify blacklisting ↵Alexey Samsonov2014-07-071-8/+2
| | | | | | | | | | | | code. Now CodeGenFunction is responsible for looking at sanitizer blacklist (in CodeGenFunction::StartFunction) and turning off instrumentation, if necessary. No functionality change. llvm-svn: 212501
* This patch adds a helper class (CGLoopInfo) for marking memory instructions ↵Alexander Musman2014-05-221-1/+29
| | | | | | | | | | with llvm.mem.parallel_loop_access metadata. It also adds a simple initial version of codegen for pragma omp simd (it will change in the future to support all the clauses). Differential revision: http://reviews.llvm.org/D3644 llvm-svn: 209411
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-24/+26
| | | | llvm-svn: 209272
* MS ABI: Pass 'sret' as the second parameter of instance methodsReid Kleckner2014-05-091-1/+4
| | | | | | | | | | | | | | | | | Summary: MSVC always passes 'sret' after 'this', unlike GCC. This required changing a number of places in Clang that assumed the sret parameter was always first in LLVM IR. This fixes win64 MSVC ABI compatibility for methods returning structs. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3618 llvm-svn: 208458
* [OPENMP] Initial codegen for '#pragma omp parallel'Alexey Bataev2014-05-061-0/+5
| | | | llvm-svn: 208077
* Debug info: Improve line table for functions with cleanups an early exitAdrian Prantl2014-04-291-0/+20
| | | | | | | | | | | | | and no return expr at the end of the function. The "function has only simple returns" check in FinishFunction tests whether the number of simple return exprs equals the number of return exprs, but so far a fallthrough at the end of a function was not counted as a return, which would result in cleanup code being associated with the wrong source line. rdar://problem/16733984. llvm-svn: 207480
* Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_aAdrian Prantl2014-04-101-4/+19
| | | | | | | | | | | | | | | | are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 llvm-svn: 205999
* When printing types for the OpenCL kernel metadata, use the PrintingPolicy.Joey Gouly2014-04-041-2/+5
| | | | | | | | This allows 'half' to be printed as 'half' and not as '__fp16'. Patch by Fraser Cormack! llvm-svn: 205624
* Kill -faddress-sanitizer, -fthread-sanitizer and -fcatch-undefined-behavior ↵Alexey Samsonov2014-03-201-1/+1
| | | | | | | | | flags. These flags are deprecated since at least Clang 3.3. Users should instead use -fsanitize= with appropriate values. llvm-svn: 204330
* PGO: Statically generate data structuresDuncan P. N. Exon Smith2014-03-171-1/+1
| | | | | | | | | | | | | | | | | | | In instrumentation-based profiling, we need a set of data structures to represent the counters. Previously, these were built up during static initialization. Now, they're shoved into a specially-named section so that they show up as an array. As a consequence of the reorganizing symbols, instrumentation data structures for linkonce functions are now correctly coalesced. This is the first step in a larger project to minimize runtime overhead and dependencies in instrumentation-based profilng. The larger picture includes removing all initialization overhead and making the dependency on libc optional. <rdar://problem/15943240> llvm-svn: 204080
* [C++11] Replacing DeclBase iterators specific_attr_begin() and ↵Aaron Ballman2014-03-101-8/+4
| | | | | | specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203474
* [C++11] Update Clang for the change to LLVM's Use-Def chain iterators inChandler Carruth2014-03-091-1/+1
| | | | | | | | | r203364: what was use_iterator is now user_iterator, and there is a use_iterator for directly iterating over the uses. This also switches to use the range-based APIs where appropriate. llvm-svn: 203365
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-2/+1
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. llvm-svn: 203179
* PGO: Use the main file name to help distinguish functions with local linkage.Bob Wilson2014-03-061-11/+2
| | | | | | | | | | | | In addition, for all functions, use the name from the llvm::Function to identify the function in the profile data. Compute that "function name", including the file name for local functions, once when assigning the PGO counters and store it in the CodeGenPGO class. Move the code to add InlineHint and Cold attributes out of StartFunction(), because the "function name" string isn't available at that point. llvm-svn: 203075
* Refactor PGO code in preparation for handling non-C/C++ code.Bob Wilson2014-03-061-2/+2
| | | | | | | | | | | Move the PGO.assignRegionCounters() call out of StartFunction, because that function is called from many places where it does not make sense to do PGO instrumentation (e.g., compiler-generated helper functions). Change several functions to take a StringRef argument for the unique name associated with a function, so that the name can be set differently for things like Objective-C methods and block literals. llvm-svn: 203073
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202639
* IRGen: Remove a stale commentDavid Majnemer2014-02-251-1/+1
| | | | | | | This comment survived the transition from ForceInline to InlineAlways, fix it. llvm-svn: 202133
* Attr: Remove ForceInlineDavid Majnemer2014-02-251-2/+1
| | | | | | | | | | The __forceinline keyword's semantics are now recast as AlwaysInline and the kw___forceinline token has its language mode set for KEYMS. This preserves the semantics of the previous implementation but with less duplication of code. llvm-svn: 202131
* Change PGO instrumentation to compute counts in a separate AST traversal.Bob Wilson2014-02-171-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we made one traversal of the AST prior to codegen to assign counters to the ASTs and then propagated the count values during codegen. This patch now adds a separate AST traversal prior to codegen for the -fprofile-instr-use option to propagate the count values. The counts are then saved in a map from which they can be retrieved during codegen. This new approach has several advantages: 1. It gets rid of a lot of extra PGO-related code that had previously been added to codegen. 2. It fixes a serious bug. My original implementation (which was mailed to the list but never committed) used 3 counters for every loop. Justin improved it to move 2 of those counters into the less-frequently executed breaks and continues, but that turned out to produce wrong count values in some cases. The solution requires visiting a loop body before the condition so that the count for the condition properly includes the break and continue counts. Changing codegen to visit a loop body first would be a fairly invasive change, but with a separate AST traversal, it is easy to control the order of traversal. I've added a testcase (provided by Justin) to make sure this works correctly. 3. It improves the instrumentation overhead, reducing the number of counters for a loop from 3 to 1. We no longer need dedicated counters for breaks and continues, since we can just use the propagated count values when visiting breaks and continues. To make this work, I needed to make a change to the way we count case statements, going back to my original approach of not including the fall-through in the counter values. This was necessary because there isn't always an AST node that can be used to record the fall-through count. Now case statements are handled the same as default statements, with the fall-through paths branching over the counter increments. While I was at it, I also went back to using this approach for do-loops -- omitting the fall-through count into the loop body simplifies some of the calculations and make them behave the same as other loops. Whenever we start using this instrumentation for coverage, we'll need to add the fall-through counts into the counter values. llvm-svn: 201528
* Fix some minor whitespace issues.Bob Wilson2014-02-171-1/+1
| | | | llvm-svn: 201526
* Simplify code by combining ifs.Manman Ren2014-02-061-9/+7
| | | | llvm-svn: 200893
* Fix Werror introduced at r200874.Manman Ren2014-02-061-1/+1
| | | | llvm-svn: 200891
* PGO: instrumentation based profiling sets function attributes.Manman Ren2014-02-051-0/+10
| | | | | | | | | | | | | | | We collect a maximal function count among all functions in the pgo data file. For functions that are hot, we set its InlineHint attribute. For functions that are cold, we set its Cold attribute. We currently treat functions with >= 30% of the maximal function count as hot and functions with <= 1% of the maximal function count are treated as cold. These two numbers are from preliminary tuning on SPEC. This commit should not affect non-PGO builds and should boost performance on instrumentation based PGO. llvm-svn: 200874
* [ms-cxxabi] Use inalloca on win32 when passing non-trivial C++ objectsReid Kleckner2014-02-011-0/+16
| | | | | | | | | | | | | | | | | | | When a non-trivial parameter is present, clang now gathers up all the parameters that lack inreg and puts them into a packed struct. MSVC always aligns each parameter to 4 bytes and no more, so this is a pretty simple struct to lay out. On win64, non-trivial records are passed indirectly. Prior to this change, clang was incorrectly using byval on win64. I'm able to self-host a working clang with this change and additional LLVM patches. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2636 llvm-svn: 200597
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-3/+3
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* CodeGen: Fix tracking of PGO counters for the logical or operatorJustin Bogner2014-01-231-1/+1
| | | | | | | This adds tests for both logical or and for logical and, which was already correct. llvm-svn: 199865
* Make -fno-inline attach NoInline attribute to all functions that are notRoman Divacky2014-01-151-3/+8
| | | | | | | | | | marked as AlwaysInline or ForceInline. This moves us to what gcc does with -fno-inline. The attribute approach was discussed to be better than switching to InlineAlways inliner in presence of LTO. llvm-svn: 199324
* Simplifying the OpenCL image attribute. It does not need a semantic integer ↵Aaron Ballman2014-01-141-2/+2
| | | | | | parameter because the required information is encoded in the spelling. Added an appropriate subject to the attribute, and simplified the semantic checking (which will likely be expanded upon in a future patch). Also, removed the GNU spelling since it was unsupported in the first place. llvm-svn: 199229
* CodeGen: Rename adjustFallThroughCount -> adjustForControlFlowJustin Bogner2014-01-131-2/+2
| | | | | | | | adjustFallThroughCount isn't a good name, and the documentation was even worse. This commit attempts to clarify what it's for and when to use it. llvm-svn: 199139
* The OpenCL specification states that images are allocated Pekka Jaaskelainen2014-01-091-1/+6
| | | | | | | | | | | from the global address space (6.5.1 of the OpenCL 1.2 specification). This makes clang construct the image arguments in the global address space and generate the argument metadata with the correct address space descriptor. Patch by Pedro Ferreira! llvm-svn: 198868
* Revert "Debug info: Ensure that the last stop point in a function is still ↵Adrian Prantl2014-01-071-4/+3
| | | | | | | | within" This reverts commit r198461. llvm-svn: 198714
* Revert "Debug info: Implement a cleaner version of r198461. For symmetry with"Adrian Prantl2014-01-071-3/+4
| | | | | | This reverts commit 198699 so we can get a cleaner patch. llvm-svn: 198713
* Debug info: Implement a cleaner version of r198461. For symmetry withAdrian Prantl2014-01-071-4/+3
| | | | | | | | | C and C++ don't emit an extra lexical scope for the compound statement that is the body of an Objective-C method. rdar://problem/15010825 llvm-svn: 198699
* CodeGen: Initial instrumentation based PGO implementationJustin Bogner2014-01-061-16/+76
| | | | llvm-svn: 198640
* Debug info: Ensure that the last stop point in a function is still withinAdrian Prantl2014-01-031-3/+4
| | | | | | | | | the lexical block formed by the compound statement that is the function body. rdar://problem/15010825 llvm-svn: 198461
* Switched code from using hasAttr followed by getAttr to simply call getAttr ↵Aaron Ballman2013-12-191-16/+13
| | | | | | | | directly and check the resulting value. No functional changes intended. llvm-svn: 197652
* [ms-cxxabi] The 'most derived' ctor parameter usually comes lastReid Kleckner2013-12-171-3/+6
| | | | | | | | | | | | | | Unlike Itanium's VTTs, the 'most derived' boolean or bitfield is the last parameter for non-variadic constructors, rather than the second. For variadic constructors, the 'most derived' parameter comes after the 'this' parameter. This affects constructor calls and constructor decls in a variety of places. Reviewers: timurrrr Differential Revision: http://llvm-reviews.chandlerc.com/D2405 llvm-svn: 197518
* Add an AdjustedType sugar node for adjusting calling conventionsReid Kleckner2013-12-051-0/+4
| | | | | | | | | | | | | | | | Summary: In general, this type node can be used to represent any type adjustment that occurs implicitly without losing type sugar. The immediate use of this is to adjust the calling conventions of member function pointer types without breaking template instantiation. Fixes PR17996. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2332 llvm-svn: 196451
OpenPOWER on IntegriCloud