summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rip out EHCleanupScope.John McCall2010-07-211-183/+4
| | | | llvm-svn: 108999
* Remove unused argument.Devang Patel2010-07-201-1/+1
| | | | llvm-svn: 108946
* Follow the implementation approach suggested by PR6687,Chris Lattner2010-07-201-39/+1
| | | | | | | | | | | | | | | | | | | | | | which generates more efficient and more obviously conformant code. We now test for overflow of the multiply then force the result to -1 if so. On X86, this generates nice code like this: __Z4testl: ## @_Z4testl ## BB#0: ## %entry subl $12, %esp movl $4, %eax mull 16(%esp) testl %edx, %edx movl $-1, %ecx cmovel %eax, %ecx movl %ecx, (%esp) call __Znam addl $12, %esp ret llvm-svn: 108927
* implement rdar://5739832 - operator new should check for overflow in multiply,Chris Lattner2010-07-201-1/+39
| | | | | | | | | | | | | | | | | | | | causing clang to compile this code into something that correctly throws a length error, fixing a potential integer overflow security attack: void *test(long N) { return new int[N]; } int main() { test(1L << 62); } We do this even when exceptions are disabled, because it is better for the code to abort than for the attack to succeed. This is heavily based on a patch that Fariborz wrote. llvm-svn: 108915
* Teach IR generation how to lazily emit cleanups. This has a lot of advantages,John McCall2010-07-131-0/+177
| | | | | | | | | | | | | | | mostly in avoiding unnecessary work at compile time but also in producing more sensible block orderings. Move the destructor cleanups for local variables over to use lazy cleanups. Eventually all cleanups will do this; for now we have some awkward code duplication. Tell IR generation just to never produce landing pads in -fno-exceptions. This is a much more comprehensive solution to a problem which previously was half-solved by checks in most cleanup-generation spots. llvm-svn: 108270
* Provide a hook for the benefit of clients using clang IR gen as a subroutine:John McCall2010-07-061-0/+3
| | | | | | | | | | | | emit metadata associating allocas and global values with a Decl*. This feature is controlled by an option that (intentionally) cannot be enabled on the command line. To use this feature, simply set CodeGenOptions.EmitDeclMetadata = true; and then interpret the completely underspecified metadata. :) llvm-svn: 107739
* When destroying a cleanup, kill any references to instructions in the entryJohn McCall2010-07-061-0/+6
| | | | | | | | block before deleting it. Fixes PR7575. This really just a short-term fix before implementing lazy cleanups. llvm-svn: 107676
* Validated by nightly-test runs on x86 and x86-64 darwin, including afterJohn McCall2010-07-061-191/+360
| | | | | | | | | | | | | | | | | | | | | | | | self-host. Hopefully these results hold up on different platforms. I tried to keep the GNU ObjC runtime happy, but it's hard for me to test. Reimplement how clang generates IR for exceptions. Instead of creating new invoke destinations which sequentially chain to the previous destination, push a more semantic representation of *why* we need the cleanup/catch/filter behavior, then collect that information into a single landing pad upon request. Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional control flow) are generated, since it's actually fairly closely tied in with the former. Remove the need to track which cleanup scope a block is associated with. Document a lot of previously poorly-understood (by me, at least) behavior. The new framework implements the Horrible Hack (tm), which requires every landing pad to have a catch-all so that inlining will work. Clang no longer requires the Horrible Hack just to make exceptions flow correctly within a function, however. The HH is an unfortunate requirement of LLVM's EH IR. llvm-svn: 107631
* Revert "IRgen: Make sure any prolog instructions get debug info.", the lexicalDaniel Dunbar2010-07-011-1/+0
| | | | | | | scope hasn't been set up yet so this isn't valid. It was just a cleanup to the IR, so I'm going to ignore it for now. llvm-svn: 107356
* IRgen: Make sure any prolog instructions get debug info.Daniel Dunbar2010-06-301-0/+1
| | | | llvm-svn: 107320
* misc tidyingChris Lattner2010-06-271-2/+1
| | | | llvm-svn: 106978
* finally get around to doing a significant cleanup to irgen:Chris Lattner2010-06-271-22/+18
| | | | | | | | have CGF create and make accessible standard int32,int64 and intptr types. This fixes a ton of 80 column violations introduced by LLVMContextification and cleans up stuff a lot. llvm-svn: 106977
* Change IR generation for return (in the simple case) to avoid doing sillyChris Lattner2010-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | load/store nonsense in the epilog. For example, for: int foo(int X) { int A[100]; return A[X]; } we used to generate: %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i64 %idxprom ; <i32*> [#uses=1] %tmp1 = load i32* %arrayidx ; <i32> [#uses=1] store i32 %tmp1, i32* %retval %0 = load i32* %retval ; <i32> [#uses=1] ret i32 %0 } which codegen'd to this code: _foo: ## @foo ## BB#0: ## %entry subq $408, %rsp ## imm = 0x198 movl %edi, 400(%rsp) movl 400(%rsp), %edi movslq %edi, %rax movl (%rsp,%rax,4), %edi movl %edi, 404(%rsp) movl 404(%rsp), %eax addq $408, %rsp ## imm = 0x198 ret Now we generate: %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i64 %idxprom ; <i32*> [#uses=1] %tmp1 = load i32* %arrayidx ; <i32> [#uses=1] ret i32 %tmp1 } and: _foo: ## @foo ## BB#0: ## %entry subq $408, %rsp ## imm = 0x198 movl %edi, 404(%rsp) movl 404(%rsp), %edi movslq %edi, %rax movl (%rsp,%rax,4), %eax addq $408, %rsp ## imm = 0x198 ret This actually does matter, cutting out 2000 lines of IR from CGStmt.ll for example. Another interesting effect is that altivec.h functions which are dead now get dce'd by the inliner. Hence all the changes to builtins-ppc-altivec.c to ensure the calls aren't dead. llvm-svn: 106970
* polish the -finstrument-functions implementation, patch by Nelson Elhage!Chris Lattner2010-06-231-3/+8
| | | | llvm-svn: 106618
* implement support for -finstrument-functions, patch by NelsonChris Lattner2010-06-221-0/+41
| | | | | | Elhage! llvm-svn: 106507
* Rename __tcf_ to __cxx_global_array_dtor. Remove the ↵Anders Carlsson2010-06-081-2/+1
| | | | | | UniqueAggreDestructorCount from CodeGenFunction and let LLVM handle uniquing the internal functions instead. llvm-svn: 105648
* Improve name mangling for blocks and support mangling of static localDouglas Gregor2010-05-251-0/+1
| | | | | | | | | variables within blocks. We loosely follow GCC's mangling, but since these are always internal symbols the names don't really matter. I intend to revisit block mangling later, because GCC's mangling is rather verbose. <rdar://problem/8015719>. llvm-svn: 104610
* Re-land the fix for PR7139.Anders Carlsson2010-05-221-1/+20
| | | | llvm-svn: 104446
* Unbreak self-host.Anders Carlsson2010-05-211-20/+1
| | | | llvm-svn: 104390
* Rename CodeGenFunction::EmitMemSetToZero to EmitNullInitialization. Handle ↵Anders Carlsson2010-05-211-1/+20
| | | | | | setting null data member pointers correctly. Fixes PR7139. llvm-svn: 104387
* Don't copy or initialize empty classes. Fixes PR7012.Anders Carlsson2010-05-031-0/+8
| | | | llvm-svn: 102891
* Complete reimplementation of the synthesis for implicitly-defined copyDouglas Gregor2010-05-011-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assignment operators. Previously, Sema provided type-checking and template instantiation for copy assignment operators, then CodeGen would synthesize the actual body of the copy constructor. Unfortunately, the two were not in sync, and CodeGen might pick a copy-assignment operator that is different from what Sema chose, leading to strange failures, e.g., link-time failures when CodeGen called a copy-assignment operator that was not instantiation, run-time failures when copy-assignment operators were overloaded for const/non-const references and the wrong one was picked, and run-time failures when by-value copy-assignment operators did not have their arguments properly copy-initialized. This implementation synthesizes the implicitly-defined copy assignment operator bodies in Sema, so that the resulting ASTs encode exactly what CodeGen needs to do; there is no longer any special code in CodeGen to synthesize copy-assignment operators. The synthesis of the body is relatively simple, and we generate one of three different kinds of copy statements for each base or member: - For a class subobject, call the appropriate copy-assignment operator, after overload resolution has determined what that is. - For an array of scalar types or an array of class types that have trivial copy assignment operators, construct a call to __builtin_memcpy. - For an array of class types with non-trivial copy assignment operators, synthesize a (possibly nested!) for loop whose inner statement calls the copy constructor. - For a scalar type, use built-in assignment. This patch fixes at least a few tests cases in Boost.Spirit that were failing because CodeGen picked the wrong copy-assignment operator (leading to link-time failures), and I suspect a number of undiagnosed problems will also go away with this change. Some of the diagnostics we had previously have gotten worse with this change, since we're going through generic code for our type-checking. I will improve this in a subsequent patch. llvm-svn: 102853
* Fix debug info for cleanup block.Devang Patel2010-04-131-0/+5
| | | | llvm-svn: 101100
* Reapply patch for adding support for address spaces and added a isVolatile ↵Mon P Wang2010-04-041-2/+4
| | | | | | field to memcpy, memmove, and memset. llvm-svn: 100305
* Revert r100193 since it causes failures in objc in clangMon P Wang2010-04-021-4/+2
| | | | llvm-svn: 100200
* Reapply patch for adding support for address spaces and added a isVolatile ↵Mon P Wang2010-04-021-2/+4
| | | | | | field to memcpy, memmove, and memset. llvm-svn: 100193
* Revert Mon Ping's 99930 due to broken llvm-gcc buildbots.Bob Wilson2010-03-301-4/+2
| | | | llvm-svn: 99949
* Added support for address spaces and added a isVolatile field to memcpy, ↵Mon P Wang2010-03-301-2/+4
| | | | | | memmove, and memset llvm-svn: 99930
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-3/+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
* Rename CGVtableInfo to CodeGenVTables in preparation of adding another ↵Anders Carlsson2010-03-231-1/+1
| | | | | | VTableInfo class. llvm-svn: 99250
* Eliminate the default arguments to ASTContext::getFunctionType(),Douglas Gregor2010-02-211-1/+4
| | | | | | | | fixing up a few callers that thought they were propagating NoReturn information but were in fact saying something about exception specifications. llvm-svn: 96766
* More refactoring around constructor/destructor code generation.John McCall2010-02-191-73/+13
| | | | | | | | | | | | Fix some bugs with function-try-blocks and simplify normal try-block code generation. This implementation excludes a deleting destructor's call to operator delete() from the function-try-block, which I believe is correct but which I can't find straightforward support for at a moment's glance. llvm-svn: 96670
* Make deleting and complete dtor variants defer to other dtor variants byJohn McCall2010-02-181-12/+42
| | | | | | | | calling them as subroutines. This triggers whenever the alias optimization doesn't, i.e. when the dtor has linkonce linkage or there are virtual bases or it's the deleting dtor. llvm-svn: 96605
* Extract out function-body code generation into its own method. No functionalityJohn McCall2010-02-181-71/+55
| | | | | | change. llvm-svn: 96564
* IRgen optimization: cache the value of 'this' and 'vtt' instead ofJohn McCall2010-02-161-3/+9
| | | | | | | | repeatedly reloading from an alloca. We still need to create the alloca for debug info purposes (although we currently create it in all cases because of some abstraction boundaries that're hard to break down). llvm-svn: 96403
* IRgen: Switch 'retval' to use CreateIRTemp.Daniel Dunbar2010-02-161-2/+2
| | | | llvm-svn: 96376
* Pass inline keyword to optimizer as the new InlineHint function attribute.Jakob Stoklund Olesen2010-02-091-0/+10
| | | | | | | | | | At the moment the inlinehint attribute is ignored by the Inliner unless you pass a -respect-inlinehint option. This will soon be the default. The inlinehint attribute is set if the inline keyword is explicitly specified on any declaration. llvm-svn: 95623
* Make sure to set vtable pointers in the destructors as well.Anders Carlsson2010-02-071-0/+2
| | | | llvm-svn: 95525
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-1/+3
| | | | | | | | | | | | 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
* Rename StartConditionalBranch/FinishConditionalBranch to ↵Anders Carlsson2010-02-041-4/+4
| | | | | | BeginConditionalBranch/EndConditionalBranch. llvm-svn: 95308
* Fix a nasty bug where temporaries weren't marked as being conditional in ↵Anders Carlsson2010-01-241-0/+8
| | | | | | some cases. llvm-svn: 94341
* Emit human readable names for c/c++ functions. Avoid emitting linkage name ↵Devang Patel2010-01-141-7/+1
| | | | | | if it matches regular name. llvm-svn: 93383
* Roll out ASTContext::getTypeSizeInChars(), replacing instances ofKen Dyck2010-01-111-1/+1
| | | | | | | | | | "ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits ones as appropriate. Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType, fromQuantity(), and getQuantity() for clarity. llvm-svn: 93153
* Correctly pass VTT parameters to constructors and destructors. The VTTs ↵Anders Carlsson2010-01-021-21/+2
| | | | | | aren't yet used in the ctors/dtors, but that will follow. llvm-svn: 92409
* Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, ↵Douglas Gregor2009-12-221-1/+1
| | | | | | since the context is available in the Decl llvm-svn: 91862
* Switch codegen for -fcatch-undefined-bahavior over to __builtin_trapMike Stump2009-12-151-1/+1
| | | | | | instead of abort to improve codesize and codegen. llvm-svn: 91374
* Add support for detecting undefined shift behavior. WIP.Mike Stump2009-12-141-2/+2
| | | | llvm-svn: 91341
* Implement runtime checks for undefined behavior. WIP.Mike Stump2009-12-121-1/+2
| | | | | | | | | | | | | This implements a new flag -fcatch-undefined-behavior. The flag turns on additional runtime checks for: T a[I]; a[i] abort when i < 0 or i >= I. Future stuff includes shifts by >= bitwidth amounts. llvm-svn: 91198
* Get rid of static variable.Eli Friedman2009-12-101-1/+2
| | | | llvm-svn: 91041
* Ensure we only generate one terminate handler.Mike Stump2009-12-101-1/+1
| | | | llvm-svn: 90998
OpenPOWER on IntegriCloud