Commit Graph

571 Commits

Author SHA1 Message Date
Eli Friedman cecc21d2f6 Make IRGen compatible with declaring a function with incomplete
return/argument types.  (The generated IR isn't ideal, but we can't 
really do better in general.)

llvm-svn: 66132
2009-03-05 04:18:07 +00:00
Eli Friedman 22fcc24b30 Initial implementation of CodeGen for incomplete function types; fixes
PR3688.  (The FIXME is a rather big performance issue, but it only 
affects code using this feature, which is relatively rare.)

llvm-svn: 66128
2009-03-05 03:16:41 +00:00
Mike Stump 626aecc4be Add codegen support for __block variables to call _Block_object_dispose as necessary.
llvm-svn: 66117
2009-03-05 01:23:13 +00:00
Mike Stump 2d33d6300c Fixup __block codegen in nested block literals.
llvm-svn: 66091
2009-03-04 22:48:06 +00:00
Daniel Dunbar 5b9e9682f1 Support "asm" renaming of external symbols.
- PR3698.

llvm-svn: 66038
2009-03-04 17:31:19 +00:00
Mike Stump 0874160bd5 Add __block codegen testcase. We introduce a temporary flag to enable
codegen, until such time as codegen is complete enough to turn on with
-fblocks.

llvm-svn: 66031
2009-03-04 13:17:22 +00:00
Eli Friedman 3efa41a478 Continuation of PR3687: fix more places to use the right type for
booleans.

llvm-svn: 66012
2009-03-04 04:25:14 +00:00
Eli Friedman 42d2a3add6 Attempt to fix PR3709: when converting from an integer to a pointer,
first extend the integer to the correct width.

llvm-svn: 66009
2009-03-04 04:02:35 +00:00
Eli Friedman 78350edafb Fix for PR3687: use the memory representation for booleans when a
sub-type describes a memory location, like the pointee type of a pointer
or the element type of an array.

llvm-svn: 65925
2009-03-03 04:48:01 +00:00
Daniel Dunbar e2e704752c Attempt to make test more robust (fails for users who put LLVM in
/path/with/store/in/it").

llvm-svn: 65852
2009-03-02 18:50:36 +00:00
Chris Lattner d3fd8fb3ac testcase for mike's fix for PR3612
llvm-svn: 65757
2009-03-01 03:26:22 +00:00
Anders Carlsson ed5e69fe50 Do some blocks cleanup and simplification. Fix a crash, and add a test case.
llvm-svn: 65746
2009-03-01 01:09:12 +00:00
Chris Lattner e87da66562 adjust to changes in the mainline llvm .ll printer.
llvm-svn: 65745
2009-03-01 00:59:19 +00:00
Chris Lattner 3ef668c27a after going around in circles a few times, finally cave and emit structure
copies with memcpy instead of memmove.  This matches what GCC does and if it
causes a problem with a particular libc we can always fix it with a target
hook.

llvm-svn: 65699
2009-02-28 18:18:58 +00:00
Chris Lattner d42c29f9a2 fix some sema problems with wide strings and hook up basic codegen for them.
llvm-svn: 65582
2009-02-26 23:01:51 +00:00
Mike Stump 92000e54ac Add end of line at end.
llvm-svn: 65557
2009-02-26 19:00:14 +00:00
Anders Carlsson 43e8a2b36e Add test for enum types
llvm-svn: 65540
2009-02-26 17:38:19 +00:00
Daniel Dunbar 4208835eec Temporarily disable clearing of insert point (to indicate unreachable
code) when calling noreturn functions; general expression emission
isn't ready to do the right thing in all cases.

llvm-svn: 65473
2009-02-25 20:59:29 +00:00
Daniel Dunbar 1cdbc5404b Allow constant initializers to reference their defining decl.
- PR3662.

llvm-svn: 65472
2009-02-25 20:08:33 +00:00
Daniel Dunbar a1047857f7 Remove a FIXME; I was mistaken in believing gcc rejected this.
llvm-svn: 65420
2009-02-25 00:22:25 +00:00
Daniel Dunbar d4ecca135a Fix IRgen of constant expressions referring to external/static
variables.
 - PR3657.

llvm-svn: 65381
2009-02-24 18:41:57 +00:00
Douglas Gregor e62c0a45dd Improve merging of function declarations. Specifically:
- When we are declaring a function in local scope, we can merge with
    a visible declaration from an outer scope if that declaration
    refers to an entity with linkage. This behavior now works in C++
    and properly ignores entities without linkage.
  - Diagnose the use of "static" on a function declaration in local
    scope.
  - Diagnose the declaration of a static function after a non-static
    declaration of the same function.
  - Propagate the storage specifier to a function declaration from a
    prior declaration (PR3425)
  - Don't name-mangle "main"

llvm-svn: 65360
2009-02-24 01:23:02 +00:00
Mike Stump 624497c29a Cleanp code with some recent suggestions.
llvm-svn: 65285
2009-02-22 13:27:11 +00:00
Anders Carlsson b8482c5d5d Match gcc and always perform array/function conversion for asm input exprs. Fixes PR3641.
llvm-svn: 65256
2009-02-22 02:11:23 +00:00
Daniel Dunbar 9cbbd99c4b Force arch for these test cases.
llvm-svn: 65252
2009-02-21 23:45:41 +00:00
Daniel Dunbar 3c81dabd76 Emit extern_weak when needed.
- PR3629.

llvm-svn: 65203
2009-02-21 00:24:10 +00:00
Daniel Dunbar 0c4eda5923 We must always mangle attribute overloadable functions; even if in a
system header.
 - Prevents a codegen crash when anything used anything in tgmath! :)

llvm-svn: 65200
2009-02-20 23:09:27 +00:00
Daniel Dunbar ce39954d5d Handle constant int -> ptr casts of lvalue results.
- PR3463 (again).

llvm-svn: 65133
2009-02-20 18:22:23 +00:00
Daniel Dunbar cdbb5e336d Set call attribute for direct calls (i.e. noreturn).
- Remove an unused variant of EmitCallExpr overload.

llvm-svn: 65130
2009-02-20 18:06:48 +00:00
Daniel Dunbar e4be42c17f Add some stdlib builtins
llvm-svn: 65115
2009-02-20 06:36:40 +00:00
Daniel Dunbar 1c8560d93e Extend Evaluate() to fold (int) <pointer type>.
- PR3463, PR3398, <rdar://problem/6553401> crash on relocatable
   symbol addresses as constants in static locals.

 - There are many more scenarious we could handle (like arithmetic on
   such an int) but this is the main use case.

llvm-svn: 65074
2009-02-19 22:24:01 +00:00
Anders Carlsson f96954ca30 Add irgen support for the noinline attribute.
llvm-svn: 65056
2009-02-19 19:22:11 +00:00
Daniel Dunbar f0acf7bd4c Don't emit K&R unprototyped function definitions as varargs.
- <rdar://problem/6584606> clang/x86-64 - too many reg saves

llvm-svn: 65032
2009-02-19 07:15:39 +00:00
Daniel Dunbar b2f4cdb233 Emission of global variable initialializer was broken in rare
situation where a tentative decl was emitted *after* the actual
initialization. This occurs in some rare situations with static decls.
 - PR3613.

 - I'm not particularly happy with this fix, but I don't see a simpler
   or more elegant solution yet.

llvm-svn: 65018
2009-02-19 05:36:41 +00:00
Daniel Dunbar 43a5d9e409 Eek! getDeclAlign sometimes returned alignment in bits.
- Renamed to getDeclAlignInBytes since most other query functions
   work in bits.

 - Fun to track down as isIntegerConstantExpr was getting it right,
   but Evaluate() was getting it wrong. Maybe we should assert they
   compute the same thing when they succeed?

llvm-svn: 64828
2009-02-17 22:16:19 +00:00
Daniel Dunbar 38ad1e6138 Change EmitConstantExpr to allow failure.
IRgen no longer relies on isConstantInitializer, instead we just try
to emit the constant. If that fails then in C we emit an error
unsupported (this occurs when Sema accepted something that it doesn't
know how to fold, and IRgen doesn't know how to emit) and in C++ we
emit a guarded initializer.

This ends up handling a few more cases, because IRgen was actually
able to emit some of the constants Sema accepts but can't Evaluate().
For example, PR3398.

llvm-svn: 64780
2009-02-17 18:43:32 +00:00
Daniel Dunbar 8eb018ab9c Support IRgen of sqrt -> llvm.sqrt, pow -> llvm.pow.
- Define pow[lf]?, sqrt[lf]? as builtins.

 - Add -fmath-errno option which binds to LangOptions.MathErrno

 - Add new builtin flag Builtin::Context::isConstWithoutErrno for
   functions which can be marked as const if errno isn't respected for
   math functions. Sema automatically marks these functions as const
   when they are defined, if MathErrno=0.

 - IRgen uses const attribute on sqrt and pow library functions to
   decide if it can use the llvm intrinsic.

llvm-svn: 64689
2009-02-16 22:43:43 +00:00
Daniel Dunbar e28b359881 Fix IRgen of __builtin_memset.
- Fix test case to not only have negative tests.

llvm-svn: 64674
2009-02-16 21:52:05 +00:00
Douglas Gregor bfdd607372 When merging from a function with a prototype to a function without a
prototype, synthesize ParmVarDecls for prototype-less FunctionDecl.

llvm-svn: 64666
2009-02-16 20:58:07 +00:00
Daniel Dunbar f898638eee PR3589: Don't simplify libcalls with -ffreestanding.
llvm-svn: 64599
2009-02-15 20:00:15 +00:00
Daniel Dunbar 019ef0bbfe x86_64 ABI: Pass simple types directly when possible. This is
important for both keeping the generated LLVM simple and for ensuring
that integer types are passed/promoted correctly.

llvm-svn: 64529
2009-02-14 02:09:24 +00:00
Chris Lattner cd7bc144f6 fix rdar://6586493, a bug in codegen of the GNU
missing-?:-true-value extension.

llvm-svn: 64505
2009-02-13 23:35:32 +00:00
Douglas Gregor b9063fc1b3 Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:

  1) When we're supporting the "implicit function declaration" feature
  of C99, these functions will be implicitly declared with the right
  signature rather than as a function returning "int" with no
  prototype. See PR3541 for the reason why this is important (hint:
  GCC always predeclares these functions).
 
  2) If users attempt to redeclare one of these library functions with
  an incompatible signature, we produce a hard error.

This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:

  'strcpy' was implicitly declared here with type 'char *(char *, char
  const *)'

but we should really print out a fake code line showing the
declaration, like this:

  'strcpy' was implicitly declared here as:

    char *strcpy(char *, char const *)

This would also be good for printing built-in candidates with C++
operator overloading.

The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.

llvm-svn: 64504
2009-02-13 23:20:09 +00:00
Daniel Dunbar f9f039865f Set constant bit on static block vars as well. Patch by Anders Johnson!q
llvm-svn: 64502
2009-02-13 22:58:39 +00:00
Daniel Dunbar 128a138a57 IRgen support for attribute used.
- PR3566

llvm-svn: 64492
2009-02-13 22:08:43 +00:00
Daniel Dunbar 6b8720e723 Pull MayDeferGeneration out of EmitGlobal.
- Fix emission of static functions with constructor attribute while I
   was here.
<rdar://problem/6140899> [codegen] "static" and attribute-constructor interact poorly

llvm-svn: 64488
2009-02-13 21:18:01 +00:00
Anders Carlsson 63784f4e5e Add CodeGen support for the nodebug attribute.
llvm-svn: 64445
2009-02-13 08:11:52 +00:00
Douglas Gregor adb0201418 Add mangling for variadic functions and conversion functions
llvm-svn: 64425
2009-02-13 01:28:03 +00:00
Douglas Gregor 5fec5b0495 Add basic support for C++ name mangling according to the Itanium C++
ABI to the CodeGen library. Since C++ code-generation is so
incomplete, we can't exercise much of this mangling code. However, a
few smoke tests show that it's doing the same thing as GCC. When C++
codegen matures, we'll extend the ABI tester to verify name-mangling
as well, and complete the implementation here.

At this point, the major client of name mangling is in the uses of the
new "overloadable" attribute in C, which allows overloading. Any
"overloadable" function in C (or in an extern "C" block in C++) will
be mangled the same way that the corresponding C++ function would be
mangled.

llvm-svn: 64413
2009-02-13 00:10:09 +00:00
Daniel Dunbar 53bf741208 Honor attribute section on static block var decls.
llvm-svn: 64411
2009-02-12 23:32:54 +00:00
Daniel Dunbar 648bf78333 Support __attribute__(section(<name>))
llvm-svn: 64380
2009-02-12 17:28:23 +00:00
Daniel Dunbar eef883327a Test case for emitting va_arg as l-value; apparently I only *thought* I had committed this.
llvm-svn: 64368
2009-02-12 08:41:10 +00:00
Chris Lattner 60dcdc7062 finish off codegen support for sub of pointer to functions,
finishing off rdar://6520707

llvm-svn: 64295
2009-02-11 07:21:43 +00:00
Anders Carlsson 7ccf3e4e28 Handle the case where EmitBlock might be called multiple times for the same block. Fixes PR3536.
llvm-svn: 64252
2009-02-10 22:50:24 +00:00
Daniel Dunbar 2daa142765 Enable parameter passing test for x86_64.
llvm-svn: 64195
2009-02-10 01:53:22 +00:00
Daniel Dunbar d5f1f55e28 Make sure to initialize local variables, even if they were ignored by
ABI.

llvm-svn: 64187
2009-02-10 00:06:49 +00:00
Anders Carlsson d19fd0dd57 Move previously unsupported VLA test to vla.c
llvm-svn: 64173
2009-02-09 21:48:07 +00:00
Daniel Dunbar 7aa851246e Update test case; VLA's are now supported.
llvm-svn: 64168
2009-02-09 21:19:23 +00:00
Daniel Dunbar fe2fb0af5a Use 'compile' instead of 'codegen' when reporting error to user.
llvm-svn: 63952
2009-02-06 19:18:03 +00:00
Daniel Dunbar 3b2dd4368a Add bare bones test that parameter passing is consistent for
scalar/complex/aggregate cases.
 - Currently disabled for x86_64, triggering a misoptimization
   (PR3489).

llvm-svn: 63864
2009-02-05 11:21:33 +00:00
Daniel Dunbar fa803cd260 Test case for -femit-all-decls.
llvm-svn: 63777
2009-02-04 21:20:25 +00:00
Daniel Dunbar c41a0b8a3c Force -triple/-fnext-runtime for a few more test cases.
llvm-svn: 63679
2009-02-03 23:04:31 +00:00
Daniel Dunbar 25bd032084 Force triple for codegen tests which have expectations on output
types.

llvm-svn: 63669
2009-02-03 21:54:49 +00:00
Douglas Gregor d42a0fb41b Upgrade the "excess elements in array initializer" warning to an
error, since both C99 and C++ consider it an error. For reference, GCC
makes this a warning while G++ makes it an error.

llvm-svn: 63435
2009-01-30 22:26:29 +00:00
Anders Carlsson 221483dd4e Make sure to cast the VLA size of array to the type of size_t. Fixes PR3442.
llvm-svn: 63394
2009-01-30 16:41:04 +00:00
Nuno Lopes 92f95eb739 enable test as it already works
llvm-svn: 63390
2009-01-30 12:58:18 +00:00
Douglas Gregor 0202cb406e Introduce a new expression node, ImplicitValueInitExpr, that
represents an implicit value-initialization of a subobject of a
particular type. This replaces the (ab)use of CXXZeroValueInitExpr
within initializer lists for the "holes" that occur due to the use of
C99 designated initializers.

The new test case is currently XFAIL'd, because CodeGen's
ConstExprEmitter (in lib/CodeGen/CGExprConstant.cpp) needs to be
taught to value-initialize when it sees ImplicitValueInitExprs.

llvm-svn: 63317
2009-01-29 17:44:32 +00:00
Daniel Dunbar 74f2425b89 Evaluate ==,!= for complex types.
llvm-svn: 63280
2009-01-29 06:43:41 +00:00
Daniel Dunbar f50e60b23a Implement basic _Complex integer constant folding.
- Merged into single ComplexEvaluator, these share too much logic to
   be worth splitting for float/int (IMHO). Will split on request.

llvm-svn: 63248
2009-01-28 22:24:07 +00:00
Nuno Lopes bb537dc189 fix PR3427: fix debuginfo for incomplete array types
llvm-svn: 63158
2009-01-28 00:35:17 +00:00
Anders Carlsson 570c357ded If an input constraint refers to an output constraint, it should have the same constraint info as the output constraint. Fixes PR3417
llvm-svn: 63127
2009-01-27 20:38:24 +00:00
Chris Lattner 75441a3870 eliminate some random .ll file outputs
llvm-svn: 63117
2009-01-27 18:56:08 +00:00
Daniel Dunbar 7a88d1fcc4 Fix definition of __builtin_ia32_vec_set_v2di and de-XFAIL
builtins-x86.c.

llvm-svn: 63069
2009-01-26 23:43:02 +00:00
Eli Friedman c69d454d5a Make the constant folder aware of
__builtin___CFStringMakeConstantString.  (We get into trouble in 
GenerateStaticBlockVarDecl if the constant folder isn't accurate.)

llvm-svn: 62949
2009-01-25 01:54:01 +00:00
Eli Friedman 529a99bcf4 Fix the address of a label to be properly considered and emitted as a
constant.

llvm-svn: 62948
2009-01-25 01:21:06 +00:00
Eli Friedman 8549e5dcc8 Fix for PR2910: implement CodeGen for non-constant offsetof.
Note that there are still other issues in this area; see PR3396.

llvm-svn: 62942
2009-01-24 22:38:55 +00:00
Daniel Dunbar 42a8cd37b2 Handle pointer arithmetic on function pointers.
- <rdar://problem/6518844> Clang-generated bitcode crashes LLVM while compiling function pointer addition expression

llvm-svn: 62857
2009-01-23 18:51:09 +00:00
Daniel Dunbar 56493b0d54 Allow creation of "dummy" compile units for debug information.
- Although gross, this is needed currently to ensure that we produce
   well formed debug information (to match pace with the assertions
   being added to DebugInfo in LLVM).

llvm-svn: 62734
2009-01-22 00:09:25 +00:00
Nate Begeman b699c9bf57 Vector codegen improvements
llvm-svn: 62458
2009-01-18 06:42:49 +00:00
Nate Begeman 2f2bdeb5df Support evaluation of vector constant expressions, and codegen of same.
llvm-svn: 62455
2009-01-18 03:20:47 +00:00
Nate Begeman 7e5185b264 A couple more vector component access fixes.
llvm-svn: 62443
2009-01-18 02:01:21 +00:00
Nuno Lopes 4d78cf0fa7 add support for usage of cast to union thing with static vars
llvm-svn: 62387
2009-01-17 00:48:48 +00:00
Nuno Lopes 7ffcf93b24 add codegen support to union casts
init of static vars still not working. I'll get back to it tomorrow or so

llvm-svn: 62278
2009-01-15 20:14:33 +00:00
Daniel Dunbar dec798bf37 Bug fix, __private_extern__ globals were always introducing a definition.
llvm-svn: 62139
2009-01-13 02:25:00 +00:00
Anders Carlsson 00057e4e09 Handle multi-value inputs
llvm-svn: 62069
2009-01-12 02:22:13 +00:00
Anders Carlsson 431acd1129 More inline asm fixes
llvm-svn: 62049
2009-01-11 21:23:27 +00:00
Anders Carlsson a948c34b0b Handle readwrite constraints correctly
llvm-svn: 62043
2009-01-11 19:46:50 +00:00
Chris Lattner 610c87cad6 rename these tests to match the attribute.
llvm-svn: 61770
2009-01-05 23:10:19 +00:00
Daniel Dunbar 0d2bfec51d Remainder is only valid on integer vector operands.
Improve ext vector test case.

llvm-svn: 61766
2009-01-05 22:55:36 +00:00
Anders Carlsson 762e162284 Fix the bug that would cause Python to crash at startup.
When emitting the static variables we need to make sure that the order is preserved. 
Fix this by making StaticDecls a std::list which has O(1) random removal.

llvm-svn: 61621
2009-01-04 02:08:04 +00:00
Anton Korobeynikov d72f47aa05 Add full dllimport / dllexport support: both sema checks and codegen.
Patch by Ilya Okonsky

llvm-svn: 61437
2008-12-26 00:52:02 +00:00
Anders Carlsson 118467dfb7 Commit the right version of the test
llvm-svn: 61302
2008-12-21 03:40:32 +00:00
Anders Carlsson 76dbc0423e Make sure to emit the size expression for sizeof(type)
llvm-svn: 61301
2008-12-21 03:33:21 +00:00
Eli Friedman f4084708cd Make VLAs usable, and make basic usage work correctly. Also, add a
simple test that actually does VLA codegen.

Note that despite the fact that the alloca isn't in the entry block, it 
should dominate all uses; this is guaranteed by the restrictions on goto 
into VLA scope in C99.

llvm-svn: 61291
2008-12-20 23:11:59 +00:00
Anders Carlsson 6200f0c533 Add some ErrorUnsupported calls and turn on VLA codegen again.
llvm-svn: 61283
2008-12-20 19:33:21 +00:00
Chris Lattner 3d72297909 diagnose C99 6.9.1p5, C arguments in definitions that are lacking
a name.  This implements PR3208.

llvm-svn: 61127
2008-12-17 07:32:46 +00:00
Sebastian Redl 19ed30be38 stdlib.h is the wrong header for printf, and introduces test-breaking definitions of inlines on Linux
llvm-svn: 60981
2008-12-13 15:31:28 +00:00
Daniel Dunbar a4daf203fe Add test case for using mmintrin (and making sure that inlining is
working with and without debug info).

llvm-svn: 60960
2008-12-12 19:12:02 +00:00
Anders Carlsson 45f4b8c0f2 Fix invalid bit-field.
llvm-svn: 60627
2008-12-06 20:32:39 +00:00
Anders Carlsson 1e495d9860 Make Sema::CheckForConstantInitializer use Expr::Evaluate. This fixes PR3130.
llvm-svn: 60580
2008-12-05 05:09:56 +00:00
Anders Carlsson 6a113d9ddb If a global var decl has an initializer, make sure to always set its linkage to external.
llvm-svn: 60462
2008-12-03 05:51:23 +00:00
Eli Friedman e918435f94 Fix for PR3150: obvious copy-paste bug in
ScalarExprEmitter::VisitBinLOr.

llvm-svn: 60415
2008-12-02 16:02:46 +00:00
Anders Carlsson f7a9a92359 Convert incomplete array types before emitting debug info for them, fixes PR3134.
llvm-svn: 60109
2008-11-26 17:40:42 +00:00
Anders Carlsson 32ef8ceaa1 Handle returning complex types that get coerced. Fixes PR3131
llvm-svn: 60058
2008-11-25 22:21:48 +00:00
Anders Carlsson a7c5eb72a0 Reimplement Expr::isConstantExpr in terms of Expr::Evaluate. This fixes PR2832.
llvm-svn: 59946
2008-11-24 05:23:59 +00:00
Anders Carlsson 87da2b5dce Forgot the newline :)
llvm-svn: 59942
2008-11-24 05:13:45 +00:00
Anders Carlsson 3abcb58a35 Add test case for bug that's been fixed.
llvm-svn: 59941
2008-11-24 05:11:21 +00:00
Anders Carlsson 4d5f2e532c Add test for PR2992.
llvm-svn: 59861
2008-11-22 06:42:54 +00:00
Nuno Lopes 0e33c688d5 fix folding of '*doubleArray'
llvm-svn: 59647
2008-11-19 17:44:31 +00:00
Daniel Dunbar 9b1335eca8 Fix redundant load of bit-fields on assignment (to get the updated
value).
 - Use extra argument to EmitStoreThroughLValue to provide place to
   write update bit-field value if caller requires it.
 - This fixes several FIXMEs.

llvm-svn: 59615
2008-11-19 09:36:46 +00:00
Nuno Lopes e236a48210 fix folding of comma if given a non-constant operand.
Eli please take a look, as I'm not sure if this gets the extension warning in the right place

llvm-svn: 59422
2008-11-16 20:09:07 +00:00
Sebastian Redl 85a4019167 Fix testcase for 64-bit systems.
llvm-svn: 59099
2008-11-12 00:18:32 +00:00
Anton Korobeynikov fdf389b9e4 Codegen support for fastcall & stdcall CC.
Patch by Ilya Okonsky!

llvm-svn: 59080
2008-11-11 20:21:14 +00:00
Chris Lattner bd178d51ff merge some testcases together.
llvm-svn: 59031
2008-11-11 06:42:53 +00:00
Chris Lattner 4497fbf6e0 remove the wrong PR # from the file name.
llvm-svn: 59029
2008-11-11 06:28:10 +00:00
Chris Lattner d75e4e59b9 add PR#
llvm-svn: 59028
2008-11-11 06:27:34 +00:00
Daniel Dunbar 471d9ddeab These tests have no needed to redirect stderr to stdout.
llvm-svn: 59019
2008-11-11 04:09:47 +00:00
Daniel Dunbar 8ec8048f93 "Fix" PR3021, don't crash on generating record types when we can't
generate the type of a member.

llvm-svn: 58889
2008-11-08 04:42:29 +00:00
Daniel Dunbar d678ae2da3 Quick fix for PR2950, infinite loop generating debug info for
recursive types.
 - Style will be clean up in further patches.

llvm-svn: 58490
2008-10-31 04:04:54 +00:00
Daniel Dunbar 03a3844c66 Add attribute always_inline support.
llvm-svn: 58304
2008-10-28 00:17:57 +00:00
Daniel Dunbar 0b288b8a59 Add test case to exercise IRgen "unsupported" path (mostly cleanup).
llvm-svn: 58286
2008-10-27 22:11:01 +00:00
Mon P Wang 179a72f000 Added vec_set intrinsics
llvm-svn: 57749
2008-10-18 02:43:25 +00:00
Daniel Dunbar 380827cfa1 Quick patch for PR2784, assert genereting debug info for opaque
structure.
 - I'm not sure yet about the behavior, but this at least prevents the
   crash.

Add some asserts on RegionStack usage.

llvm-svn: 57661
2008-10-17 01:07:56 +00:00
Chris Lattner 25728d931a fix incorrect rdar number.
llvm-svn: 57165
2008-10-06 07:43:28 +00:00
Chris Lattner 1b0a00a4c9 __CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329

llvm-svn: 57164
2008-10-06 07:43:09 +00:00
Chris Lattner a97132a9c4 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.

llvm-svn: 57163
2008-10-06 07:26:43 +00:00
Daniel Dunbar 93bc49d882 Add X86 builtin code generation test case.
llvm-svn: 57104
2008-10-05 06:38:36 +00:00
Daniel Dunbar b11d5d65e8 Add some builtins to codegen test case.
llvm-svn: 57101
2008-10-05 06:34:45 +00:00
Nuno Lopes a459f12862 fix test for latest changes in llvm asm representation
llvm-svn: 56842
2008-09-30 14:37:33 +00:00
Daniel Dunbar 00e36f4c5c Fix function-attributes test case to not rely on llvm-gcc.
llvm-svn: 56734
2008-09-27 00:44:01 +00:00
Daniel Dunbar 23b46ca198 Fix attributes test case to not run clang umpteen times.
llvm-svn: 56733
2008-09-27 00:39:13 +00:00
Daniel Dunbar c6fdac260b Bug fix, result of isIntegerConstantExpr could be of incorrect width
for type.
  - PR2817

llvm-svn: 56482
2008-09-22 23:53:24 +00:00
Argyrios Kyrtzidis 07052350f0 Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which represents a 'condition' declaration, e.g: "if (int x=0) {...}".
llvm-svn: 56045
2008-09-10 02:36:38 +00:00
Daniel Dunbar 0beedc1684 Fix a number of issues w.r.t. emission of global for functions and
aliases.
 - Attributes specific to a definition are only set when the
   definition is seen.
 - Alias generation is delayed until the end of the module; necessary
   since the alias may reference forward.
 - Fixes: PR2743, <rdr://6140807&6094512>
 - Improves: <rdr://6095112> (added XFAIL)

Also, print module on verification failures.

llvm-svn: 55966
2008-09-08 23:44:31 +00:00
Daniel Dunbar 47be094138 Add missing RUN line
llvm-svn: 55934
2008-09-08 18:01:15 +00:00
Argyrios Kyrtzidis 91c3f526dc Line endings: CRLF -> LF
llvm-svn: 55829
2008-09-05 08:53:53 +00:00
Daniel Dunbar 2ffee610da Set sext/zext on function result.
- <rdar://problem/6156739>

llvm-svn: 55815
2008-09-05 00:57:45 +00:00
Daniel Dunbar 8cde00a510 Implement codegen of aggregates as lvalues in binary expressions,
e.g. "(a = b).somefield".

llvm-svn: 55758
2008-09-04 03:20:13 +00:00
Daniel Dunbar 20e5db77a3 Add two test cases for builtins (mostly related to object size
builtins).

llvm-svn: 55736
2008-09-03 21:17:21 +00:00
Daniel Dunbar 40bf7fe20e In incompatible pointer-typed ?: expressions, add implicit conversion
of RHSs to id type instead of void* if either has Objective-C object
type.
 - This ensures the result can still be used in normal places an
   object can be used, like a message send.

Add implicit conversions for ?: applied to qualified id types to
ensure that the RHSs are compatible. 
 - This prevents a codegen crash (creating invalid PHI nodes).
 - Again, this relates to the fact that qualified id types have no
   canonical types.
 - Note that the implicit type casted to is incorrect, however this
   doesn't currently cause problems because of the flexibility of the
   id type.

Test cases for above.

llvm-svn: 55346
2008-08-26 00:41:39 +00:00
Eli Friedman 3d421e190a Do typechecking and codegen for K&R-style function declarations
correctly.  Not a regression, but made more obvious by my recent fix 
which made function type compatibility checking a bit more strict.

llvm-svn: 55339
2008-08-25 21:31:01 +00:00
Argyrios Kyrtzidis ce4528f008 Add CodeGen support for CXXZeroInitValueExpr.
llvm-svn: 55249
2008-08-23 19:35:47 +00:00
Daniel Dunbar 5f977e7b15 Missed a test case writing a .ll file.
Suppress count output from 'make test' on errors (used to generate
result code).

llvm-svn: 55107
2008-08-21 04:30:23 +00:00
Daniel Dunbar 19d84c3c51 Update a number of CodeGen tests to not create .ll files in the test
directory.
 - Removed .ll from the svn:ignore lists to try and prevent this.
 - Added svn:ignore on test/Misc/Output

llvm-svn: 55104
2008-08-21 02:51:29 +00:00
Daniel Dunbar 94834d8883 Fix subtle bug introduced in r54852.
- UsualUnaryConversions takes an Expr *& and may modify its argument,
   this broke when it was refactored into Sema::CheckCastTypes. This
   meant that we were missing implicit casts in some places.
 - Seems pretty sad that this got through our tests.

llvm-svn: 55039
2008-08-20 03:55:42 +00:00
Daniel Dunbar 5a42754328 Fix test case RUN: line (thanks Argiris)
llvm-svn: 54922
2008-08-18 17:52:17 +00:00
Nuno Lopes cb46c144bc make sure the size of constant arrays is respected
llvm-svn: 54769
2008-08-13 23:28:57 +00:00
Daniel Dunbar c4baa06d15 Add GetAddrOfConstantCString method
- Returns addr of constant for argument + '\0'.
 - I couldn't think of a better name.
 - Move appropriate users of GetAddrOfConstantString to this.

Rename getStringForStringLiteral to GetStringForStringLiteral.

Add GetAddrOfConstantStringFromLiteral
 - This combines GetAddrOfConstantString and
   GetStringForStringLiteral. This method can be, but is not yet, more
   efficient.

Change GetAddrOfConstantString to not add terminating '\0'
 - <rdar://problem/6140956>

llvm-svn: 54768
2008-08-13 23:20:05 +00:00
Daniel Dunbar 2de4b5e2fc Add test case for -fexceptions
llvm-svn: 54647
2008-08-11 18:40:47 +00:00
Daniel Dunbar 07bb087ac1 Fix crash during initialization of a bitfield which followed a zero
length element.

Fix some 80-col violations.

llvm-svn: 54610
2008-08-10 07:00:24 +00:00
Daniel Dunbar 8d81683554 Replace old bitfield test.
- Change hardcoded assembly instructions to a use of 'opt' (still
   waiting for someone to yell at me for this).

 - Add some cases to cover behavior fixed by previous commit.

llvm-svn: 54413
2008-08-06 16:07:39 +00:00
Daniel Dunbar e8bdce441b Fix EmitNullInitializationToLValue for bitfield lvalues.
- PR2643

llvm-svn: 54397
2008-08-06 05:32:55 +00:00
Daniel Dunbar ead7c91240 Fix bitfield accesses which straddle the boundary of the underlying
type.

 - This generates somewhat less optimal code than before but this is
   not hard to rectify once stable (at the cost of slightly more
   complex code).

 - This currently always uses little-endian ordering of the bitfield. 

 - This breaks the CodeGen/bitfield.c test because it was grepping for
   hard-coded assembly instructions. Will fix once a better test case
   is constructed (hard to do without execution).

 - This fixes SingleSource/UnitTests/2006-01-23-InitializedBitField.c
   and Regression/C/PR1386.c from the test suite.

 - <rdar://problem/6085090>, <rdar://problem/6094169>

llvm-svn: 54395
2008-08-06 05:08:45 +00:00
Daniel Dunbar bfb1cd7454 Fix CodeGen of pointer arithmetic in compound assignment statements.
- Changed EmitSub to work on all cases (arithmetic, ptr - int, ptr -
   ptr) so that implementation matches that of other operators.

 - Modify EmitCompoundAssign to compute and perform the appropriate
   casts of left, right, and result types for the assorted pointer
   arithmetic cases.

 - Fix EmitSub (ptr - int) case to negate the rhs *after*
   extension. This is critical when the rhs is unsigned (and needs
   extension).

 - This fixes cfrac.

 - <rdr://6115726>

llvm-svn: 54392
2008-08-06 02:00:38 +00:00
Daniel Dunbar ffc29be83f Implement GNU asm-label extension support in CodeGen. This fixes
scimark2 on Darwin.

 - Added Sema support for asm-label on variables, which I forgot before.

 - Update CodeGen to use GlobalDeclMap to determine if static Decls
   require emission (instead of LLVM module name lookup). Important
   since the Decl name and the LLVM module name can differ.

 - <rdar://problem/6116729>

llvm-svn: 54388
2008-08-06 00:03:29 +00:00
Daniel Dunbar 829e988899 Change CodeGen of global decls to key off of the name (instead of
having multiple bindings from all the possible decls which
  conceptually map to the same global).

 - This eliminates CodeGen depending on the LLVM module for name
   lookup.

 - This also eliminates the need for ReplaceMapValuesWith (hurrah).

 - This handles lookups for FunctionDecls correctly in the presence of
   aliases, this was previously broken.

 - WIP: Can still clean up & unify variable and function emission.

llvm-svn: 54382
2008-08-05 23:31:02 +00:00
Daniel Dunbar eca183bad2 Add test case for PR2001.
llvm-svn: 54352
2008-08-05 16:15:29 +00:00
Daniel Dunbar d548c79eaf Fix const-init test case
- Use -verify and added expected warnings for EXTWARN change.

llvm-svn: 54342
2008-08-05 06:30:41 +00:00
Daniel Dunbar 5aa55d51ca Bug fix, CodeGen of (void*) - (void*) was broken.
- <rdar://problem/6122967>

llvm-svn: 54338
2008-08-05 00:47:03 +00:00
Daniel Dunbar 88402ce8d0 Add CodeGen support for indirect goto.
- Follows emission scheme used by llvm-gcc, i.e. invent an id for
   each label whose address is taken and replace each indirect goto by
   a switch to each possible target.
 - Currently we emit a switch for each indirect goto instead of
   merging them as llvm-gcc does.

llvm-svn: 54318
2008-08-04 16:51:22 +00:00
Daniel Dunbar 74aa7e1eae Support constructor and destructor attributes in CodeGen
- There is an miscompilation issue remaining due to a poor
   interaction between the delayed emission of static functions and
   the emission of constructors, but that already existed prior to
   this change.

llvm-svn: 54258
2008-08-01 00:01:51 +00:00
Chris Lattner 330f0f2567 Fix a regression I introduced in r54107:
http://llvm.org/viewvc/llvm-project?view=rev&revision=54107

llvm-svn: 54242
2008-07-31 04:58:58 +00:00
Daniel Dunbar b39b1cd7c3 Fix implicit initialization of structures.
<rdar://problem/6113085>

llvm-svn: 54237
2008-07-30 21:00:24 +00:00
Daniel Dunbar e49df9b58f Change CodeGenModule GlobalDeclMap to directly reference globals
instead of mapping the decl to a bitcast of the global to the correct
type.
 
 - GetAddrOf{Function,GlobalVar} introduce the bitcast on every use now.

 - This solves a problem where a dangling pointer could be introduced
   by the RAUW done when replacing a forward or tentative
   definition. See testcase for more details.

 - Fixes <rdar://problem/6108358>

llvm-svn: 54211
2008-07-30 16:32:24 +00:00
Daniel Dunbar 837fd272f8 Fix codegen of chained declarations
- Killed useless CodeGenModule::EmitGlobalVarDeclarator, instead just
   recurse on any ScopedDecl.
 - Fix for <rdar://problem/6093838>

llvm-svn: 54162
2008-07-29 17:47:36 +00:00
Chris Lattner 4591fd0aac Fix rdar://6103124, the only dummy blocks are ones without names. Named blocks
are important part of control flow structures.

llvm-svn: 54078
2008-07-25 23:40:10 +00:00
Daniel Dunbar b5586dad97 Fix long double test case
- Had wrong sizeof(long double) encoded into test case
 - Results now agree with llvm-gcc

llvm-svn: 54059
2008-07-25 20:54:30 +00:00
Daniel Dunbar 0e5845c13a Rework codegen of case ranges
- Fix multiple issues with the way case ranges were emitted, see test
   cases details about the specific issues.

 - The root issue was not being careful about how basic blocks were
   emitted which led to them being chained together incorrectly,
   resulting in improper control flow.

 - Fixes <rdar://problem/6098585>

llvm-svn: 54006
2008-07-25 01:11:38 +00:00
Chris Lattner d258325c2b Fix a codegen crash on:
int foo(void) {
  float x[2];
  return x;
}

rdar://6093986

llvm-svn: 53946
2008-07-23 06:31:27 +00:00
Daniel Dunbar 327acd7a6c Implement bzero, memset, memmove builtins.
This subsumes Nico Weber's patch and implements bzero in terms
of llvm.memset to match llvm-gcc.

llvm-svn: 53888
2008-07-22 00:26:45 +00:00
Daniel Dunbar c2f67966f4 Add __builtin_powi[fl] support
llvm-svn: 53866
2008-07-21 18:44:41 +00:00
Daniel Dunbar d93abc3bb0 Implement ffs, parity, and popcount builtins.
+ test case

llvm-svn: 53851
2008-07-21 17:19:41 +00:00
Daniel Dunbar 155ed24359 Prevent clang from emitting output when input has errors
+ test case
<rdar://problem/6080040>
http://llvm.org/bugs/show_bug.cgi?id=2280

llvm-svn: 53756
2008-07-18 16:38:05 +00:00
Chris Lattner e6c693d932 Fix a bug where we didn't promote 'const float' (or typedefs) to
double in some places.

llvm-svn: 52846
2008-06-27 22:48:56 +00:00
Chris Lattner 4b413ea3bf fix a bug handling type attributes in the declspec. declspec processing
used to mutate the attribute list for declspecs when the type was 
converted, breaking the case where one declspec was shared by multiple
declarators.

This fixes rdar://6032532.

llvm-svn: 52769
2008-06-26 06:27:57 +00:00
Chris Lattner 64d8d074a8 fix this testcase after Mon Ping's intrinsic rename.
llvm-svn: 52754
2008-06-26 04:06:27 +00:00
Chris Lattner 5a92bab4f0 "This moves built-in Objective-C types up the scope chains to where they can be replaced by versions included from the runtime library's headers."
This makes it ok to use @"foo" without a declaration for NSConstantString.

Patch by David Chisnall!

llvm-svn: 52593
2008-06-21 20:20:39 +00:00
Eli Friedman fd4c32164c Make this test actually pass, in addition to the previous patch
which made it work.

llvm-svn: 52382
2008-06-17 05:36:46 +00:00
Eli Friedman 327944b343 Basic support for volatile loads and stores. Stores the volatile
qualifier in the lvalue, and changes lvalue loads/stores to honor 
the volatile flag.  Places which need some further attention are marked 
with FIXMEs.

Patch by Cédric Venet.

llvm-svn: 52264
2008-06-13 23:01:12 +00:00
Argyrios Kyrtzidis caec17eab9 Fix broken test.
llvm-svn: 52232
2008-06-12 12:44:52 +00:00
Argyrios Kyrtzidis 351763e156 Multiple tests in a single test file must be linked with '&&'.
Otherwise, failing tests other than the last one will not be reported.

llvm-svn: 52231
2008-06-12 12:40:02 +00:00
Argyrios Kyrtzidis 34fe86cd9c Fix the setup of CodeGen/bitfield.c test.
Due to the broken setup it was passing the test while it should have failed.

llvm-svn: 52181
2008-06-10 15:48:26 +00:00
Eli Friedman d5b11a3adc Don't include complex.h or tgmath.h for this test; they aren't needed,
and including tgmath.h causes the test to fail for no good reason.

llvm-svn: 52167
2008-06-10 05:09:36 +00:00
Eli Friedman e6e0f23a29 Add code to make test/CodeGen/struct-init.c work correctly without the
pointer cast hack currently in isIntegerConstantExpr 
(in lib/AST/Expr.cpp).  Also removes an odd test that even gcc doesn't accept.

The reason the pointer cast hack is relevant here is that it makes Sema 
end up misinterpreting the relevant expression as a null pointer constant.

The reason for this patch is that I plan to remove the pointer cast hack 
sometime soon because it causes strange issues, especially in its 
current form; see my recent email to cfe-dev
"[PATCH] add constant expression evaluation to the AST and fix PR2413".

llvm-svn: 52120
2008-06-09 05:05:07 +00:00
Nuno Lopes b6f7953818 implement the alias attirbute (in both Sema and Codegen)
llvm-svn: 52092
2008-06-08 15:45:52 +00:00
Eli Friedman c98a7add43 Don't crash emitting an initializer for a static local with union type.
This fix just makes sure to construct the global with the appropriate 
type, and fixes up the one user this affects to compensate.

llvm-svn: 52084
2008-06-08 01:23:18 +00:00
Eli Friedman 3ce7b20590 Fix crash with conversion to an address-space-qualified pointer. Bug
reported on cfe-dev by Cédric Venet.

Note that I seriously doubt that this perticular construct is useful, 
though: it's a pointer in an alternate address space pointing into 
unqualified address space.

llvm-svn: 52076
2008-06-07 17:27:51 +00:00
Eli Friedman fd1e32b1f3 Reorganize this loop a bit so it doesn't crash for empty unions. Fixes
PR2419.

llvm-svn: 52060
2008-06-06 20:12:37 +00:00
Nuno Lopes 9b07b7b099 implement constant expr. sub ptr ptr
llvm-svn: 52049
2008-06-06 16:41:08 +00:00
Eli Friedman 2425cd8158 For setting attributes, don't assume there are ParamVarDecls available,
because trying to access non-existent ParamVarDecls can crash. 
Testcase from the original source for PR2414.

llvm-svn: 51960
2008-06-04 19:41:28 +00:00
Nuno Lopes 7bd6e58ddc fix crash when codegening 'cond ? lhs : call-to-void-func()'
llvm-svn: 51958
2008-06-04 19:15:45 +00:00
Eli Friedman 8547e1d129 Don't assume that the type of a FunctionDecl is a FunctionType; that
assumption isn't accurate in the presence of typedefs.

llvm-svn: 51951
2008-06-04 17:58:41 +00:00
Nuno Lopes 3fe4651e2e fix decl attributes cleaning
this plugs the leak of attributes and also fixes a crash in the test

llvm-svn: 51862
2008-06-01 22:53:53 +00:00
Eli Friedman 10c2417570 Make sure _Bool globals have the correct type.
llvm-svn: 51838
2008-06-01 15:31:44 +00:00
Eli Friedman 252e5f1b29 Calculate alignment for local variables.
llvm-svn: 51826
2008-05-31 21:20:41 +00:00
Eli Friedman 6859a1b961 PR1893: Fix up the type of tentative definitions of incomplete array
types so that they end up the correct size.

llvm-svn: 51787
2008-05-30 20:39:54 +00:00
Eli Friedman 34994cbcbf Fix and enable generating general union initializers. Essentially, what
this does is reconstruct the type for structs and arrays if the type 
wouldn't be compatible otherwise.

The assertion about packing in the struct type reconstruction code 
sucks, but I don't see any obvious way to fix it.  Maybe we need a general
utility method to take a list of types and alignments and try to construct an
unpacked type if possible?

llvm-svn: 51785
2008-05-30 19:58:50 +00:00
Eli Friedman f7fe41656c Fix constant vector init for initializer lists with an incomplete list
of elements.

llvm-svn: 51769
2008-05-30 12:02:14 +00:00
Eli Friedman 617ba48fd5 Always check that the definition of a function has the correct type.
This fixes a crash on the included testcase (found in NetHack).

llvm-svn: 51767
2008-05-30 11:13:18 +00:00
Eli Friedman 43a6d51494 More complete/correct implementation of the comparison operators for
constant expressions.

llvm-svn: 51682
2008-05-29 15:17:49 +00:00
Eli Friedman 3c28524632 Fix an extremely subtle bug with pointer comparisons: they have to be
unsigned because it's possible (at least in theory) to have
have both positive and negative pointers pointing to the same object.

llvm-svn: 51681
2008-05-29 15:09:15 +00:00
Eli Friedman 133e8040ca Rearrange EmitLValueForField a bit to work properly for _Bool bitfields
in unions (we don't want to do the union-specific bitcast for 
bit-fields).

llvm-svn: 51678
2008-05-29 11:33:25 +00:00
Eli Friedman 045bf4ff82 Add codegen support for a few more kinds of initializer constant
expressions.

llvm-svn: 51677
2008-05-29 11:22:45 +00:00
Eli Friedman 174d9c26f1 Add CodeGen support for alignment on globals, both for unusual natural
alignment and alignment attributes.

llvm-svn: 51676
2008-05-29 11:10:27 +00:00
Eli Friedman d72a9624a1 Tentative declarations are supposed to have common linkage, not weak.
This change makes clang generate the same thing as llvm-gcc.

llvm-svn: 51674
2008-05-29 11:03:17 +00:00
Eli Friedman 5a6d0ede91 Always use packed structs. This isn't really very nice, but there's
nothing fundamentally wrong with it. Emitting unpacked structs where 
possible is more work for almost no practical benefit.  We'll probably 
want to fix it at some point anyway, but it's low priority.

The issue with long double in particular is that LLVM thinks an X86 long
double is 10 bytes, while clang considers it for all purposes to be
either 12 or 16 bytes, depending on the platform, even in a packed
struct.

llvm-svn: 51673
2008-05-29 10:58:49 +00:00
Devang Patel 1c56ace4df Check first member alignment and uses packed struct if required.
llvm-svn: 51619
2008-05-27 22:45:40 +00:00
Devang Patel d608074e09 Fix test case
llvm-svn: 51618
2008-05-27 22:44:22 +00:00
Eli Friedman 21911e89d5 A few more cases for aggregate values.
llvm-svn: 51596
2008-05-27 15:51:49 +00:00
Eli Friedman 5e2281ede8 Implementation of __builtin_ctlz.
llvm-svn: 51595
2008-05-27 15:32:46 +00:00
Eli Friedman aee9e54dca Don't swap function decls, and add them to the scope as they are
encountered.  Mixing up the decls is unintuitive, and confuses the AST 
destruction code. Fixes PR2360.

Note that there is a need to look up the characteristics and 
declarations of a function associated with a particular name or decl, 
but the original swapping code doesn't solve it properly. 
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html is one 
suggestion for how to fix that.

llvm-svn: 51584
2008-05-27 05:07:37 +00:00
Eli Friedman 078c963a31 Add a more reliable check for whether a static declaration has already
been used.  In preparation for the fix to PR2360, but also a minor bug 
in its own right.

llvm-svn: 51583
2008-05-27 04:58:01 +00:00
Eli Friedman bdef5df44e Generalize the float type generation code, and specifically fix the
codegen of X86 long double.

llvm-svn: 51578
2008-05-27 04:20:05 +00:00
Eli Friedman 43f6b67135 A small testcase; no patch, since it was a bug in a patch I never
committed.

llvm-svn: 51370
2008-05-21 13:21:01 +00:00
Eli Friedman f77daf5e58 Fix test (it was incorrectly succeeding).
llvm-svn: 51310
2008-05-20 09:04:19 +00:00
Eli Friedman 53e38bd6b6 Add codegen support for stack address intrinsics.
llvm-svn: 51309
2008-05-20 08:59:34 +00:00
Eli Friedman 4b0e2a30e0 Implement codegen for comma operator for structs.
llvm-svn: 51304
2008-05-20 07:56:31 +00:00
Eli Friedman a3a4068949 Implement CodeGen for __builtin_memcpy.
llvm-svn: 51282
2008-05-19 23:27:48 +00:00
Eli Friedman 541268086a Remove illegal test.
llvm-svn: 51267
2008-05-19 20:17:34 +00:00
Eli Friedman f23b6fa41f Fix the emission of expressions like char a[10] = "asdf"; previously,
they were causing bad code to be emitted.  There are two fixes here: one 
makes sure we emit a string that is long enough, and one makes sure we 
properly handle string initialization in init lists.

llvm-svn: 51259
2008-05-19 17:51:16 +00:00
Eli Friedman f2442dcc8d Fix support for _Bool bitfields. The issue is that the bitfield width
used for _Bool is not the same as the primitive width (which for _Bool 
is 1 bit).  The load and store changes add some casts to make the 
types consistent.  The EmitLValue changes make sure that the pointer is 
of an appropriate type for loading the bitfield.

This isn't perfect, but it's an improvement, and getting everything 
right depends on actually laying out structs in an ABI-compliant way.

llvm-svn: 51224
2008-05-17 20:03:47 +00:00
Eli Friedman cb92a3f03b Patch for PR2334, and a similar ObjC bug.
llvm-svn: 51193
2008-05-16 17:37:11 +00:00
Eli Friedman a1b4ed8003 Implementation of __builtin_shufflevector, a portable builtin capable of
expressing the full flexibility of the LLVM shufflevector instruction.  
The expected immediate usage is in *mmintrin.h, so that they don't 
depend on the mess of gcc-inherited (and not completely implemented)
shuffle builtins.

llvm-svn: 51113
2008-05-14 19:38:39 +00:00
Eli Friedman 9fd8b68568 Add codegen support for block-level compound literals.
llvm-svn: 51081
2008-05-13 23:18:27 +00:00
Eli Friedman 6a7087e455 Emit basic block for switch body; fixes PR2307.
llvm-svn: 50968
2008-05-12 16:08:04 +00:00
Eli Friedman 6e31321043 Don't try to take the address of a bitfield; fixes PR2310.
llvm-svn: 50966
2008-05-12 15:06:05 +00:00
Mon P Wang b84407d6ec Added support to generate some atomic operators (add, sub, and, or etc..)
llvm-svn: 50919
2008-05-09 22:40:52 +00:00
Devang Patel ac25fc6f2e Begin handling union bitfields.
Note, this is just beginning.

llvm-svn: 50835
2008-05-07 22:28:29 +00:00
Devang Patel 243d5cd283 Fix PR2101 - Codegen crash during bitfield initialization.
llvm-svn: 50769
2008-05-06 19:57:59 +00:00
Chris Lattner 033352b036 add a testcase
llvm-svn: 50608
2008-05-04 00:56:25 +00:00
Chris Lattner 73669defed remove the 'unused static' diagnostic from codegen. This should be
reimplemented in Sema someday.  This is tracked in PR2236.  Until then
disabling it removes some bogus diagnostics (see 2236).

llvm-svn: 50263
2008-04-25 15:47:13 +00:00
Nate Begeman 1c906206b8 Fix PR2236
Add test
Implement feedback from Chris re: PR1998

llvm-svn: 50001
2008-04-20 20:38:08 +00:00
Nate Begeman ce4d7fce6b OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris.
llvm-svn: 49942
2008-04-18 23:10:10 +00:00
Chris Lattner d71f83a8cb this started failing because a GEP was constant folded,
improve the robustness of the test.

llvm-svn: 49618
2008-04-13 19:54:28 +00:00
Chris Lattner aa9c7aed0f Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49369
2008-04-08 04:40:51 +00:00
Chris Lattner 579a05d767 Fix PR2049, updating Eli's patch that fixes to mainline. This produces incorrect
code, but the codegen doesn't crash.  I'll file a bugzilla for the AST being wrong.

llvm-svn: 49226
2008-04-04 18:42:16 +00:00
Chris Lattner f3bc75afcf Since isComplexType() no longer returns true for _Complex integers, the code
generator needs to call isAnyComplexType().  This fixes PR1960.

llvm-svn: 49220
2008-04-04 16:54:41 +00:00
Chris Lattner e799eb5daa Fix PR2081 (problems codegen'ing some recursive structures) patch
by Lauro Venancio!

llvm-svn: 49144
2008-04-03 05:50:42 +00:00
Chris Lattner a21ad8058a Fix several bugs in array -> pointer decomposition.
First, we got several CVR propagation cases wrong, which Eli pointed
out in PR2039.

Second, we didn't propagate address space qualifiers correctly, leading
to incorrect lowering of code in CodeGen/address-space.c.

Third, we didn't uniformly propagate the specifier in the array to the
pointer ("int[restrict 4]" -> "int *restrict").

This adds an ASTContext::getArrayDecayedType member that handles the 
non-trivial logic for this seemingly simple operation.

llvm-svn: 49078
2008-04-02 05:18:44 +00:00
Chris Lattner 0fdc379475 The operand to the visibility attribute is required to be a quoted string, not a bare identifier.
llvm-svn: 47893
2008-03-04 18:08:48 +00:00
Gabor Greif e2e5c3f394 The attribute nothrow maps to llvm attribute nounwind. Fix testcase.
llvm-svn: 47841
2008-03-03 14:53:09 +00:00
Chris Lattner 65079bd9be fix codegen support for functions that are nothrow and noreturn.
llvm-svn: 47838
2008-03-03 03:45:26 +00:00
Chris Lattner 8496639787 Add a bunch of attributes, patch by Nuno Lopes.
llvm-svn: 47837
2008-03-03 03:28:21 +00:00
Lauro Ramos Venancio 01a72ff5d3 Implement codegen for the following static var init.
void g() {
  static char a[10];
  static char *b = a;
}

Now we can compile wget!

llvm-svn: 47627
2008-02-26 21:41:45 +00:00
Lauro Ramos Venancio 8af648ac55 Fix a bug in ConvertAsmString function.
llvm-svn: 47618
2008-02-26 19:19:58 +00:00
Lauro Ramos Venancio c9fbd7301a Convert x86 target specific inline asm constraints to LLVM.
llvm-svn: 47609
2008-02-26 18:33:46 +00:00
Eli Friedman c62dd9d345 Some const initializer tests for stuff I just committed.
llvm-svn: 47442
2008-02-21 18:07:36 +00:00
Chris Lattner 3b418d8446 implement codegen support for sizeof(void), fixing PR2080.
llvm-svn: 47429
2008-02-21 05:45:29 +00:00
Lauro Ramos Venancio e2162c6549 Simplify aggregate initilizer implementation. Use the CodeGenModule::EmitConstantExpr method when
possible.
Fix mediabench/mpeg2/mpeg2dec test.

llvm-svn: 47336
2008-02-19 19:27:31 +00:00
Lauro Ramos Venancio c58fc4052e A global without initializer must be emitted as weak.
Fix Olden/bh test.

llvm-svn: 47292
2008-02-19 00:04:15 +00:00