Chris Lattner
fe34c1d53e
Kill off the 'coerce' ABI passing form. Now 'direct' and 'extend' always
...
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
2010-07-29 06:26:06 +00:00
Chris Lattner
9fa15c3608
ignore structs that wrap vectors in IR, the abstraction shouldn't add penalty.
...
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
2010-07-29 05:02:29 +00:00
Chris Lattner
4200fe4e50
move the 'pretty 16-byte vector' inferring code up to be shared
...
with return values, improving stuff that returns __m128 etc.
llvm-svn: 109731
2010-07-29 04:56:46 +00:00
Chris Lattner
ce1bd754d8
simplify code by eliminating a premature optimization.
...
llvm-svn: 109730
2010-07-29 04:51:12 +00:00
Chris Lattner
3a44c7e55d
now that we have CGT around, we can start using preferred types
...
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
2010-07-29 04:46:19 +00:00
Chris Lattner
029c0f1681
sink preferred type stuff lower. It's possible that this might
...
improve codegen for vaarg or something, because its codepath is
getting preferred types now.
llvm-svn: 109728
2010-07-29 04:41:05 +00:00
Chris Lattner
22326a10a7
dissolve some more complexity: make the x86-64 abi lowering code
...
compute its own preferred types instead of having CGT compute
them then pass them (circuituously) down into ABIInfo.
llvm-svn: 109726
2010-07-29 02:31:05 +00:00
Chris Lattner
c11301c76e
simplify Get8ByteTypeAtOffset by making it a member of X86_64ABIInfo
...
llvm-svn: 109724
2010-07-29 02:20:19 +00:00
Chris Lattner
458b2aaee0
now that ABIInfo depends on CGT, it has trivial access to such
...
things as TargetData, ASTContext, LLVMContext etc. Stop passing
them through so many APIs.
llvm-svn: 109723
2010-07-29 02:16:43 +00:00
Chris Lattner
2b03797222
cave in to reality and make ABIInfo depend on CodeGenTypes.
...
This will simplify a bunch of code, coming up next.
llvm-svn: 109722
2010-07-29 02:01:43 +00:00
Chris Lattner
f4ba08aeaf
pass argument vectors in a type that corresponds to the user type if
...
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
2010-07-28 23:47:21 +00:00
Chris Lattner
4b8585ef6a
tidy up
...
llvm-svn: 109699
2010-07-28 23:46:15 +00:00
Devang Patel
c7f16ab3e3
Override selected builtin names (e.g. "long int" instead of "long") to match names used by gcc in debug info. This makes gdb testsuite happy.
...
llvm-svn: 109694
2010-07-28 23:23:29 +00:00
Chris Lattner
fa560fedb7
fix some break statements to be formatted more consistently,
...
remove some now-dead code.
llvm-svn: 109690
2010-07-28 23:12:33 +00:00
Chris Lattner
31faff5d58
use Get8ByteTypeAtOffset for the return value path as well so we
...
don't get errors similar to PR7714 on the return path.
llvm-svn: 109689
2010-07-28 23:06:14 +00:00
Chris Lattner
b22f1c8bf7
refactor the autosizing code, eliminating duplication
...
and making Get8ByteTypeAtOffset always succeed and documented.
llvm-svn: 109685
2010-07-28 22:44:07 +00:00
Chris Lattner
4c1e484f39
fix PR7714 by not referencing off the end of a struct when passed by value in
...
x86-64 abi. This also improves codegen as well. Some refactoring is needed of
this code.
llvm-svn: 109681
2010-07-28 22:15:08 +00:00
Fariborz Jahanian
d5010898ab
Fix flags in global block descriptor when
...
block returns structs. Fies radar 8241648.
Executable test added to llvm test suite.
llvm-svn: 109620
2010-07-28 19:07:18 +00:00
Chris Lattner
ff941a666a
some cleanups and get alignments correct for various coerce cases.
...
llvm-svn: 109607
2010-07-28 18:24:28 +00:00
Gabor Greif
79ac9ed7ac
we are not supposed to create an improper callsite using a CallInstr; leave a fixme mentioning the simplification when CallSite can clone itself
...
llvm-svn: 109575
2010-07-28 09:19:33 +00:00
Devang Patel
a652fab052
construct debug info for "id" by hand.
...
Tested by mi1-var-obj.exp in gdb testsuite.
llvm-svn: 109571
2010-07-28 01:33:15 +00:00
John McCall
ba80390307
When creating a jump destination, its scope should be the scope of the
...
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
2010-07-28 01:07:35 +00:00
Argyrios Kyrtzidis
c0279a9826
Revert r109546, it broke linux build.
...
llvm-svn: 109550
2010-07-27 22:37:14 +00:00
Argyrios Kyrtzidis
4fac280618
Merge PCHWriterDecl.cpp's isRequiredDecl and 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
2010-07-27 22:01:17 +00:00
Devang Patel
4f6e73b168
Always use current working directory for DW_AT_comp_dir.
...
llvm-svn: 109535
2010-07-27 20:49:59 +00:00
Devang Patel
6014edd117
Reapply 109303.
...
llvm-svn: 109507
2010-07-27 15:17:16 +00:00
Fariborz Jahanian
0ebca28f1d
2nd argument of __builtin_expect must be evaluated
...
if it hs side-effect to matchgcc's behaviour.
Addresses radar 8172109.
llvm-svn: 109467
2010-07-26 23:11:03 +00:00
John McCall
5cbe152ffc
Test for the presence of EH branch-throughs instead of normal branch-throughs.
...
I knew this code duplication would bite me.
llvm-svn: 109463
2010-07-26 22:44:58 +00:00
Devang Patel
6005082354
Revert 109303.
...
llvm-svn: 109426
2010-07-26 18:49:27 +00:00
Douglas Gregor
b412e174db
Remove the vast majority of the Destroy methods from the AST library,
...
since we aren't going to be calling them ever.
llvm-svn: 109377
2010-07-25 18:17:45 +00:00
John McCall
268b576b72
Mangle enum constant expressions. Fixes rdar://problem/8204122
...
llvm-svn: 109315
2010-07-24 01:17:35 +00:00
Devang Patel
268ad093a7
Untangle filename/dirname confusion. Store constructed strings on the side. 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
2010-07-24 00:59:16 +00:00
John McCall
2ca705eb13
Support catching Objective C pointers in C++ under the non-fragile NeXT runtime.
...
Diagnose attempts to do this under the GNU or fragile NeXT runtimes.
llvm-svn: 109298
2010-07-24 00:37:23 +00:00
Fariborz Jahanian
72cdffa401
Return type of a setter call caused by
...
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
2010-07-24 00:34:08 +00:00
Devang Patel
cb9fe9ec16
Revert r109263.
...
llvm-svn: 109284
2010-07-23 23:04:28 +00:00
John McCall
ad5d61e227
Revise cleanup IR generation to fix a major bug with cleanups (PR7686)
...
as well as some significant asymptotic inefficiencies with threading
multiple jumps through deep cleanups.
llvm-svn: 109274
2010-07-23 21:56:41 +00:00
Devang Patel
28f167699a
There is no need to use separate dir name for AT_comp_dir attribute. Using absolute path for filename allows clients to query complete file location info from gdb breakpoints. Save constructed full file name.
...
llvm-svn: 109263
2010-07-23 20:38:37 +00:00
Douglas Gregor
5cc2c8b9c3
Vectors are not integer types, so the type system should not classify
...
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
2010-07-23 15:58:24 +00:00
Devang Patel
0884a60eb5
Keep track of artificial scopes introduced by line directives. For example,
...
#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
2010-07-22 22:29:16 +00:00
John McCall
775f9f9919
Turn off EH cleanups for __block variables; they caused some internal buildbot
...
failures. There's a radar tracking this.
llvm-svn: 109170
2010-07-22 21:25:44 +00:00
Fariborz Jahanian
6e7e8cc19d
atch for implementation of objective-c's -Wselector
...
warning flag in clang. Little more to do
for a PCH issue. Radar 6507158.
llvm-svn: 109129
2010-07-22 18:24:20 +00:00
Devang Patel
222f4be834
ObjCId is special "struct objc_object". Make this explicit in debug info.
...
This is tested by objc-rbreak.exp in gdb testsuite.
llvm-svn: 109050
2010-07-21 22:41:25 +00:00
Devang Patel
65497583b5
Fix regression caused by r108911.
...
Do not override known debug loc with unknown debug loc.
This is tested by sections.exp in gdb testsuite.
llvm-svn: 109022
2010-07-21 18:08:50 +00:00
David Chisnall
4715d161c0
Don't crash when sending a message inside a block with the non-fragile ABI (GNU runtime).
...
llvm-svn: 109012
2010-07-21 15:28:28 +00:00
David Chisnall
7fa204edc7
Mark the load after calling objc_msg_lookup_sender() so that it doesn't get optimised away (GNU runtime).
...
llvm-svn: 109010
2010-07-21 12:55:25 +00:00
John McCall
cda666ccd8
Rename LazyCleanup -> Cleanup. No functionality change for these last three
...
commits.
llvm-svn: 109000
2010-07-21 07:22:38 +00:00
John McCall
20141f2d8c
Rip out EHCleanupScope.
...
llvm-svn: 108999
2010-07-21 07:11:21 +00:00
John McCall
7535ee0352
Kill the CleanupBlock API.
...
llvm-svn: 108998
2010-07-21 07:04:01 +00:00
John McCall
65bea08879
Switch the fragile-ABI @finally/@synchronized cleanup over to using a lazy
...
cleanup.
llvm-svn: 108997
2010-07-21 06:59:36 +00:00
John McCall
0d42a41a63
Code simplification.
...
llvm-svn: 108996
2010-07-21 06:45:54 +00:00