summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.h
Commit message (Collapse)AuthorAgeFilesLines
* Don't emit exceptional stackrestore cleanups around inalloca functionsReid Kleckner2015-10-081-4/+1
| | | | | | | | The backend restores the stack pointer after recovering from an exception. This is similar to r245879, but it doesn't try to use the normal cleanup mechanism, so hopefully it won't cause the same breakage. llvm-svn: 249640
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert r245879. Speculative, might have caused crbug.com/524604Nico Weber2015-08-251-0/+1
| | | | llvm-svn: 245965
* [MS ABI] Don't emit stackrestore in cleanupsDavid Majnemer2015-08-241-1/+0
| | | | | | The stackrestore intrinsic isn't meaningful inside of a cleanup funclet. llvm-svn: 245879
* [CodeGen] Reuse stack space from unused function results (with more accurate ↵Leny Kholodov2015-06-081-5/+13
| | | | | | | | | | unused result detection) This patch fixes issues with unused result detection which were found in patch http://reviews.llvm.org/D9743. Differential Revision: http://reviews.llvm.org/D10042 llvm-svn: 239294
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-2/+2
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-1/+1
| | | | llvm-svn: 209272
* [C++11] Replacing CallArgList writeback iterators with iterator_range ↵Aaron Ballman2014-03-171-3/+6
| | | | | | writebacks(). Updating all of the usages of the iterators with range-based for loops, and removing the no-longer-needed iterator versions. llvm-svn: 204062
* [ms-cxxabi] Use inalloca on win32 when passing non-trivial C++ objectsReid Kleckner2014-02-011-0/+21
| | | | | | | | | | | | | | | | | | | 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
* Add CodeGenABITypes.h for use in LLDB.Mark Lacey2013-10-301-180/+0
| | | | | | | | | | | | | | | | | | CodeGenABITypes is a wrapper built on top of CodeGenModule that exposes some of the functionality of CodeGenTypes (held by CodeGenModule), specifically methods that determine the LLVM types appropriate for function argument and return values. I addition to CodeGenABITypes.h, CGFunctionInfo.h is introduced, and the definitions of ABIArgInfo, RequiredArgs, and CGFunctionInfo are moved into this new header from the private headers ABIInfo.h and CGCall.h. Exposing this functionality is one part of making it possible for LLDB to determine the actual ABI locations of function arguments and return values, making it possible for it to determine this for any supported target without hard-coding ABI knowledge in the LLDB code. llvm-svn: 193717
* [ms-cxxabi] Destroy temporary record arguments in the calleeReid Kleckner2013-06-211-0/+26
| | | | | | | | | | | | | | | | | | Itanium destroys them in the caller at the end of the full expression, but MSVC destroys them in the callee. This is further complicated by the need to emit EH-only destructor cleanups in the caller. This should help clang compile MSVC's debug iterators more correctly. There is still an outstanding issue in PR5064 of a memcpy emitted by the LLVM backend, which is not correct for C++ records. Fixes PR16226. Reviewers: rjmccall Differential Revision: http://llvm-reviews.chandlerc.com/D929 llvm-svn: 184543
* Under ARC, when we're passing the address of a strong variableJohn McCall2013-03-231-9/+10
| | | | | | | | | | | | to an out-parameter using the indirect-writeback conversion, and we copied the current value of the variable to the temporary, make sure that we register an intrinsic use of that value with the optimizer so that the value won't get released until we have a chance to retain it. rdar://13195034 llvm-svn: 177813
* Use the AttributeSet instead of AttributeWithIndex.Bill Wendling2013-01-271-2/+2
| | | | | | | In the future, AttributeWithIndex won't be used anymore. Besides, it exposes the internals of the AttributeSet to outside users, which isn't goodness. llvm-svn: 173605
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-2/+0
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate toChandler Carruth2013-01-021-1/+1
| | | | | | | | reflect the migration in r171366. Re-sort the #include lines to reflect the new paths. llvm-svn: 171369
* Fix the required args count for variadic blocks.John McCall2012-12-071-1/+1
| | | | | | | | | | | | | | | | | We were emitting calls to blocks as if all arguments were required --- i.e. with signature (A,B,C,D,...) rather than (A,B,...). This patch fixes that and accounts for the implicit block-context argument as a required argument. In addition, this patch changes the function type under which we call unprototyped functions on platforms like x86-64 that guarantee compatibility of variadic functions with unprototyped function types; previously we would always call such functions under the LLVM type T (...)*, but now we will call them under the type T (A,B,C,D,...)*. This last change should have no material effect except for making the type conventions more explicit; it was a side-effect of the most convenient implementation. llvm-svn: 169588
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+3
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Whether an argument is required (in contrast with being anJohn McCall2012-02-171-38/+116
| | | | | | | | | | | | | | | | | | | | | optional argument passed through the variadic ellipsis) potentially affects how we need to lower it. Propagate this information down to the various getFunctionInfo(...) overloads on CodeGenTypes. Furthermore, rename those overloads to clarify their distinct purposes, and make sure we're calling the right one in the right place. This has a nice side-effect of making it easier to construct a function type, since the 'variadic' bit is no longer separable. This shouldn't really change anything for our existing platforms, with one minor exception --- we should now call variadic ObjC methods with the ... in the "right place" (see the test case), which I guess matters for anyone running GNUStep on MIPS. Mostly it's just a substantial clean-up. llvm-svn: 150788
* now that we have a centralized place to do so, add some using declarations forChris Lattner2011-07-201-5/+5
| | | | | | | some common llvm types: stringref and smallvector. This cleans up the codebase quite a bit. llvm-svn: 135576
* Automatic Reference Counting.John McCall2011-06-151-1/+46
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Skip extra copy from aggregate where it isn't necessary; ↵Eli Friedman2011-05-261-4/+5
| | | | | | | | rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0. Originally r130717, but was backed out due to an ObjC regression. llvm-svn: 132102
* Revert r130717, which caused a regression (<rdar://problem/9402621>).Douglas Gregor2011-05-071-5/+4
| | | | llvm-svn: 131057
* Skip extra copy from aggregate where it isn't necessary; ↵Eli Friedman2011-05-021-4/+5
| | | | | | rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0. llvm-svn: 130717
* Switch CallArgList from an std::pair to a new CallArg struct (which will ↵Eli Friedman2011-05-021-2/+10
| | | | | | eventually gain more members). Working towards modifying call emission to avoid unnecessary copies. llvm-svn: 130700
* PR8369: make __attribute((regparm(0))) work correctly. Original patch byEli Friedman2011-04-091-1/+5
| | | | | | pageexec@freemail.hu, tweaks by me. llvm-svn: 129206
* Use a slightly more semantic interface for emitting call arguments.John McCall2011-03-111-0/+4
| | | | llvm-svn: 127494
* Use the "undergoes default argument promotion" bit on parameters toJohn McCall2011-03-091-3/+5
| | | | | | | | | | simplify the logic of initializing function parameters so that we don't need both a variable declaration and a type in FunctionArgList. This also means that we need to propagate the CGFunctionInfo down in a lot of places rather than recalculating it from the FAL. There's more we can do to eliminate redundancy here, and I've left FIXMEs behind to do it. llvm-svn: 127314
* relax the CGFunctionInfo::CGFunctionInfo ctor to allow any sequence Chris Lattner2010-06-291-5/+3
| | | | | | of CanQualTypes to be passed in. llvm-svn: 107176
* Remember the regparm attribute in FunctionType::ExtInfo.Rafael Espindola2010-03-301-0/+8
| | | | | | Fixes PR3782. llvm-svn: 99940
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-4/+3
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Use the power of types to track down another canonicalization bug inJohn McCall2010-02-261-7/+10
| | | | | | the ABI-computation interface. Fixes <rdar://problem/7691046>. llvm-svn: 97197
* Canonicalize parameter and return types before computing ABI info. EliminatesJohn McCall2010-02-241-1/+1
| | | | | | | | | | | a common source of oddities and, in theory, removes some redundant ABI computations. Also fixes a miscompile I introduced yesterday by refactoring some code and causing a slightly different code path to be taken that didn't perform *parameter* type canonicalization, just normal type canonicalization; this in turn caused a bit of ABI code to misfire because it was looking for 'double' or 'float' but received 'const float'. llvm-svn: 97030
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-0/+9
| | | | | | | | | | | | follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). llvm-svn: 95436
* Fill in the return value slot in CGExprAgg::VisitCallExpr. This takes us ↵Anders Carlsson2009-12-241-0/+2
| | | | | | halfway towards fixing PR5824. llvm-svn: 92142
* Add a ReturnValueSlot class. Change the argument order in EmitCall to match ↵Anders Carlsson2009-12-241-1/+17
| | | | | | the other overload better. llvm-svn: 92136
* Change CodeGenModule::ConstructTypeAttributes to return the calling conventionDaniel Dunbar2009-09-121-1/+17
| | | | | | to use, and allow the ABI implementation to override the calling convention. llvm-svn: 81593
* Add CallingConvention argument to CGFunctionInfo.Daniel Dunbar2009-09-111-1/+10
| | | | | | - Currently unused. llvm-svn: 81581
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-4/+4
| | | | llvm-svn: 81346
* Unbreak CGFunctionInfo::Profile method and reenable caching of ABIDaniel Dunbar2009-02-051-0/+1
| | | | | | information. llvm-svn: 63799
* Add asserts that the function signature matches the other arguments provideDaniel Dunbar2009-02-041-0/+2
| | | | | | to CGCall functions. llvm-svn: 63775
* Move ABIArgInfo into CGFunctionInfo, computed on creation.Daniel Dunbar2009-02-031-7/+25
| | | | | | - Still have to convert some consumers over. llvm-svn: 63610
* Memoize CGFunctionInfo construction.Daniel Dunbar2009-02-031-1/+15
| | | | llvm-svn: 63576
* Change CGFunctionInfo args iterator to not include the return type.Daniel Dunbar2009-02-021-6/+4
| | | | llvm-svn: 63571
* Thread CGFunctionInfo construction through CodeGenTypes.Daniel Dunbar2009-02-021-6/+2
| | | | | | - Inefficient & leaks memory currently, will be cleaned up subsequently. llvm-svn: 63567
* ABI handling API changes.Daniel Dunbar2009-02-021-8/+5
| | | | | | | | | | | - Lift CGFunctionInfo creation up to callers of EmitCall. - Move isVariadic bit out of CGFunctionInfo, take as argument to GetFunctionType instead. No functionality change. llvm-svn: 63550
* Kill off CGCallInfo, always use CGFunctionInfo for encapsulatingDaniel Dunbar2009-01-311-12/+2
| | | | | | function/call info. llvm-svn: 63466
* Large mechanical patch.Devang Patel2008-09-251-2/+2
| | | | | | | | | | | | | s/ParamAttr/Attribute/g s/PAList/AttrList/g s/FnAttributeWithIndex/AttributeWithIndex/g s/FnAttr/Attribute/g This sets the stage - to implement function notes as function attributes and - to distinguish between function attributes and return value attributes. llvm-svn: 56623
* s/ParamAttrsWithIndex/FnAttributeWithIndex/gDevang Patel2008-09-241-2/+2
| | | | | | Rename to match changes done on llvm side. llvm-svn: 56537
* Move FunctionType conversion into CGCall.cpp:Daniel Dunbar2008-09-101-4/+4
| | | | | | | | | | | | | - Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo. - Updated Obj-C runtimes to use this instead of rolling the llvm::FunctionType by hand. - Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}. Add ABIArgInfo class to encapsulate ABI decision of how to lower types to LLVM. - Will move to target sometime soon. llvm-svn: 56047
* Tweak CGCall functions:Daniel Dunbar2008-09-101-6/+9
| | | | | | | | - Move actual param attr list creation to CodeGenFunction::ConstructParamAttrList. - Make ReturnTypeUsesSret static. llvm-svn: 56038
OpenPOWER on IntegriCloud