Commit Graph

4034 Commits

Author SHA1 Message Date
John McCall 398dc37d1f Implement RTTI generation for Objective C types. Fixes PR7864.
llvm-svn: 110900
2010-08-12 02:17:33 +00:00
Devang Patel caa23f0708 Emit debug info for static const class member.
llvm-svn: 110885
2010-08-12 00:02:44 +00:00
John McCall 5996699834 Revise r110163: don't mark weak functions nounwind, because the optimizer
treats that as a contract to be fulfilled by any replacements.

llvm-svn: 110864
2010-08-11 22:38:33 +00:00
Devang Patel d76c1dbe39 Emit a stop point for delegate constructor call. This gives user a chance to step into constructor body.
llvm-svn: 110853
2010-08-11 21:04:37 +00:00
John McCall ffe4630f3d When re-raising an exception after a cleanup, we need to call _Unwind_Resume_or_Rethrow
instead of _Unwind_Resume.  With SJLJ exceptions, this is spelled
"_Unwind_SjLj_Resume_or_Rethrow", not "_Unwind_SjLj_Resume", which has
significantly different semantics.

We should actually never be generating a call to _Unwind_SjLj_Resume directly;
even if we were generating true cleanups (which we aren't because of the
horrible hack), we should be calling __cxa_end_cleanup() on ARM.  I
haven't implemented this because there's little point as long as the HH is
present.

I believe this fixes <rdar://problem/8281377>.

llvm-svn: 110851
2010-08-11 20:59:53 +00:00
Eli Friedman 961fc05418 Work in progress for PR7864. Someone more familiar with ObjC++ needs to fill
in the code after the "FIXME: Needs to be written".

llvm-svn: 110849
2010-08-11 20:41:51 +00:00
Fariborz Jahanian d539d098a4 IRGen support for functions returning objc object
types. Fixes PR7865.

llvm-svn: 110832
2010-08-11 17:37:35 +00:00
John McCall cebe0ca75e Fix a bug in @finally emission in both the fragile and non-fragile EH schemes
where we weren't accounting for the possibility that a @finally block might
have internal cleanups and therefore might write to the cleanup destination slot.

Fixes <rdar://problem/8293901>.

llvm-svn: 110760
2010-08-11 00:16:14 +00:00
Devang Patel 8166571a25 Simplify
llvm-svn: 110716
2010-08-10 20:16:57 +00:00
John Thompson a5c7d706b8 Slightly revised handling of mult-alt constraints, to avoid an assert, until we have the full fix.
llvm-svn: 110706
2010-08-10 19:20:14 +00:00
John McCall 62eb9a8e84 When initializing a static local, pop the guard-abort EH cleanup after
the variable is fully initialized.

llvm-svn: 110704
2010-08-10 18:51:44 +00:00
Devang Patel 76e3b53541 Do not use DIGlobalVariable to emit debugging information for enums.
llvm-svn: 110697
2010-08-10 18:27:15 +00:00
Devang Patel dc866e119c Simplify code and add comments, in code that generate debug info for constant integer globals, based on Chris's feedback.
llvm-svn: 110694
2010-08-10 17:53:33 +00:00
Devang Patel e03edfd3e7 Even if a constant's evaluated value is used, emit debug info for the constant variable.
llvm-svn: 110660
2010-08-10 07:24:25 +00:00
Argyrios Kyrtzidis 13257c5527 Support ObjC implementation decls for PCH.
Strictly speaking, implementations don't go in headers but there's no law against it.

llvm-svn: 110567
2010-08-09 10:54:20 +00:00
Eric Christopher 6ff7161d51 Thread local variables aren't considered common linkage.
llvm-svn: 110530
2010-08-08 01:37:14 +00:00
Douglas Gregor 8b2d2fe234 Allow reference binding of a reference of Objective-C object type to
an lvalue of another, compatible Objective-C object type (e.g., a
subclass). Introduce a new initialization sequence step kind to
describe this binding, along with a new cast kind. Fixes PR7741.

llvm-svn: 110513
2010-08-07 11:51:51 +00:00
John McCall 7cd1d97e33 Inline a special case of EmitAggregateCopy into EmitNullInitialization
to avoid the awesome-but-wrong-in-this-case assertion in the canon EAC.
Fixes PR7834.

Also fix a subtle address-space bug in the memset path.

llvm-svn: 110511
2010-08-07 08:21:30 +00:00
John McCall cf14216509 Store inheritance paths after CastExprs instead of inside them.
This takes some trickery since CastExpr has subclasses (and indeed,
is abstract).

Also, smoosh the CastKind into the bitfield from Expr.

Drops two words of storage from Expr in the common case of expressions
which don't need inheritance paths.  Avoids a separate allocation and
another word of overhead in cases needing inheritance paths.  Also has
the advantage of not leaking memory, since destructors for AST nodes are
never run.

llvm-svn: 110507
2010-08-07 06:22:56 +00:00
Chris Lattner 8139c98cf9 Correct -ftrapv to trap on errors, instead of calling the
__overflow_handler entrypoint that David Chisnall made up.
Calling __overflow_handler is not part of the contract of
-ftrapv provided by GCC, and should never have been checked
in in the first place.

According to:
http://permalink.gmane.org/gmane.comp.compilers.clang.devel/8699

David is using this for some of arbitrary precision integer stuff
or something, which is not an appropriate thing to implement on
this.

llvm-svn: 110490
2010-08-07 00:20:46 +00:00
Eli Friedman 165301d38d Initialize variable to work around warning; unfortunately, there isn't any
way to tell gcc "really, values outside the enum aren't valid".

llvm-svn: 110450
2010-08-06 16:37:05 +00:00
Fariborz Jahanian f95e358004 Finishing up block variable layout API by supporting
union type variables and their nesting inside other
aggregate types.

llvm-svn: 110448
2010-08-06 16:28:55 +00:00
Nate Begeman ad5dd42817 vdup_lane was missing
<rdar://problem/8278732>

llvm-svn: 110420
2010-08-06 01:24:57 +00:00
Eli Friedman e83d2b7649 Attempt to fix uninitialized value warning reported on cfe-commits.
llvm-svn: 110418
2010-08-06 01:17:25 +00:00
John McCall 491462425a Don't crash when mangling empty anonymous unions. We never actually *need*
these, but it's convenient to mangle them when deferring them (in the 99.99%
case where it's not an anonymous union, of course).

llvm-svn: 110381
2010-08-05 22:02:13 +00:00
Fariborz Jahanian 903aba39ee Add support for block imported struct variable layout info.
(objc gc and blocks in NeXt runtime).

llvm-svn: 110377
2010-08-05 21:00:25 +00:00
John McCall 5513fce96b It turns out that linkers (at least, the Darwin linker) don't necessarily
do the right thing with mixed-visibility symbols, so disable the visibility
optimization where that's possible, i.e. with template classes (since it's
possible that an arbitrary template might be subject to an explicit
instantiation elsewhere).  447.dealII actually does this.

I've put the code under an option that's currently not hooked up to anything.

llvm-svn: 110374
2010-08-05 20:39:18 +00:00
John McCall 95bde46bbb Argument evaluation order is not guaranteed. Split these out to force an order.
llvm-svn: 110354
2010-08-05 18:11:10 +00:00
John McCall a9731a4179 Fix a major bug with -ftrapv and ++/--. Patch by David Keaton!
llvm-svn: 110347
2010-08-05 17:39:44 +00:00
Fariborz Jahanian d652ac82b0 For now skip over aggregate non-byref block variables.
(objc gc specific).

llvm-svn: 110340
2010-08-05 16:13:18 +00:00
Fariborz Jahanian 89f3721dee Trying to unbreak buildbot.
llvm-svn: 110339
2010-08-05 15:52:12 +00:00
Eli Friedman d7c7232a1d Add IRGen support for non-constant OffsetOfExpr.
llvm-svn: 110326
2010-08-05 09:58:49 +00:00
Eli Friedman 570024a8d9 Implement #pragma GCC visibility.
llvm-svn: 110315
2010-08-05 06:57:20 +00:00
Fariborz Jahanian 1f78a9ad56 Clean up of my last patch.
llvm-svn: 110290
2010-08-05 00:19:48 +00:00
Fariborz Jahanian 9659f6b540 Block variable layout bitmap API generation.
llvm-svn: 110287
2010-08-04 23:55:24 +00:00
John McCall c8bd9c277b Extend the visibility-hidden optimization to linkonce_odr thunks for
functions with in-line definitions, since such thunks will be emitted at any
use of the function.

Completes the feature work for rdar://problem/7523229.

llvm-svn: 110285
2010-08-04 23:46:35 +00:00
Fariborz Jahanian afa3c0a875 More objc block variable layout info. work.
llvm-svn: 110239
2010-08-04 18:44:59 +00:00
Fariborz Jahanian c05349e53a Some early work for providing block layout info.
for objective-c/c++ blocks (NeXt runtime).

llvm-svn: 110213
2010-08-04 16:57:49 +00:00
John McCall e16adc2b1e Emit standard-library RTTI with external linkage, not weak_odr.
Apply hidden visibility to most RTTI;  libstdc++ does not rely on exact
pointer equality for the type info (just the type info names).  Apply
the same optimization to RTTI that we do to vtables.

Fixes PR5962.

llvm-svn: 110192
2010-08-04 08:34:44 +00:00
John McCall 8a705c15d9 Extend the hidden-visibility vtables optimization to template classes that
haven't been explicitly instantiated.

llvm-svn: 110189
2010-08-04 06:38:15 +00:00
John McCall 2dd7d44135 Some more correctness fixes and code-size optimizations for fragile-ABI
ObjC exceptions:
  - don't enter a try for the catch blocks unless there's a finally
  - put the setjmp buffer in the locals set for liveness reasons
  - dump the sync object into an alloca in the locals set for liveness reasons
Some of this can go away if the backend starts to properly calculate liveness
in the presence of setjmp (which would also be a *much* stabler solution).

llvm-svn: 110188
2010-08-04 05:59:32 +00:00
John McCall 8601a75118 Do a very simple pass over every function we emit to infer whether we can
mark it nounwind based on whether it contains any non-nounwind calls.
<rdar://problem/8087431>

llvm-svn: 110163
2010-08-03 22:46:07 +00:00
Nate Begeman f568b074db Add support for VFP status & control operations for ARM.
llvm-svn: 110153
2010-08-03 21:32:34 +00:00
John McCall 5696d6d316 Emit weak vtables of non-template classes with hidden visibility.
llvm-svn: 110107
2010-08-03 07:24:12 +00:00
John McCall 8b0f4ff317 Further adjustments to -Wglobal-constructors; works for references and direct
initializations now.

llvm-svn: 110063
2010-08-02 21:13:48 +00:00
John McCall 42227edc79 Fix fragile-ABI ObjC exceptions in the presence of optimization with
the magic of inline assembly.  Essentially we use read and write hazards
on the set of local variables to force flushing locals to memory
immediately before any protected calls and to inhibit optimizing locals
across the setjmp->catch edge.  Fixes rdar://problem/8160285

llvm-svn: 109960
2010-07-31 23:20:56 +00:00
John McCall 45d494785d Emit global destructors even if the destroyed object has no initializers or has
an initializer requiring temporary object disposal.

Fixes rdar:://problem/8246444.

llvm-svn: 109849
2010-07-30 04:56:58 +00:00
Chris Lattner 8a2f3c778e fix PR5179 and correctly fix PR5831 to not miscompile.
The X86-64 ABI code didn't handle the case when a struct
would get classified and turn up as "NoClass INTEGER" for
example.  This is perfectly possible when the first slot
is all padding (e.g. due to empty base classes).  In this
situation, the first 8-byte doesn't take a register at all,
only the second 8-byte does.

This fixes this by enhancing the x86-64 abi stuff to allow
and handle this case, reverts the broken fix for PR5831,
and enhances the target independent stuff to be able to 
handle an argument value in registers being accessed at an
offset from the memory value.

This is the last x86-64 calling convention related miscompile
that I'm aware of.

llvm-svn: 109848
2010-07-30 04:02:24 +00:00
Daniel Dunbar cda4307308 Revert "Re-apply fixed version of 108749, correctly conditionalizing the new
sections on", this change uncovered a possible linker bug which resulted in the
wrong messages getting dispatched. Backing this out while we investigate...

llvm-svn: 109817
2010-07-29 22:57:21 +00:00
Nate Begeman 1194bd2bd8 Wire up sema checking for __builtin_arm_usat and __builtin_arm_ssat immediates.
llvm-svn: 109814
2010-07-29 22:48:34 +00:00
Chris Lattner 1f3a063f00 move the last hunk of getCoerceResult into the place
that needs it and remove getCoerceResult.

llvm-svn: 109807
2010-07-29 21:42:50 +00:00
Chris Lattner 60fbd7744f now that direct and coerce are merged, getCoerceResult gets simpler.
llvm-svn: 109805
2010-07-29 21:29:53 +00:00
Chris Lattner 09794695ef now that GetSSETypeAtOffset handles passing SSE class values as
float, the special case hack in getCoerceResult can go away.

llvm-svn: 109804
2010-07-29 21:22:50 +00:00
Argyrios Kyrtzidis c904933aac Change the name to something less terrible; suggestion by Doug. No functionality change.
llvm-svn: 109797
2010-07-29 20:08:05 +00:00
Chris Lattner e556a71859 Implement the clang-side of detection for when to pass as
<2 x float> instead of double.  This works but can't be turned
on until I teach codegen to pass <2 x float> as one XMM register
instead of two.

llvm-svn: 109790
2010-07-29 18:39:32 +00:00
Chris Lattner 50a357e962 Look at me, I can count!
llvm-svn: 109786
2010-07-29 18:19:50 +00:00
Argyrios Kyrtzidis c81af03fb3 Merge PCHWriterDecl.cpp's isRequiredDecl and CodeGenModule::MayDeferGeneration into a new function,
DeclIsRequiredFunctionOrFileScopedVar.

This is 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.
Since this logic is shared by CodeGen and the PCH mechanism, move it to the ASTContext,
thus CodeGenModule's GetLinkageForFunction/GetLinkageForVariable and the GVALinkage enum is moved out of CodeGen.

This fixes current (and avoids future) codegen-from-PCH bugs.

llvm-svn: 109784
2010-07-29 18:15:58 +00:00
Chris Lattner 7f4b81af7a fix rdar://8251384, another case where we could access beyond the
end of a struct.  This improves the case when the struct being passed
contains 3 floats, either due to a struct or array of 3 things.  Before
we'd generate this IR for the testcase:

define float @bar(double %X.coerce0, double %X.coerce1) nounwind {
entry:
  %X = alloca %struct.foof, align 8               ; <%struct.foof*> [#uses=2]
  %0 = bitcast %struct.foof* %X to %1*            ; <%1*> [#uses=2]
  %1 = getelementptr %1* %0, i32 0, i32 0         ; <double*> [#uses=1]
  store double %X.coerce0, double* %1
  %2 = getelementptr %1* %0, i32 0, i32 1         ; <double*> [#uses=1]
  store double %X.coerce1, double* %2
  %tmp = getelementptr inbounds %struct.foof* %X, i32 0, i32 2 ; <float*> [#uses=1]
  %tmp1 = load float* %tmp                        ; <float> [#uses=1]
  ret float %tmp1
}

which compiled (with optimization) to:

_bar:                                   ## @bar
## BB#0:                                ## %entry
	movd	%xmm1, %rax
	movd	%eax, %xmm0
	ret

Now we produce:

define float @bar(double %X.coerce0, float %X.coerce1) nounwind {
entry:
  %X = alloca %struct.foof, align 8               ; <%struct.foof*> [#uses=2]
  %0 = bitcast %struct.foof* %X to %0*            ; <%0*> [#uses=2]
  %1 = getelementptr %0* %0, i32 0, i32 0         ; <double*> [#uses=1]
  store double %X.coerce0, double* %1
  %2 = getelementptr %0* %0, i32 0, i32 1         ; <float*> [#uses=1]
  store float %X.coerce1, float* %2
  %tmp = getelementptr inbounds %struct.foof* %X, i32 0, i32 2 ; <float*> [#uses=1]
  %tmp1 = load float* %tmp                        ; <float> [#uses=1]
  ret float %tmp1
}

and:

_bar:                                   ## @bar
## BB#0:                                ## %entry
	movaps	%xmm1, %xmm0
	ret

llvm-svn: 109776
2010-07-29 18:13:09 +00:00
Chris Lattner c95a398947 start setting up infrastructure for passing multi-floats
as <2 x float> instead of as double.  The backend isn't ready
yet, but infrastructure in the frontend can come up.

llvm-svn: 109768
2010-07-29 17:49:08 +00:00
Chris Lattner 1c56d9ab56 rename Get8ByteTypeAtOffset -> GetINTEGERTypeAtOffset to
make it clear that this function should only return a type
that the codegen will classify the same as an INTEGER type.

llvm-svn: 109763
2010-07-29 17:40:35 +00:00
Chris Lattner 3f76342cfc handle a case where we could access off the end of a function
that Eli pointed out, rdar://8249586

llvm-svn: 109762
2010-07-29 17:34:39 +00:00
Chris Lattner cd84084f02 fix PR7742 / rdar://8250764, a miscompilation of struct
return where the struct has a base but no fields.  This
was because the x86-64 abi logic was checking the wrong
predicate in one place.

This was introduced in r91874, which was a fix for PR5831,
which lacked a CHECK line, so I verified and added it.

llvm-svn: 109759
2010-07-29 17:04:54 +00:00
Chris Lattner 98076a25ce This is a little bit far, but optimize cases like:
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
2010-07-29 07:43:55 +00:00
Chris Lattner c8b7b53a1e implement a todo: pass a eight-byte that consists of a
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
2010-07-29 07:30:00 +00:00
Chris Lattner 2cdfda44a1 fix a builder, why didn't clang++ catch this?
llvm-svn: 109735
2010-07-29 06:44:09 +00:00
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