Commit Graph

23790 Commits

Author SHA1 Message Date
Daniel Dunbar 9dcde4bdec Driver/Darwin: Add one -L for the DarwinClang toolchain to point into the gcc
library directory, as we still rely on a few libraries that are hiding there (in
particular libstdc++.dylib).

llvm-svn: 107353
2010-06-30 23:56:13 +00:00
Douglas Gregor 56f2e34a6a Improve diagnostic when we fail to pick an overload because it would
require a base-to-derived pointer conversion.

llvm-svn: 107349
2010-06-30 23:01:39 +00:00
John Thompson 781ad17ba9 Fix vector literal/cast confusion - bug 6895.
llvm-svn: 107347
2010-06-30 22:55:51 +00:00
Douglas Gregor 5396853d81 Wording tweak from Dan.
llvm-svn: 107344
2010-06-30 22:43:03 +00:00
Douglas Gregor 426c572d78 Wording tweak from Dan.
llvm-svn: 107343
2010-06-30 22:38:37 +00:00
Benjamin Kramer aab931dd32 typo.
llvm-svn: 107342
2010-06-30 22:29:56 +00:00
Daniel Dunbar 4a58ced750 Runtime: Always build compiler-rt using the Clang we just built, instead of the
system CC.

llvm-svn: 107328
2010-06-30 22:10:41 +00:00
Daniel Dunbar 8d65fc86c4 Move lib/Runtime to runtime/, and build after everything else.
llvm-svn: 107327
2010-06-30 22:10:38 +00:00
Douglas Gregor b7b04ae204 Remove redundant and incomplete bits from the users manual w.r.t. language conformance
llvm-svn: 107326
2010-06-30 22:04:24 +00:00
Douglas Gregor 9c9f26d4bf New language-compatibility page, including language-compatibility information for the various language dialects Clang supports in a single, easy-to-find page
llvm-svn: 107325
2010-06-30 22:01:08 +00:00
Daniel Dunbar df000da850 libclang: When invoking external clang process to get code completion results,
pass -ccc-clang-cxx to force C++ support (even if the binary was built without
it).

llvm-svn: 107324
2010-06-30 21:40:01 +00:00
Daniel Dunbar 6696e22cc9 IRgen: Fix debug info regression in r106970; when we eliminate the return value
store make sure to move the debug metadata from the store (which is actual
'return' statement location) to the return instruction (which otherwise would
have the function end location as its debug info).
 - Tested by gdb test suite.

llvm-svn: 107322
2010-06-30 21:27:58 +00:00
Daniel Dunbar d7ac9a375a IRgen: Make sure any prolog instructions get debug info.
llvm-svn: 107320
2010-06-30 21:27:56 +00:00
Daniel Dunbar 8ab6c54ce2 Rewriter: Use the appropriate printing context instead of the default
constructed one -- this is necessary to ensure types get printed correctly.

llvm-svn: 107312
2010-06-30 19:16:53 +00:00
Daniel Dunbar 219fa69f91 AST: Propogate printing policy to types in a bunch more places.
llvm-svn: 107311
2010-06-30 19:16:48 +00:00
Chris Lattner 5c740f1523 Reapply:
r107173, "fix PR7519: after thrashing around and remembering how all this stuff"
r107216, "fix PR7523, which was caused by the ABI code calling ConvertType instead"

This includes a fix to make ConvertTypeForMem handle the "recursive" case, and call
it as such when lowering function types which have an indirect result.

llvm-svn: 107310
2010-06-30 19:14:05 +00:00
Fariborz Jahanian 02995320e9 Use isFunctionOrMethod for vars declared locallly
in method/blocks to decide not to mangle them.

llvm-svn: 107309
2010-06-30 18:57:21 +00:00
Eric Christopher aba9fb217e Add a return to silence a warning. Alternately a default: return false
would work.

Sebastian: figure out which one you want :)
llvm-svn: 107305
2010-06-30 18:36:32 +00:00
Zhanyong Wan 88d5a91f0d Fix RecursiveASTVisitor to traverse the ctor initializer list before
traversing the ctor body when traversing a CXXConstructorDecl.
Reviewed by chandlerc and csilvers.

llvm-svn: 107304
2010-06-30 18:34:52 +00:00
Fariborz Jahanian 0f19afb9d4 extern variable declared locally to objective-c++ method
should not be mangled either. Fixes radar 8016412.

llvm-svn: 107303
2010-06-30 18:27:47 +00:00
Sebastian Redl d92badfd9c Make both old and new versions of reference binding use the new classification functions, and updated them for N3092.
llvm-svn: 107301
2010-06-30 18:13:39 +00:00
Douglas Gregor bc0c79b4ab Clean up the diagnostic complaining about the element type of a vector
type so that it actually complains about the element type itself.

llvm-svn: 107299
2010-06-30 17:30:41 +00:00
Douglas Gregor 2187266120 Complain about the application of a transparent_union attribute to a
union whose first field has integral vector type. Also, clean up this
diagnostic a bit. Thanks to Eli for spotting this change in semantics
last week.

llvm-svn: 107296
2010-06-30 17:24:13 +00:00
Chris Lattner 749b8ed5af reduce nesting.
llvm-svn: 107292
2010-06-30 16:58:07 +00:00
Duncan Sands 36d97d8938 Add header file needed to compile with g++-4.6, which has undergone some more
header trimming (needed for std::uninitialized_copy).

llvm-svn: 107291
2010-06-30 16:54:05 +00:00
Sebastian Redl d559a545d4 Fix a comment typo.
llvm-svn: 107290
2010-06-30 16:41:54 +00:00
Fariborz Jahanian e33c116bdf Nasty rewriter bug which turns out to have an easy fix in
rewriting a c-style cast expression in statement printer.
Fixes radar 8143056.

llvm-svn: 107289
2010-06-30 16:31:08 +00:00
Argyrios Kyrtzidis 639ffb0c07 Fix rdar://8139785 "implement warning on dead expression in comma operator"
As a bonus, fix the warning for || and && operators; it was emitted even if one of the operands had side effects, e.g:

x || test_logical_foo1();

emitted a bogus "expression result unused" for 'x'.

llvm-svn: 107274
2010-06-30 10:53:14 +00:00
Argyrios Kyrtzidis bd8ac8cf07 Fix PCH support for UnresolvedUsingTypenameDecl and UnresolvedUsingValueDecl.
llvm-svn: 107268
2010-06-30 08:49:30 +00:00
Argyrios Kyrtzidis 4a57bd0d62 Support DependentSizedArrayType for PCH.
llvm-svn: 107267
2010-06-30 08:49:25 +00:00
Argyrios Kyrtzidis f9f47c8e54 Support ParenListExpr for PCH.
llvm-svn: 107266
2010-06-30 08:49:18 +00:00
Argyrios Kyrtzidis 2b3ac09200 Make the constructor explicit.
llvm-svn: 107265
2010-06-30 08:49:12 +00:00
Charles Davis 2a47730767 Mangle arrays in the Microsoft C++ Mangler. It's not quite finished (it
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
2010-06-30 08:09:57 +00:00
Ted Kremenek 169e43c4cf Correctly implement the CheckerVisit optimization introduced in r106884, but this time actually used the cached checker list when calling back to Checker visit methods. This reduces the analysis time for sqlite3.c by 8%.
llvm-svn: 107259
2010-06-30 07:28:52 +00:00
Daniel Dunbar 120a1e9d0f Headers: Define __INT64_TYPE__ in terms of getInt64Type(), which isn't always
'long'. The practical upshot is so that the uint64_t we define in our stdint.h
ends up being compatible with that defined by gcc (at least on Darwin), which
otherwise could lead to type incompatibilities with other system headers.

llvm-svn: 107255
2010-06-30 06:30:56 +00:00
Daniel Dunbar 540e8b1dcd Headers: Change [u]intmax_t to be defined in terms of __[U]INTMAX_TYPE__, instead of intN_t.
llvm-svn: 107254
2010-06-30 06:30:50 +00:00
Chandler Carruth 139e96216a Reapply r107235, this time with both my typo fixed, and a logical bug fixed.
Previously we relied on the presence of a member which needs no initialization
to prevent us from creating an additional initialization of the outer anonymous
union field. We have already correctly marked that field as initialized by the
member of the union (repeatedly due to the original bug this patch fixes) so we
simply need to bail out.

llvm-svn: 107242
2010-06-30 02:59:29 +00:00
Chandler Carruth 0e783c2e86 Revert r107235, it had a silly typo in it, and fixing the typo breaks something
else. Get the build bots happy while I debug. Very sorry for the delay fixing
this...

llvm-svn: 107239
2010-06-30 02:06:16 +00:00
Jordy Rose dc48471861 Pointers casted as integers still count as locations to SimpleSValuator, so don't crash if we do a funny thing like ((int)ptr)&1. Fixes PR7527.
llvm-svn: 107236
2010-06-30 01:35:20 +00:00
Chandler Carruth abb04f730e Fix PR7402: We were creating implicit member initializers for every field in an
anonymous union under the presumption that they didn't do anything. While this
is true, our checks for redundant initialization of an anonymous union still
fire when these overlap with explicit user initialization. A cleaner approach
is to avoid initializing multiple members of a union altogether, but this still
is in a rather fuzzy are especially when C++0x allows non-POD types into
unions.

llvm-svn: 107235
2010-06-30 00:54:29 +00:00
Daniel Dunbar e422266926 Revert r107173, "fix PR7519: after thrashing around and remembering how all this stuff", it broke bootstrap.
llvm-svn: 107232
2010-06-30 00:22:35 +00:00
Daniel Dunbar 8386469d7d Revert r107216, "fix PR7523, which was caused by the ABI code calling ConvertType instead", it is part of a boostrap breaking sequence.
llvm-svn: 107231
2010-06-30 00:22:30 +00:00
Douglas Gregor 4799d03ce8 Implement C++ DR299, which allows an implicit conversion from a class
type to an integral or enumeration type in the size of an array new
expression, e.g.,

  new int[ConvertibleToInt(10)];

This is a GNU and C++0x extension.

llvm-svn: 107229
2010-06-30 00:20:43 +00:00
Chandler Carruth 9c9286b531 Retain the source location of the constructor when building an implicit member
initialization. I tried several ideas but couldn't come up with a test case for
this that didn't rely on a Clang bug to report a diagnostic after template
instantiation of the constructor due to the implicit initializers. Suggestions
welcome. This fixes the source location aspect of PR7402.

llvm-svn: 107226
2010-06-29 23:50:44 +00:00
Douglas Gregor 5823da3ab0 Re-improve recovery when the condition of a switch statement does not
have integral or enumeration type, so that we still check the contents
of the switch body. My previous patch made this worse; now we're back
to where we were previously.

llvm-svn: 107223
2010-06-29 23:25:20 +00:00
Douglas Gregor f4ea725d38 Factor the conversion from a switch condition to an integral or
enumeration type out into a separate, reusable routine. The only
functionality change here is that we recover a little more
aggressively from ill-formed switch conditions.

llvm-svn: 107222
2010-06-29 23:17:37 +00:00
Argyrios Kyrtzidis 74d28bd084 Support C++ friend declarations for PCH.
This commit 'introduces' a slightly different way to restore the state of the AST object.
It makes PCHDeclReader/PCHDeclWriter friends and gives them access to the private members of the object.
The rationale is to avoid using/modifying the AST interfaces for PCH read/write so that to:

-Avoid complications with objects that have side-effects during creation or when using some setters.
-Not 'pollute' the AST interface with methods only used by the PCH reader/writer
-Allow AST objects to be read-only.

llvm-svn: 107219
2010-06-29 22:47:00 +00:00
Argyrios Kyrtzidis 26d7201d5d When we know that we are at sub-statement reading (which is all of PCHStmtReader) use the "faster" ReadSubStmt. No functionality change.
llvm-svn: 107218
2010-06-29 22:46:25 +00:00
Daniel Dunbar 8c94ffe776 IRgen: Assignment to Objective-C properties shouldn't reload the value, for
complex values either. Previously we did this properly for regular assignment,
but not for compound assignment.
 - Also, tidy up assignment code a bit to look more like the scalar path.

llvm-svn: 107217
2010-06-29 22:44:21 +00:00
Chris Lattner 466b1419c6 fix PR7523, which was caused by the ABI code calling ConvertType instead
of ConvertTypeRecursive when it needed to in a few cases, causing pointer
types to get resolved at the wrong time.

llvm-svn: 107216
2010-06-29 22:39:04 +00:00
Daniel Dunbar c85ea8e175 IRgen: Assignment to Objective-C properties shouldn't reload the value (which
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
2010-06-29 22:00:45 +00:00
Ted Kremenek 090d62e7cc Tweaker Checker::VisitEndAnalysis to have 'hasWorkRemaining' also
be true if some paths were aborted because they exceeded
the maximum loop unrolling count.

llvm-svn: 107209
2010-06-29 21:58:54 +00:00
Ted Kremenek 3f1240b614 Add test case for <rdar://problem/4289832>. Clang actuallys gets
the test case right (for the noreturn warning) because the CFG
doesn't support @try yet, but the test case is now present when
we do properly implement CFG support for @try...@catch.

llvm-svn: 107203
2010-06-29 20:25:42 +00:00
Douglas Gregor c048c52734 When typo correction produces a result that is not of the kind we're
looking for, reset the name within the LookupResult structure in
addition to clearing out the results. Fixes PR7508.

llvm-svn: 107197
2010-06-29 19:27:42 +00:00
Chris Lattner cccaad9584 change ABIArgInfo to hold its llvm type with PATypeHolder so that
it doesn't dangle as types get refined.  This fixes Shootout-C++/lists1
and probably also PR7522.

llvm-svn: 107196
2010-06-29 19:21:36 +00:00
Douglas Gregor 6969fb73ca Fix broken testcase
llvm-svn: 107194
2010-06-29 19:17:14 +00:00
Douglas Gregor 9629e9ac3e Typo correction for namespace alias definitions
llvm-svn: 107191
2010-06-29 18:55:19 +00:00
Daniel Dunbar 99e13101b2 tests: Fix test to not depend on instruction names.
llvm-svn: 107186
2010-06-29 18:34:40 +00:00
Daniel Dunbar f35e76552f Sema: Fix a subtle i64 -> i32 truncation which broke layout of large structures
with bit-fields.

llvm-svn: 107185
2010-06-29 18:34:35 +00:00
Chris Lattner 34d6281ae5 relax the CGFunctionInfo::CGFunctionInfo ctor to allow any sequence
of CanQualTypes to be passed in.

llvm-svn: 107176
2010-06-29 18:13:52 +00:00
Fariborz Jahanian 66f9a6560e This patch fixes a bug whereby, clang skipped
unimplemented property warning for properties 
coming from class's conformin protocol. It also
simplifies the algorithm in the process.
Fixes radar 8035776.

llvm-svn: 107174
2010-06-29 18:12:32 +00:00
Chris Lattner ab1e65e2ea fix PR7519: after thrashing around and remembering how all this stuff
works, the fix is quite simple: just make sure to call ConvertTypeRecursive
when the function type being lowered is in the midst of ConvertType.

llvm-svn: 107173
2010-06-29 17:56:33 +00:00
Douglas Gregor cdf87024ed Allow a using directive to refer to the implicitly-defined namespace
"std", with a warning, to improve GCC compatibility. Fixes PR7517.

As a drive-by, add typo correction for using directives.

llvm-svn: 107172
2010-06-29 17:53:46 +00:00
Douglas Gregor 56980d688b With packed enums, an enumerator's value may be stored in more bits
than the enumeration type itself takes. Fixes PR7477.

llvm-svn: 107163
2010-06-29 17:12:35 +00:00
Daniel Dunbar 8452ef0798 tests: Use %clangxx when using driver for C++, in case C++ support is disabled.
llvm-svn: 107153
2010-06-29 16:52:24 +00:00
Daniel Dunbar ec1bee907a tests: Spell %clang_cc1 correctly.
llvm-svn: 107152
2010-06-29 16:52:18 +00:00
Chris Lattner e70a007b36 minor cleanups.
llvm-svn: 107150
2010-06-29 16:40:28 +00:00
Daniel Dunbar 00d3d8e902 Driver/Darwin: Only run dsymutil when we are also compiling/assembling as part
of the compilation.
 - <rdar://problem/8141387> clang is always invoking dsymutil

llvm-svn: 107149
2010-06-29 16:38:33 +00:00
Jeffrey Yasskin bb219e01a6 Delete assert in ComputeKeyFunction. The function runs fine without it, since
there's an explicit guard on isPolymorphic, and virtual bases don't affect the
key function calculation.  This allows people to call
ASTContext::getKeyFunction on arbitrary classes.

llvm-svn: 107143
2010-06-29 15:27:35 +00:00
Chris Lattner 22a931e3bb Change X86_64ABIInfo to have ASTContext and TargetData ivars to
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
2010-06-29 06:01:59 +00:00
Chris Lattner de310d5d95 Minix doesn't support dylibs, PR7294
llvm-svn: 107120
2010-06-29 05:05:09 +00:00
Chris Lattner 399d22ac1b plumb preferred types down into X86_64ABIInfo::classifyArgumentType,
no functionality change.

llvm-svn: 107115
2010-06-29 01:14:09 +00:00
Chris Lattner 1d7c9f7f4b Pass the LLVM IR version of argument types down into computeInfo.
This is somewhat annoying to do this at this level, but it avoids
having ABIInfo know depend on CodeGenTypes for a hint.

Nothing is using this yet, so no functionality change.

llvm-svn: 107111
2010-06-29 01:08:48 +00:00
Chandler Carruth 8337ba6303 Prefer llvm_unreachable(...) to assert(false && ...). This is important as
without it we might exit a non-void function without returning.

llvm-svn: 107106
2010-06-29 00:23:11 +00:00
Chris Lattner 9e748e9d6e add IR names to coerced arguments.
llvm-svn: 107105
2010-06-29 00:14:52 +00:00
Chris Lattner 15ec361bd6 make the argument passing stuff in the FCA case smarter still, by
avoiding making the FCA at all when the types exactly line up.  For
example, before we made:

%struct.DeclGroup = type { i64, i64 }

define i64 @_Z3foo9DeclGroup(i64, i64) nounwind {
entry:
  %D = alloca %struct.DeclGroup, align 8          ; <%struct.DeclGroup*> [#uses=3]
  %2 = insertvalue %struct.DeclGroup undef, i64 %0, 0 ; <%struct.DeclGroup> [#uses=1]
  %3 = insertvalue %struct.DeclGroup %2, i64 %1, 1 ; <%struct.DeclGroup> [#uses=1]
  store %struct.DeclGroup %3, %struct.DeclGroup* %D
  %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
}

... which has the pointless insertvalue, which fastisel hates, now we
make:

%struct.DeclGroup = type { i64, i64 }

define i64 @_Z3foo9DeclGroup(i64, i64) nounwind {
entry:
  %D = alloca %struct.DeclGroup, align 8          ; <%struct.DeclGroup*> [#uses=4]
  %2 = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i64*> [#uses=1]
  store i64 %0, i64* %2
  %3 = getelementptr %struct.DeclGroup* %D, i32 0, i32 1 ; <i64*> [#uses=1]
  store i64 %1, i64* %3
  %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
}

This only kicks in when x86-64 abi lowering decides it likes us.

llvm-svn: 107104
2010-06-29 00:06:42 +00:00
Craig Silverstein 1b28a4298e A few prettifications. Also renamed TraverseInitializer to
TraverseConstructorInitializer, to be a bit clearer.

llvm-svn: 107102
2010-06-29 00:02:17 +00:00
Ted Kremenek 5414027020 Per Doug's suggestion, move check for invalid SourceLocation into
cxloc::translateSourceLocation() (thus causing all clients of this
function to have the same behavior).

llvm-svn: 107101
2010-06-28 23:54:17 +00:00
Chris Lattner 3dd716c3c3 Change CGCall to handle the "coerce" case where the coerce-to type
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
2010-06-28 23:44:11 +00:00
Craig Silverstein a37aa88e62 Fix up ClassTemplateSpecializationDecl: For implicit instantiations
("set<int> x;"), we don't want to recurse at all, since the
instatiated class isn't written in the source code anywhere.  (Note
the instatiated *type* -- set<int> -- is written, and will still get a
callback of TemplateSpecializationType).  For explicit instantiations
("template set<int>;"), we do need a callback, since this is the only
callback that's made for this instantiation.  We use
getTypeAsWritten() to distinguish.

We will still need to figure out how to handle template
specializations, which probably are still not quite correct.

Reviewed by chandlerc

llvm-svn: 107098
2010-06-28 23:42:10 +00:00
Chris Lattner d200eda487 make the trivial forms of CreateCoerced{Load|Store} trivial.
llvm-svn: 107091
2010-06-28 22:51:39 +00:00
Argyrios Kyrtzidis d0795b2d78 Modify the way sub-statements are stored and retrieved from PCH.
Before this commit, sub-stmts were stored as encountered and when they were placed in the Stmts stack we had to know what index
each stmt operand has. This complicated supporting variable sub-stmts and sub-stmts that were contained in TypeSourceInfos, e.g.

x = sizeof(int[1]);

would crash PCH.

Now, sub-stmts are stored in reverse order, from last to first, so that when reading them, in order to get the next sub-stmt we just
need to pop the last stmt from the stack. This greatly simplified the way stmts are written and read (just use PCHWriter::AddStmt and
 PCHReader::ReadStmt accordingly) and allowed variable stmt operands and TypeSourceInfo exprs.

llvm-svn: 107087
2010-06-28 22:28:35 +00:00
Chris Lattner 93af332819 pass/return structs of char and short as i8/i16 to avoid
aweful through-memory coersion, just like we do for i32 now.

llvm-svn: 107078
2010-06-28 21:59:07 +00:00
Chris Lattner d776fb150e more tidying up.
llvm-svn: 107076
2010-06-28 21:43:59 +00:00
Ted Kremenek e60d304d13 Remove state assertion.
llvm-svn: 107064
2010-06-28 20:44:49 +00:00
Ted Kremenek ea78375ed4 Don't crash in InitializePreprocessor() when there is no valid PTHManager. Fixes <rdar://problem/8098441>.
llvm-svn: 107061
2010-06-28 20:32:40 +00:00
Chris Lattner 0cf2419cd7 random acts of tidying.
llvm-svn: 107050
2010-06-28 20:05:43 +00:00
Chris Lattner a7d81ab7f3 X86-64:
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
2010-06-28 19:56:59 +00:00
Fariborz Jahanian c42461e145 Minor refactorin of my last patch (radar 7860965 related).
llvm-svn: 107047
2010-06-28 19:42:10 +00:00
Fariborz Jahanian 36ad0e99d5 Have __func__ and siblings point to block's implementation function
name. Fixes radar 7860965.

llvm-svn: 107044
2010-06-28 18:58:34 +00:00
Chris Lattner d250b8e9a8 tweak test to pass on windows
llvm-svn: 107040
2010-06-28 18:29:14 +00:00
Daniel Dunbar ebf9da9849 tests: Rewrite test to check intent instead of implementation.
llvm-svn: 107024
2010-06-28 17:43:18 +00:00
Rafael Espindola 0e1fb4f341 Set the default arch based on the triple.
llvm-svn: 107021
2010-06-28 17:18:09 +00:00
Chris Lattner c1028f689e Fix UnitTests/2004-02-02-NegativeZero.c, which regressed when
I broke negate of FP values.

llvm-svn: 107019
2010-06-28 17:12:37 +00:00
Chris Lattner 18bcf76f05 fix a silly fixme.
llvm-svn: 107018
2010-06-28 17:11:58 +00:00
Dan Gohman 3bc1b0c882 llvm::errs() is non-buffered, so it doesn't need to be flushed.
llvm-svn: 107012
2010-06-28 15:56:07 +00:00
Craig Silverstein 282ddc646b Add support for traversing initializer lists (in constructors), which
we ignoring before.  To give access to the names on the initializer,
which aren't a type or an expr or a decl, I've introduced a new
TraverseInitializer.  By default, it just traverses on the expr that
the name is being initialized to.

Reviewed by chandlerc.  Tested via clang's 'make test'.

llvm-svn: 107008
2010-06-28 15:37:14 +00:00
Sebastian Redl f9463106b3 Introduce Expr::Classify and Expr::ClassifyModifiable, which determine the classification of an expression under the C++0x taxology (value category). Reimplement isLvalue and isModifiableLvalue using these functions. No regressions in the test suite from this, and my rough performance check doesn't show any regressions either.
llvm-svn: 107007
2010-06-28 15:09:07 +00:00
Argyrios Kyrtzidis 99a226dde4 Support CXXPseudoDestructorExpr for PCH.
llvm-svn: 106999
2010-06-28 09:32:03 +00:00
Argyrios Kyrtzidis cd444d1af7 Support DependentScopeDeclRefExpr for PCH.
llvm-svn: 106998
2010-06-28 09:31:56 +00:00