summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* This is a little bit far, but optimize cases like:Chris Lattner2010-07-291-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct a { struct c { double x; int y; } x[1]; }; void foo(struct a A) { } into: define void @foo(double %A.coerce0, i32 %A.coerce1) nounwind { entry: %A = alloca %struct.a, align 8 ; <%struct.a*> [#uses=1] %0 = bitcast %struct.a* %A to %struct.c* ; <%struct.c*> [#uses=2] %1 = getelementptr %struct.c* %0, i32 0, i32 0 ; <double*> [#uses=1] store double %A.coerce0, double* %1 %2 = getelementptr %struct.c* %0, i32 0, i32 1 ; <i32*> [#uses=1] store i32 %A.coerce1, i32* %2 instead of: define void @foo(double %A.coerce0, i64 %A.coerce1) nounwind { entry: %A = alloca %struct.a, align 8 ; <%struct.a*> [#uses=1] %0 = bitcast %struct.a* %A to %0* ; <%0*> [#uses=2] %1 = getelementptr %0* %0, i32 0, i32 0 ; <double*> [#uses=1] store double %A.coerce0, double* %1 %2 = getelementptr %0* %0, i32 0, i32 1 ; <i64*> [#uses=1] store i64 %A.coerce1, i64* %2 I only do this now because I never want to look at this code again :) llvm-svn: 109738
* implement a todo: pass a eight-byte that consists of aChris Lattner2010-07-291-6/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | small integer + padding as that small integer. On code like: struct c { double x; int y; }; void bar(struct c C) { } This means that we compile to: define void @bar(double %C.coerce0, i32 %C.coerce1) nounwind { entry: %C = alloca %struct.c, align 8 ; <%struct.c*> [#uses=2] %0 = getelementptr %struct.c* %C, i32 0, i32 0 ; <double*> [#uses=1] store double %C.coerce0, double* %0 %1 = getelementptr %struct.c* %C, i32 0, i32 1 ; <i32*> [#uses=1] store i32 %C.coerce1, i32* %1 instead of: define void @bar(double %C.coerce0, i64 %C.coerce1) nounwind { entry: %C = alloca %struct.c, align 8 ; <%struct.c*> [#uses=3] %0 = bitcast %struct.c* %C to %0* ; <%0*> [#uses=2] %1 = getelementptr %0* %0, i32 0, i32 0 ; <double*> [#uses=1] store double %C.coerce0, double* %1 %2 = getelementptr %0* %0, i32 0, i32 1 ; <i64*> [#uses=1] store i64 %C.coerce1, i64* %2 which gives SRoA heartburn. This implements rdar://5711709, a nice low number :) llvm-svn: 109737
* fix a builder, why didn't clang++ catch this?Chris Lattner2010-07-292-2/+3
| | | | llvm-svn: 109735
* Kill off the 'coerce' ABI passing form. Now 'direct' and 'extend' alwaysChris Lattner2010-07-294-194/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | have a "coerce to" type which often matches the default lowering of Clang type to LLVM IR type, but the coerce case can be handled by making them not be the same. This simplifies things and fixes issues where X86-64 abi lowering would return coerce after making preferred types exactly match up. This caused us to compile: typedef float v4f32 __attribute__((__vector_size__(16))); v4f32 foo(v4f32 X) { return X+X; } into this code at -O0: define <4 x float> @foo(<4 x float> %X.coerce) nounwind { entry: %retval = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2] %coerce = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2] %X.addr = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3] store <4 x float> %X.coerce, <4 x float>* %coerce %X = load <4 x float>* %coerce ; <<4 x float>> [#uses=1] store <4 x float> %X, <4 x float>* %X.addr %tmp = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1] %tmp1 = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1] %add = fadd <4 x float> %tmp, %tmp1 ; <<4 x float>> [#uses=1] store <4 x float> %add, <4 x float>* %retval %0 = load <4 x float>* %retval ; <<4 x float>> [#uses=1] ret <4 x float> %0 } Now we get: define <4 x float> @foo(<4 x float> %X) nounwind { entry: %X.addr = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3] store <4 x float> %X, <4 x float>* %X.addr %tmp = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1] %tmp1 = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1] %add = fadd <4 x float> %tmp, %tmp1 ; <<4 x float>> [#uses=1] ret <4 x float> %add } This implements rdar://8248065 llvm-svn: 109733
* ignore structs that wrap vectors in IR, the abstraction shouldn't add penalty.Chris Lattner2010-07-291-2/+13
| | | | | | | | | | | | | | | | | Before we'd compile the example into something like: %coerce.dive2 = getelementptr %struct.v4f32wrapper* %retval, i32 0, i32 0 ; <<4 x float>*> [#uses=1] %1 = bitcast <4 x float>* %coerce.dive2 to <2 x double>* ; <<2 x double>*> [#uses=1] %2 = load <2 x double>* %1, align 1 ; <<2 x double>> [#uses=1] ret <2 x double> %2 Now we produce: %coerce.dive2 = getelementptr %struct.v4f32wrapper* %retval, i32 0, i32 0 ; <<4 x float>*> [#uses=1] %0 = load <4 x float>* %coerce.dive2, align 1 ; <<4 x float>> [#uses=1] ret <4 x float> %0 llvm-svn: 109732
* move the 'pretty 16-byte vector' inferring code up to be sharedChris Lattner2010-07-291-14/+24
| | | | | | with return values, improving stuff that returns __m128 etc. llvm-svn: 109731
* simplify code by eliminating a premature optimization.Chris Lattner2010-07-291-30/+11
| | | | llvm-svn: 109730
* now that we have CGT around, we can start using preferred typesChris Lattner2010-07-291-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for return values too. Instead of compiling something like: struct foo { int *X; float *Y; }; struct foo test(struct foo *P) { return *P; } to: %1 = type { i64, i64 } define %1 @test(%struct.foo* %P) nounwind { entry: %retval = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2] %P.addr = alloca %struct.foo*, align 8 ; <%struct.foo**> [#uses=2] store %struct.foo* %P, %struct.foo** %P.addr %tmp = load %struct.foo** %P.addr ; <%struct.foo*> [#uses=1] %tmp1 = bitcast %struct.foo* %retval to i8* ; <i8*> [#uses=1] %tmp2 = bitcast %struct.foo* %tmp to i8* ; <i8*> [#uses=1] call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 16, i32 8, i1 false) %0 = bitcast %struct.foo* %retval to %1* ; <%1*> [#uses=1] %1 = load %1* %0, align 1 ; <%1> [#uses=1] ret %1 %1 } We now get the result more type safe, with: define %struct.foo @test(%struct.foo* %P) nounwind { entry: %retval = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2] %P.addr = alloca %struct.foo*, align 8 ; <%struct.foo**> [#uses=2] store %struct.foo* %P, %struct.foo** %P.addr %tmp = load %struct.foo** %P.addr ; <%struct.foo*> [#uses=1] %tmp1 = bitcast %struct.foo* %retval to i8* ; <i8*> [#uses=1] %tmp2 = bitcast %struct.foo* %tmp to i8* ; <i8*> [#uses=1] call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 16, i32 8, i1 false) %0 = load %struct.foo* %retval ; <%struct.foo> [#uses=1] ret %struct.foo %0 } That memcpy is completely terrible, but I don't know how to fix it. llvm-svn: 109729
* sink preferred type stuff lower. It's possible that this mightChris Lattner2010-07-291-27/+33
| | | | | | | improve codegen for vaarg or something, because its codepath is getting preferred types now. llvm-svn: 109728
* dissolve some more complexity: make the x86-64 abi lowering codeChris Lattner2010-07-293-57/+13
| | | | | | | compute its own preferred types instead of having CGT compute them then pass them (circuituously) down into ABIInfo. llvm-svn: 109726
* simplify Get8ByteTypeAtOffset by making it a member of X86_64ABIInfoChris Lattner2010-07-291-24/+20
| | | | llvm-svn: 109724
* now that ABIInfo depends on CGT, it has trivial access to suchChris Lattner2010-07-293-216/+160
| | | | | | | things as TargetData, ASTContext, LLVMContext etc. Stop passing them through so many APIs. llvm-svn: 109723
* cave in to reality and make ABIInfo depend on CodeGenTypes.Chris Lattner2010-07-293-68/+105
| | | | | | This will simplify a bunch of code, coming up next. llvm-svn: 109722
* pass argument vectors in a type that corresponds to the user type ifChris Lattner2010-07-281-2/+14
| | | | | | | | possible. This improves the example to pass <4 x float> instead of <2 x double> but we still get awful code, and still don't get the return value right. llvm-svn: 109700
* tidy upChris Lattner2010-07-282-13/+10
| | | | llvm-svn: 109699
* Override selected builtin names (e.g. "long int" instead of "long") to match ↵Devang Patel2010-07-281-3/+13
| | | | | | names used by gcc in debug info. This makes gdb testsuite happy. llvm-svn: 109694
* fix some break statements to be formatted more consistently,Chris Lattner2010-07-281-16/+7
| | | | | | remove some now-dead code. llvm-svn: 109690
* use Get8ByteTypeAtOffset for the return value path as well so weChris Lattner2010-07-281-60/+63
| | | | | | don't get errors similar to PR7714 on the return path. llvm-svn: 109689
* refactor the autosizing code, eliminating duplicationChris Lattner2010-07-281-58/+53
| | | | | | and making Get8ByteTypeAtOffset always succeed and documented. llvm-svn: 109685
* fix PR7714 by not referencing off the end of a struct when passed by value inChris Lattner2010-07-281-7/+39
| | | | | | | x86-64 abi. This also improves codegen as well. Some refactoring is needed of this code. llvm-svn: 109681
* Fix flags in global block descriptor whenFariborz Jahanian2010-07-281-15/+22
| | | | | | | block returns structs. Fies radar 8241648. Executable test added to llvm test suite. llvm-svn: 109620
* some cleanups and get alignments correct for various coerce cases.Chris Lattner2010-07-281-9/+16
| | | | llvm-svn: 109607
* we are not supposed to create an improper callsite using a CallInstr; leave ↵Gabor Greif2010-07-281-0/+1
| | | | | | a fixme mentioning the simplification when CallSite can clone itself llvm-svn: 109575
* construct debug info for "id" by hand. Devang Patel2010-07-281-3/+35
| | | | | | Tested by mi1-var-obj.exp in gdb testsuite. llvm-svn: 109571
* When creating a jump destination, its scope should be the scope of theJohn McCall2010-07-282-1/+6
| | | | | | | | | enclosing normal cleanup, not the top of the EH stack. I'm *really* surprised this hasn't been causing more problems. Fixes rdar://problem/8231514. llvm-svn: 109569
* Revert r109546, it broke linux build.Argyrios Kyrtzidis2010-07-271-60/+38
| | | | llvm-svn: 109550
* Merge PCHWriterDecl.cpp's isRequiredDecl and ↵Argyrios Kyrtzidis2010-07-271-38/+60
| | | | | | | | | | | | CodeGenModule::MayDeferGeneration into a new function, DeclIsRequiredFunctionOrFileScopedVar. This function is part of the public CodeGen interface since it's essentially a CodeGen predicate that is also needed by the PCH mechanism to determine whether a decl needs to be deserialized during PCH loading for codegen purposes. This fixes current (and avoids future) codegen-from-PCH bugs. llvm-svn: 109546
* Always use current working directory for DW_AT_comp_dir.Devang Patel2010-07-272-14/+1
| | | | llvm-svn: 109535
* Reapply 109303. Devang Patel2010-07-272-14/+40
| | | | llvm-svn: 109507
* 2nd argument of __builtin_expect must be evaluatedFariborz Jahanian2010-07-261-1/+4
| | | | | | | if it hs side-effect to matchgcc's behaviour. Addresses radar 8172109. llvm-svn: 109467
* Test for the presence of EH branch-throughs instead of normal branch-throughs.John McCall2010-07-261-1/+1
| | | | | | I knew this code duplication would bite me. llvm-svn: 109463
* Revert 109303.Devang Patel2010-07-262-40/+14
| | | | llvm-svn: 109426
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-252-11/+0
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Mangle enum constant expressions. Fixes rdar://problem/8204122John McCall2010-07-241-0/+6
| | | | llvm-svn: 109315
* Untangle filename/dirname confusion. Store constructed strings on the side. ↵Devang Patel2010-07-242-14/+40
| | | | | | | | | | | | | | | | | | | | Avoid use of Path.makeAbsolute(). DW_TAG_compile_unit uses two attributes DW_AT_name and DW_AT_comp_dir. Their expected values are: $ clang foo.c -g DW_AT_name - foo.c DW_AT_comp_dir - `pwd` $ clang one/two/foo.c -g DW_AT_name - one/two/foo.c DW_AT_comp_dir - `pwd` $ clang /tmp/one/foo.c -g DW_AT_name - /tmp/one/foo.c DW_AT_comp_dir - empty llvm-svn: 109303
* Support catching Objective C pointers in C++ under the non-fragile NeXT runtime.John McCall2010-07-244-24/+56
| | | | | | Diagnose attempts to do this under the GNU or fragile NeXT runtimes. llvm-svn: 109298
* Return type of a setter call caused byFariborz Jahanian2010-07-241-1/+1
| | | | | | | | use of property-dot syntax using 'super' as receiver is 'void'. This fixes a bug in generating correct API for setter call. Fixes radar 8203426. llvm-svn: 109297
* Revert r109263.Devang Patel2010-07-231-15/+8
| | | | llvm-svn: 109284
* Revise cleanup IR generation to fix a major bug with cleanups (PR7686)John McCall2010-07-238-376/+801
| | | | | | | as well as some significant asymptotic inefficiencies with threading multiple jumps through deep cleanups. llvm-svn: 109274
* There is no need to use separate dir name for AT_comp_dir attribute. Using ↵Devang Patel2010-07-231-8/+15
| | | | | | absolute path for filename allows clients to query complete file location info from gdb breakpoints. Save constructed full file name. llvm-svn: 109263
* Vectors are not integer types, so the type system should not classifyDouglas Gregor2010-07-232-8/+8
| | | | | | | | | | | them as such. Type::is(Signed|Unsigned|)IntegerType() now return false for vector types, and new functions has(Signed|Unsigned|)IntegerRepresentation() cover integer types and vector-of-integer types. This fixes a bunch of latent bugs. Patch from Anton Yartsev! llvm-svn: 109229
* Keep track of artificial scopes introduced by line directives. For example,Devang Patel2010-07-224-1/+83
| | | | | | | | | | | | #line 41 "bar.c" dummy (1, i); #line 24 "bar.h" i = f2 (i); #line 44 "bar.c" This is tested by step-line.exp in gdb testsuite. llvm-svn: 109189
* Turn off EH cleanups for __block variables; they caused some internal buildbotJohn McCall2010-07-221-1/+3
| | | | | | failures. There's a radar tracking this. llvm-svn: 109170
* atch for implementation of objective-c's -WselectorFariborz Jahanian2010-07-221-2/+2
| | | | | | | warning flag in clang. Little more to do for a PCH issue. Radar 6507158. llvm-svn: 109129
* ObjCId is special "struct objc_object". Make this explicit in debug info.Devang Patel2010-07-211-0/+6
| | | | | | This is tested by objc-rbreak.exp in gdb testsuite. llvm-svn: 109050
* Fix regression caused by r108911.Devang Patel2010-07-211-1/+2
| | | | | | | Do not override known debug loc with unknown debug loc. This is tested by sections.exp in gdb testsuite. llvm-svn: 109022
* Don't crash when sending a message inside a block with the non-fragile ABI ↵David Chisnall2010-07-211-1/+1
| | | | | | (GNU runtime). llvm-svn: 109012
* Mark the load after calling objc_msg_lookup_sender() so that it doesn't get ↵David Chisnall2010-07-211-2/+2
| | | | | | optimised away (GNU runtime). llvm-svn: 109010
* Rename LazyCleanup -> Cleanup. No functionality change for these last threeJohn McCall2010-07-2110-178/+173
| | | | | | commits. llvm-svn: 109000
* Rip out EHCleanupScope.John McCall2010-07-214-296/+13
| | | | llvm-svn: 108999
OpenPOWER on IntegriCloud