summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX
Commit message (Collapse)AuthorAgeFilesLines
* Mangle arrays in the Microsoft C++ Mangler. It's not quite finished (itCharles Davis2010-06-301-0/+10
| | | | | | | | | doesn't mangle array parameters right), but I think that should be fixed in Sema (Doug, John, what do you think?). Also, stub out the remaining mangleType() routines. llvm-svn: 107264
* Revert r107216, "fix PR7523, which was caused by the ABI code calling ↵Daniel Dunbar2010-06-301-15/+0
| | | | | | ConvertType instead", it is part of a boostrap breaking sequence. llvm-svn: 107231
* fix PR7523, which was caused by the ABI code calling ConvertType insteadChris Lattner2010-06-291-0/+15
| | | | | | | of ConvertTypeRecursive when it needed to in a few cases, causing pointer types to get resolved at the wrong time. llvm-svn: 107216
* IRgen: Assignment to Objective-C properties shouldn't reload the value (whichDaniel Dunbar2010-06-291-2/+1
| | | | | | | | would trigger an extra method call). - While in the area, I also changed Clang to not emit an unnecessary load from 'x' in cases like 'y = (x = 1)'. llvm-svn: 107210
* tests: Use %clangxx when using driver for C++, in case C++ support is disabled.Daniel Dunbar2010-06-292-3/+3
| | | | llvm-svn: 107153
* Change X86_64ABIInfo to have ASTContext and TargetData ivars toChris Lattner2010-06-291-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | avoid passing ASTContext down through all the methods it has. When classifying an argument, or argument piece, as INTEGER, check to see if we have a pointer at exactly the same offset in the preferred type. If so, use that pointer type instead of i64. This allows us to compile A function taking a stringref into something like this: define i8* @foo(i64 %D.coerce0, i8* %D.coerce1) nounwind ssp { entry: %D = alloca %struct.DeclGroup, align 8 ; <%struct.DeclGroup*> [#uses=4] %0 = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1] store i64 %D.coerce0, i64* %0 %1 = getelementptr %struct.DeclGroup* %D, i32 0, i32 1 ; <i8**> [#uses=1] store i8* %D.coerce1, i8** %1 %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1] %tmp1 = load i64* %tmp ; <i64> [#uses=1] %tmp2 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 1 ; <i8**> [#uses=1] %tmp3 = load i8** %tmp2 ; <i8*> [#uses=1] %add.ptr = getelementptr inbounds i8* %tmp3, i64 %tmp1 ; <i8*> [#uses=1] ret i8* %add.ptr } instead of this: define i8* @foo(i64 %D.coerce0, i64 %D.coerce1) nounwind ssp { entry: %D = alloca %struct.DeclGroup, align 8 ; <%struct.DeclGroup*> [#uses=3] %0 = insertvalue %0 undef, i64 %D.coerce0, 0 ; <%0> [#uses=1] %1 = insertvalue %0 %0, i64 %D.coerce1, 1 ; <%0> [#uses=1] %2 = bitcast %struct.DeclGroup* %D to %0* ; <%0*> [#uses=1] store %0 %1, %0* %2, align 1 %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1] %tmp1 = load i64* %tmp ; <i64> [#uses=1] %tmp2 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 1 ; <i8**> [#uses=1] %tmp3 = load i8** %tmp2 ; <i8*> [#uses=1] %add.ptr = getelementptr inbounds i8* %tmp3, i64 %tmp1 ; <i8*> [#uses=1] ret i8* %add.ptr } This implements rdar://7375902 - [codegen quality] clang x86-64 ABI lowering code punishing StringRef llvm-svn: 107123
* add IR names to coerced arguments.Chris Lattner2010-06-291-5/+5
| | | | llvm-svn: 107105
* Change CGCall to handle the "coerce" case where the coerce-to typeChris Lattner2010-06-281-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is a FCA to pass each of the elements as individual scalars. This produces code fast isel is less likely to reject and is easier on the optimizers. For example, before we would compile: struct DeclGroup { long NumDecls; char * Y; }; char * foo(DeclGroup D) { return D.NumDecls+D.Y; } to: %struct.DeclGroup = type { i64, i64 } define i64 @_Z3foo9DeclGroup(%struct.DeclGroup) nounwind { entry: %D = alloca %struct.DeclGroup, align 8 ; <%struct.DeclGroup*> [#uses=3] store %struct.DeclGroup %0, %struct.DeclGroup* %D, align 1 %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1] %tmp1 = load i64* %tmp ; <i64> [#uses=1] %tmp2 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 1 ; <i64*> [#uses=1] %tmp3 = load i64* %tmp2 ; <i64> [#uses=1] %add = add nsw i64 %tmp1, %tmp3 ; <i64> [#uses=1] ret i64 %add } Now we get: %0 = type { i64, i64 } %struct.DeclGroup = type { i64, i8* } define i8* @_Z3foo9DeclGroup(i64, i64) nounwind { entry: %D = alloca %struct.DeclGroup, align 8 ; <%struct.DeclGroup*> [#uses=3] %2 = insertvalue %0 undef, i64 %0, 0 ; <%0> [#uses=1] %3 = insertvalue %0 %2, i64 %1, 1 ; <%0> [#uses=1] %4 = bitcast %struct.DeclGroup* %D to %0* ; <%0*> [#uses=1] store %0 %3, %0* %4, align 1 %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1] %tmp1 = load i64* %tmp ; <i64> [#uses=1] %tmp2 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 1 ; <i8**> [#uses=1] %tmp3 = load i8** %tmp2 ; <i8*> [#uses=1] %add.ptr = getelementptr inbounds i8* %tmp3, i64 %tmp1 ; <i8*> [#uses=1] ret i8* %add.ptr } Elimination of the FCA inside the function is still-to-come. llvm-svn: 107099
* pass/return structs of char and short as i8/i16 to avoidChris Lattner2010-06-282-2/+2
| | | | | | aweful through-memory coersion, just like we do for i32 now. llvm-svn: 107078
* X86-64:Chris Lattner2010-06-282-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pass/return structs of float/int as float/i32 instead of double/i64 to make the code generated for ABI cleaner. Passing in the low part of a double is the same as passing in a float. For example, we now compile: struct DeclGroup { float NumDecls; }; float foo(DeclGroup D); void bar(DeclGroup *D) { foo(*D); } into: %struct.DeclGroup = type { float } define void @_Z3barP9DeclGroup(%struct.DeclGroup* %D) nounwind { entry: %D.addr = alloca %struct.DeclGroup*, align 8 ; <%struct.DeclGroup**> [#uses=2] %agg.tmp = alloca %struct.DeclGroup, align 4 ; <%struct.DeclGroup*> [#uses=2] store %struct.DeclGroup* %D, %struct.DeclGroup** %D.addr %tmp = load %struct.DeclGroup** %D.addr ; <%struct.DeclGroup*> [#uses=1] %tmp1 = bitcast %struct.DeclGroup* %agg.tmp to i8* ; <i8*> [#uses=1] %tmp2 = bitcast %struct.DeclGroup* %tmp to i8* ; <i8*> [#uses=1] call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 4, i32 4, i1 false) %coerce.dive = getelementptr %struct.DeclGroup* %agg.tmp, i32 0, i32 0 ; <float*> [#uses=1] %0 = load float* %coerce.dive, align 1 ; <float> [#uses=1] %call = call float @_Z3foo9DeclGroup(float %0) ; <float> [#uses=0] ret void } instead of: %struct.DeclGroup = type { float } define void @_Z3barP9DeclGroup(%struct.DeclGroup* %D) nounwind { entry: %D.addr = alloca %struct.DeclGroup*, align 8 ; <%struct.DeclGroup**> [#uses=2] %agg.tmp = alloca %struct.DeclGroup, align 4 ; <%struct.DeclGroup*> [#uses=2] %tmp3 = alloca double ; <double*> [#uses=2] store %struct.DeclGroup* %D, %struct.DeclGroup** %D.addr %tmp = load %struct.DeclGroup** %D.addr ; <%struct.DeclGroup*> [#uses=1] %tmp1 = bitcast %struct.DeclGroup* %agg.tmp to i8* ; <i8*> [#uses=1] %tmp2 = bitcast %struct.DeclGroup* %tmp to i8* ; <i8*> [#uses=1] call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 4, i32 4, i1 false) %coerce.dive = getelementptr %struct.DeclGroup* %agg.tmp, i32 0, i32 0 ; <float*> [#uses=1] %0 = bitcast double* %tmp3 to float* ; <float*> [#uses=1] %1 = load float* %coerce.dive ; <float> [#uses=1] store float %1, float* %0, align 1 %2 = load double* %tmp3 ; <double> [#uses=1] %call = call float @_Z3foo9DeclGroup(double %2) ; <float> [#uses=0] ret void } which is this machine code (at -O0): __Z3barP9DeclGroup: subq $24, %rsp movq %rdi, 16(%rsp) movq 16(%rsp), %rdi leaq 8(%rsp), %rax movl (%rdi), %ecx movl %ecx, (%rax) movss 8(%rsp), %xmm0 callq __Z3foo9DeclGroup addq $24, %rsp ret vs this: __Z3barP9DeclGroup: subq $24, %rsp movq %rdi, 16(%rsp) movq 16(%rsp), %rdi leaq 8(%rsp), %rax movl (%rdi), %ecx movl %ecx, (%rax) movss 8(%rsp), %xmm0 movss %xmm0, (%rsp) movsd (%rsp), %xmm0 callq __Z3foo9DeclGroup addq $24, %rsp ret At -O3, it is the difference between this now: __Z3barP9DeclGroup: movss (%rdi), %xmm0 jmp __Z3foo9DeclGroup # TAILCALL vs this before: __Z3barP9DeclGroup: movl (%rdi), %eax movd %rax, %xmm0 jmp __Z3foo9DeclGroup # TAILCALL llvm-svn: 107048
* tests: Rewrite test to check intent instead of implementation.Daniel Dunbar2010-06-281-13/+12
| | | | llvm-svn: 107024
* Correctly destroy reference temporaries with global storage. Remove ↵Anders Carlsson2010-06-271-1/+35
| | | | | | ErrorUnsupported call when binding a global reference to a non-lvalue. Fixes PR7326. llvm-svn: 106983
* Change IR generation for return (in the simple case) to avoid doing sillyChris Lattner2010-06-271-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* implement rdar://7432000 - signed negate should codegen as NSW.Chris Lattner2010-06-261-2/+2
| | | | | | While I'm in there, adjust pointer to member adjustments as well. llvm-svn: 106955
* Mangle pointer and (lvalue) reference types in the Microsoft C++ Mangler.Charles Davis2010-06-261-2/+8
| | | | | | | Also, fix mangling of throw specs. Turns out MSVC totally ignores throw specs when mangling names. llvm-svn: 106937
* Try making BuildBot happy again.Fariborz Jahanian2010-06-251-3/+3
| | | | llvm-svn: 106898
* Test case for pr7490.Fariborz Jahanian2010-06-251-0/+16
| | | | llvm-svn: 106887
* Patch to correctly mangle block helper functionsFariborz Jahanian2010-06-241-0/+48
| | | | | | | when block literal is declared inside a ctor/dtor. Fixes radr 8096995. llvm-svn: 106700
* Instantiations subject to an explicit template instantiationDouglas Gregor2010-06-211-0/+26
| | | | | | | declaration have default visibility even under -fvisibility=hidden. Fixes <rdar://problem/8109763>. llvm-svn: 106440
* Fixes a corner case bug whereby declaring and defining an extern variable in a Fariborz Jahanian2010-06-211-0/+37
| | | | | | | particular sequence causes its definition to not be generated in the object file. (fixes radar 8071804). llvm-svn: 106424
* Fix for PR7415: refactor CodeGenModule::MayDeferGeneration and make it lessEli Friedman2010-06-191-0/+12
| | | | | | conservative for static variables in templated classes. llvm-svn: 106385
* Fix PR7097, a bad interaction between -fno-use-cxa-atexit andChris Lattner2010-06-191-0/+3
| | | | | | -mconstructor-aliases by using a WeakVH instead of a raw pointer. llvm-svn: 106384
* Mangle tag types (unions, structs, classes, enums) in the Microsoft C++ Mangler.Charles Davis2010-06-181-0/+23
| | | | | | | Also, test that static members with default visibility in a struct have the right mangling. llvm-svn: 106276
* Do not treat @selector as lvalue (unlike g++).Fariborz Jahanian2010-06-171-0/+14
| | | | | | Patch by Nico Weber (pr7390). llvm-svn: 106242
* Mangle operator names in the Microsoft C++ Mangler.Charles Davis2010-06-171-0/+4
| | | | llvm-svn: 106211
* Change the test for which ABI/CC to use on ARM to be base on the environmentRafael Espindola2010-06-161-1/+1
| | | | | | (the last argument of the triple). llvm-svn: 106131
* Fix tests that I missed from my previous commit.Rafael Espindola2010-06-162-4/+3
| | | | llvm-svn: 106118
* Start mangling function types in the Microsoft C++ Mangler.Charles Davis2010-06-161-1/+13
| | | | llvm-svn: 106081
* Moved objective-c++ code gen. tests to their own directory andFariborz Jahanian2010-06-152-130/+0
| | | | | | added a new test case (related to radar 8070772). llvm-svn: 106067
* Patch adds support for copying of thoseFariborz Jahanian2010-06-152-0/+130
| | | | | | | | objective-c++ class objects which have GC'able objc object pointers and need to use ObjC's objc_memmove_collectable API (radar 8070772). llvm-svn: 106061
* Implement -fvisibility-inlines-hidden. <rdar://problem/7819834>Douglas Gregor2010-06-151-0/+57
| | | | llvm-svn: 106003
* Make sure to set the visible on a vtable; VTTs and typeinfo alreadyDouglas Gregor2010-06-141-1/+19
| | | | | | handle visibility properly. Fixes <rdar://problem/8091955>. llvm-svn: 105977
* Add name mangling for address spaces. We use the vendor-extensionDouglas Gregor2010-06-141-0/+6
| | | | | | | mangling for types, where the <source-name> is ASxxx (xxx is the address-space number). llvm-svn: 105975
* Microsoft C++ Mangler:Charles Davis2010-06-141-2/+17
| | | | | | | | - Mangle qualifiers. - Start mangling variables' types into the name. A variable declared with a builtin type should now mangle properly. llvm-svn: 105931
* Microsoft C++ Mangler:Charles Davis2010-06-121-2/+8
| | | | | | | - Don't mangle static variables at global scope. - Add support for mangling builtin types. This will be used later. llvm-svn: 105881
* When mangling for the Microsoft C++ ABI, mangle variables in the globalCharles Davis2010-06-111-1/+2
| | | | | | namespace, too. llvm-svn: 105809
* Start implementing the Microsoft-style name mangler. Mangle simple namesCharles Davis2010-06-111-0/+6
| | | | | | | | | | | (but not their types; that's later). NOTE: Right now, variables in the global namespace don't get mangled, even though they're supposed to be. This is because the default mangler implements the shouldMangleDeclName() method that tells clang not to mangle them. This will be fixed in a later patch. llvm-svn: 105805
* Fix test.Anders Carlsson2010-06-091-1/+2
| | | | llvm-svn: 105668
* Try to fix buildbot tests.Anders Carlsson2010-06-081-5/+5
| | | | llvm-svn: 105660
* Add test case.Anders Carlsson2010-06-081-0/+23
| | | | llvm-svn: 105651
* Block Code Gen. API. Call destructor on descriptiorFariborz Jahanian2010-06-081-1/+3
| | | | | | entry previously constructed via copy constructor. llvm-svn: 105641
* Fixes a typo which prevented proper code gen. forFariborz Jahanian2010-06-081-2/+10
| | | | | | copy-in of c++ class objects into blocks. llvm-svn: 105622
* Correctly mangle static variables of anonymous struct/union type.Anders Carlsson2010-06-081-1/+33
| | | | llvm-svn: 105606
* Add test for previous commit.Rafael Espindola2010-06-081-0/+20
| | | | llvm-svn: 105594
* Correctly align large arrays in x86-64. This fixes PR5599.Rafael Espindola2010-06-041-1/+1
| | | | llvm-svn: 105500
* Build AST for copy-construction of copied-inFariborz Jahanian2010-06-041-2/+2
| | | | | | class object in blocks and carry it to IRGen. llvm-svn: 105487
* For C++ copied in objects, use copy constructors inFariborz Jahanian2010-06-041-0/+18
| | | | | | | | setting up block's descriptor. This is on going work to support c++ specific issues in setting up blocks various APIs. llvm-svn: 105469
* Check the output of this test.Eli Friedman2010-06-031-1/+7
| | | | llvm-svn: 105434
* Think through my commit this time.Eli Friedman2010-06-031-1/+1
| | | | llvm-svn: 105433
* Make sure this test doesn't break when we disallow throwing an exceptionEli Friedman2010-06-031-2/+1
| | | | | | in -fno-exceptions mode. llvm-svn: 105432
OpenPOWER on IntegriCloud