aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
AgeCommit message (Collapse)AuthorFilesLines
2014-02-14[IRGen]. Fixes a crash in using Objective-C array Fariborz Jahanian1-2/+2
properties by fixing shouldBindAsLValue to accept arrays (like record types) because we always manipulate them in memory. Patch suggested by John MaCall. // rdar://15610943 llvm-svn: 201428
2014-02-01[ms-cxxabi] Use inalloca on win32 when passing non-trivial C++ objectsReid Kleckner1-1/+12
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
2014-01-31ARM & AArch64: move shared vld/vst intrinsics to common implementation.Tim Northover1-1/+2
llvm-svn: 200526
2014-01-30ARM & AArch64: extend shared NEON implementation to first block.Tim Northover1-2/+1
This extends the refactoring to the whole of the first block of trivial correspondences (as a fairly arbitrary boundary). llvm-svn: 200472
2014-01-30ARM & AArch64: fully share NEON implementation of permutation intrinsicsTim Northover1-0/+3
As a starting point, this moves the CodeGen for NEON permutation instructions (vtrn, vzip, vuzp) into a new shared function. llvm-svn: 200471
2014-01-21Revert "CodeGen: Simplify CodeGenFunction::EmitCaseStmt"Justin Bogner1-0/+5
I misunderstood the discussion on this. The complexity here is justified by the malloc overhead it saves. This reverts commit r199302. llvm-svn: 199700
2014-01-20Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker1-3/+3
Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
2014-01-15CodeGen: Simplify CodeGenFunction::EmitCaseStmtJustin Bogner1-5/+0
Way back in r129652 we tried to avoid emitting an empty block at -O0 for switch cases that did nothing but break. This led to a poor debugging experience as reported in PR9796, so we disabled the optimization for -O0 but left it in for higher optimization levels in r154420. Since the whole point of this was to improve -O0, it's silly to keep the complexity at all. llvm-svn: 199302
2014-01-07Revert "Debug info: Ensure that the last stop point in a function is still ↵Adrian Prantl1-1/+1
within" This reverts commit r198461. llvm-svn: 198714
2014-01-07Revert "Debug info: Implement a cleaner version of r198461. For symmetry with"Adrian Prantl1-1/+1
This reverts commit 198699 so we can get a cleaner patch. llvm-svn: 198713
2014-01-07Debug info: Implement a cleaner version of r198461. For symmetry withAdrian Prantl1-1/+1
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
2014-01-07Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth1-1/+1
encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
2014-01-06CodeGen: Initial instrumentation based PGO implementationJustin Bogner1-4/+24
llvm-svn: 198640
2014-01-03Debug info: Ensure that the last stop point in a function is still withinAdrian Prantl1-1/+1
the lexical block formed by the compound statement that is the function body. rdar://problem/15010825 llvm-svn: 198461
2013-12-17[ms-cxxabi] The 'most derived' ctor parameter usually comes lastReid Kleckner1-0/+2
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
2013-12-04[ms-cxxabi] Construct and destroy call arguments in the correct orderReid Kleckner1-43/+53
Summary: MSVC destroys arguments in the callee from left to right. Because C++ objects have to be destroyed in the reverse order of construction, Clang has to construct arguments from right to left and destroy arguments from left to right. This patch fixes the ordering by reversing the order of evaluation of all call arguments under the MS C++ ABI. Fixes PR18035. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2275 llvm-svn: 196402
2013-11-15[-cxx-abi microsoft] Emit thunks for pointers to virtual member functionsHans Wennborg1-0/+5
Instead of storing the vtable offset directly in the function pointer and doing a branch to check for virtualness at each call site, the MS ABI generates a thunk for calling the function at a specific vtable offset, and puts that in the function pointer. This patch adds support for emitting such thunks. However, it doesn't support pointers to virtual member functions that are variadic, have an incomplete aggregate return type or parameter, or are overriding a function in a virtual base class. Differential Revision: http://llvm-reviews.chandlerc.com/D2104 llvm-svn: 194827
2013-11-14Implement aarch64 neon instruction class misc.Kevin Qin1-0/+5
llvm-svn: 194657
2013-11-05C++1y sized deallocation: if we have a use, but not a definition, of a sizedRichard Smith1-1/+1
deallocation function (and the corresponding unsized deallocation function has been declared), emit a weak discardable definition of the function that forwards to the corresponding unsized deallocation. This allows a C++ standard library implementation to provide both a sized and an unsized deallocation function, where the unsized one does not just call the sized one, for instance by putting both in the same object file within an archive. llvm-svn: 194055
2013-10-20Implement function type checker for the undefined behavior sanitizer.Peter Collingbourne1-0/+1
This uses function prefix data to store function type information at the function pointer. Differential Revision: http://llvm-reviews.chandlerc.com/D1338 llvm-svn: 193058
2013-10-04Do not emit undefined lsrh/ashr for NEON shiftsAmaury de la Vieuville1-0/+2
These IR instructions are undefined when the amount is equal to operand size, but NEON right shifts support such shifts. Work around that by emitting a different IR in these cases. llvm-svn: 191953
2013-10-02Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky1-13/+20
when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
2013-09-29Implement conversion to function pointer for generic lambdas without captures.Faisal Vali1-1/+1
The general strategy is to create template versions of the conversion function and static invoker and then during template argument deduction of the conversion function, create the corresponding call-operator and static invoker specializations, and when the conversion function is marked referenced generate the body of the conversion function using the corresponding static-invoker specialization. Similarly, Codegen does something similar - when asked to emit the IR for a specialized static invoker of a generic lambda, it forwards emission to the corresponding call operator. This patch has been reviewed in person both by Doug and Richard. Richard gave me the LGTM. A few minor changes: - per Richard's request i added a simple check to gracefully inform that captures (init, explicit or default) have not been added to generic lambdas just yet (instead of the assertion violation). - I removed a few lines of code that added the call operators instantiated parameters to the currentinstantiationscope. Not only did it not handle parameter packs, but it is more relevant in the patch for nested lambdas which will follow this one, and fix that problem more comprehensively. - Doug had commented that the original implementation strategy of using the TypeSourceInfo of the call operator to create the static-invoker was flawed and allowed const as a member qualifier to creep into the type of the static-invoker. I currently kludge around it - but after my initial discussion with Doug, with a follow up session with Richard, I have added a FIXME so that a more elegant solution that involves the use of TrivialTypeSourceInfo call followed by the correct wiring of the template parameters to the functionprototypeloc is forthcoming. Thanks! llvm-svn: 191634
2013-09-16Emit an error when attempting to generate IR for SEH __tryReid Kleckner1-0/+1
Currently we silently omit the code in the try and finally bodies, which is pretty bad. This way we fail loudly. llvm-svn: 190809
2013-08-30Revert r189649 because it was breaking sanitizer bots.Yunzhong Gao1-2/+1
llvm-svn: 189660
2013-08-30Fixing a bug where debug info for a local variable gets emitted at file scope.Yunzhong Gao1-1/+2
The patch was discussed in Phabricator. See: http://llvm-reviews.chandlerc.com/D1281 llvm-svn: 189649
2013-08-27Revert "PR14569: Omit debug info for thunks"David Blaikie1-4/+5
This reverts commit r189320. Alexey Samsonov and Dmitry Vyukov presented some arguments for keeping these around - though it still seems like those tasks could be solved by a tool just using the symbol table. In a very small number of cases, thunks may be inlined & debug info might be able to save profilers & similar tools from misclassifying those cases as part of the caller. The extra changes here plumb through the VarDecl for various cases to CodeGenFunction - this provides better fidelity through a few APIs but generally just causes the CGF::StartFunction to fallback to using the name of the IR function as the name in the debug info. The changes to debug-info-global-ctor-dtor.cpp seem like goodness. The two names that go missing (in favor of only emitting those names as linkage names) are names that can be demangled - emitting them only as the linkage name should encourage tools to do just that. Again, thanks to Dinesh Dwivedi for investigation/work on this issue. llvm-svn: 189421
2013-08-26Simplify/clean up debug info suppression in CodeGenFunctionDavid Blaikie1-8/+0
CodeGenFunction is run on only one function - a new object is made for each new function. I would add an assertion/flag to this effect, but there's an exception: ObjC properties involve emitting helper functions that are all emitted by the same CodeGenFunction object, so such a check is not possible/correct. llvm-svn: 189277
2013-08-25CodeGen: Unify two implementations of canDevirtualizeMemberFunctionCall.Benjamin Kramer1-0/+6
They were mostly copy&paste of each other, move it to CodeGenFunction. Of course the two implementations have diverged over time; the one in CGExprCXX seems to be the more modern one so I picked that one and moved it to CGClass which feels like a better home for it. No intended functionality change. llvm-svn: 189203
2013-08-21[CGF] Get rid of passing redundant VTable pointer around in ↵Timur Iskhodzhanov1-2/+0
CodeGenFunction::InitializeVTablePointer[s] llvm-svn: 188909
2013-08-21Abstract out virtual calls and virtual function prologue code generation; ↵Timur Iskhodzhanov1-2/+0
implement them for -cxx-abi microsoft llvm-svn: 188870
2013-08-19PR16933: Don't try to codegen things after we've seen errors.David Blaikie1-2/+1
Refactor the underlying code a bit to remove unnecessary calls to "hasErrorOccurred" & make them consistently at all the entry points to the IRGen ASTConsumer. llvm-svn: 188707
2013-07-26Debug Info / EmitCallArgs: arguments may modify the debug location.Adrian Prantl1-3/+16
Restore it after each argument is emitted. This fixes the scope info for inlined subroutines inside of function argument expressions. (E.g., anything STL). rdar://problem/12592135 llvm-svn: 187240
2013-07-19Simplify the CodeGenFunction::Build*Virtual*Call family of functionsTimur Iskhodzhanov1-3/+1
llvm-svn: 186657
2013-07-05Use SmallVectorImpl& for function arguments instead of SmallVector.Craig Topper1-1/+1
llvm-svn: 185715
2013-06-30Restore r184205 and associated commits (after commit of r185290)Stephen Lin1-4/+0
This allows clang to use the backend parameter attribute 'returned' when generating 'this'-returning constructors and destructors in ARM and MSVC C++ ABIs. llvm-svn: 185291
2013-06-28Delete dead code.Eli Friedman1-1/+0
llvm-svn: 185119
2013-06-19Revert r184205 and associated patches while investigating issue with broken ↵Stephen Lin1-0/+4
buildbot (possible interaction with LTO) <rdar://problem/14209661> llvm-svn: 184384
2013-06-19[CodeGen] Move EHScopeStack into its own headerReid Kleckner1-1/+1
CGCleanup.h isn't meant to be included by all of CodeGen according to John. llvm-svn: 184321
2013-06-18CodeGen: Have 'this'-returning constructors and destructors to take ↵Stephen Lin1-4/+0
advantage of the new backend 'returned' attribute. The backend will now use the generic 'returned' attribute to form tail calls where possible, as well as avoid save-restores of 'this' in some cases (specifically the cases that matter for the ARM C++ ABI). This patch also reverts a prior front-end only partial implementation of these optimizations, since it's no longer required. llvm-svn: 184205
2013-06-12Simplify: we don't need any special-case lifetime extension when initializingRichard Smith1-4/+2
declarations of reference type; they're handled by the general case handling of MaterializeTemporaryExpr. llvm-svn: 183875
2013-06-12PR12086, PR15117Richard Smith1-4/+0
Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
2013-06-12Reapply r183721, reverted in r183776, with a fix for a bug in the former (weRichard Smith1-4/+47
were lacking ExprWithCleanups nodes in some cases where the new approach to lifetime extension needed them). Original commit message: Rework IR emission for lifetime-extended temporaries. Instead of trying to walk into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183859
2013-06-12Add support for complex compound assignments where the LHS is a scalar.Eli Friedman1-0/+2
Fixes <rdar://problem/11224126> and PR12790. llvm-svn: 183821
2013-06-11Revert r183721. It caused cleanups to be delayed too long in some cases.Richard Smith1-47/+4
Testcase to follow. llvm-svn: 183776
2013-06-11Rework IR emission for lifetime-extended temporaries. Instead of trying to walkRichard Smith1-4/+47
into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183721
2013-06-10Make sure we don't emit invalid IR for StmtExprs with complex cleanups.Eli Friedman1-5/+6
Fixes <rdar://problem/14074868>. llvm-svn: 183699
2013-06-09[CodeGen] Move EHScopeStack to CGCleanup.h from CodeGenFunction.hReid Kleckner1-451/+1
No functionality change. CGCleanup.cpp provides the implementation for EHScopeStack, so it seems more consistent to place the class definition in CGCleanup.h. This should also help solve a header ordering problem that I have. llvm-svn: 183631
2013-05-29[ms-cxxabi] Implement MSVC virtual base adjustmentReid Kleckner1-4/+0
While we can't yet emit vbtables, this allows us to find virtual bases of objects constructed in other TUs. This make iostream hello world work, since basic_ostream virtually inherits from basic_ios. Differential Revision: http://llvm-reviews.chandlerc.com/D795 llvm-svn: 182870
2013-05-16Cleanup: Use a member variable to store the SourceLocation for EH code.Adrian Prantl1-6/+6
rdar://problem/13888152 llvm-svn: 181957