Commit Graph

609 Commits

Author SHA1 Message Date
Eli Friedman 3253e189c6 PR3248: Make sure the evaluate the operand of a sizeof when it has a VLA type.
Adapted from patch by Tim Northover.

llvm-svn: 69566
2009-04-20 03:21:44 +00:00
Eli Friedman daea3f62b5 Print an error for uses of __thread on targets which don't support it.
llvm-svn: 69553
2009-04-19 21:48:33 +00:00
Eli Friedman 4f856744e5 PR3853: Add CodeGen support for __thread.
llvm-svn: 69545
2009-04-19 21:05:03 +00:00
Chris Lattner c2e868fd14 fix incorrect lowering of __builtin_ia32_shufpd, rdar://6803924
llvm-svn: 69428
2009-04-18 07:01:54 +00:00
Chris Lattner 032f7665d0 rename file.
llvm-svn: 69427
2009-04-18 07:00:54 +00:00
Chris Lattner 85e4dd4055 don't dump .ll file in this dir.
llvm-svn: 69426
2009-04-18 07:00:06 +00:00
Daniel Dunbar c3e7cff6d3 Attributes on block functions were not being set.
- <rdar://problem/6800351> clang not producing correct large struct
   return code for Blocks

llvm-svn: 69337
2009-04-17 00:48:04 +00:00
Daniel Dunbar 426b5cf16a Ensure that the most recent declaration of a tentative definition wins
when generating a common definition.

llvm-svn: 69287
2009-04-16 15:34:14 +00:00
Daniel Dunbar 7dd749e6fd Defer generation of tentative definitions.
- PR3980.

 - <rdar://problem/6762287> [irgen] crash when generating tentative
   definition of incomplete structure

 - This also avoids creating common definitions for things which are
   later overwritten.

 - XFAIL'ed external-defs.c, it isn't completing types properly yet.

llvm-svn: 69231
2009-04-15 22:08:45 +00:00
Devang Patel 9074ed8c6a Set DebugInfo at the beginning of GenerateBlockFunction().
llvm-svn: 69228
2009-04-15 21:51:44 +00:00
Chris Lattner e94e13ca35 remove #include of system header, making this a) not apple specific, and
b) test dramatically faster.

llvm-svn: 69135
2009-04-15 04:26:10 +00:00
Chris Lattner bae0e68930 Fix PR3988: extern inline functions get strong symbol definitions in
C99 mode.  This is a regression from an earlier patch of mine.

This also simplifies the linkage enums a bit.

llvm-svn: 69069
2009-04-14 20:25:53 +00:00
Chris Lattner 02e987f3e8 implement codegen support for __attribute((__gnuc_inline__)),
pulling some attribute munging stuff into GetLinkageForFunction.

This should fix PR3986

llvm-svn: 69045
2009-04-14 16:44:36 +00:00
Chris Lattner 92028dad66 defer emission of always_inline, extern_inline, and inline functions (when
not in c89 mode).

llvm-svn: 69032
2009-04-14 06:44:48 +00:00
Chris Lattner 256c9507c8 set the linkage of an inline function according to its language rules.
llvm-svn: 69030
2009-04-14 06:27:57 +00:00
Steve Naroff e4e55d2706 Fix crasher in ASTContext::getObjCEncodingForMethodDecl().
This was exposed as a result of something else that was recently fixed.

llvm-svn: 69004
2009-04-14 00:03:58 +00:00
Steve Naroff 84073ec51f Fixed crasher in <rdar://problem/6780904> [irgen] Assertion failed: (Result == conversionOK && "UTF-8 to UTF-16 conversion failed"), function GetAddrOfConstantCFString, file CodeGenModule.cpp, line 1063.
Still a diagnostic related FIXME (will discuss with Daniel/Fariborz offline).

llvm-svn: 68975
2009-04-13 19:08:08 +00:00
Chris Lattner 03a6cbbd91 pass -fblocks
llvm-svn: 68878
2009-04-11 19:49:49 +00:00
Fariborz Jahanian aae4349df9 Fixes a ir-gen crash for K&R style blocks.
llvm-svn: 68865
2009-04-11 17:55:15 +00:00
Daniel Dunbar 8c920c9220 Don't set both readnone and readonly.
llvm-svn: 68833
2009-04-10 22:14:52 +00:00
Daniel Dunbar d272cca527 Internal variables could mistakenly have "hidden" visibility when
their emission was deferred.
 - <rdar://problem/6775234> variables with internal linkage should not
   be exposed with -fvisibility=hidden.

llvm-svn: 68818
2009-04-10 20:26:50 +00:00
Mike Stump 6764593098 Fixup codegen for nested blocks that use copy/dispose in the inner
blocks, so that the outer blocks use it as well.  Radar 6762279

llvm-svn: 68811
2009-04-10 18:52:28 +00:00
Daniel Dunbar b041085c17 Add more builtin definitions, including strcmp.
- PR3964.

llvm-svn: 68710
2009-04-09 16:42:50 +00:00
Anders Carlsson a60cbcdfe6 Don't assume that a block always has a FunctionProtoType. Fixes rdar://6768379.
llvm-svn: 68583
2009-04-08 02:55:55 +00:00
Daniel Dunbar ea10ab668f Visibility attributes should only be set on definition.
llvm-svn: 68561
2009-04-07 22:36:33 +00:00
Eli Friedman 574c745370 Diagnose uses of function specifiers on declarations which don't declare
functions.  Fixes PR3941.

llvm-svn: 68541
2009-04-07 19:37:57 +00:00
Daniel Dunbar 4fab57ddea Implement __sync_{add,sub,and,or,xor}_and_fetch and
__sync_bool_compare_and_swap.
 - <rdar://problem/6762223> [sema/irgen] support
   __sync_bool_compare_and_swap and __sync_add_and_fetch

llvm-svn: 68482
2009-04-07 00:55:51 +00:00
Anton Korobeynikov 18e831dcc9 Testcase for regparm codegen
llvm-svn: 68415
2009-04-04 00:49:38 +00:00
Anders Carlsson 16b1461c21 Ignore plus operands when looking up the operand number from a named operand. This matches llvm-gcc and fixes PR3908.
llvm-svn: 68371
2009-04-03 05:57:08 +00:00
Fariborz Jahanian befc9dfbff Implement -fvisibility.
llvm-svn: 68369
2009-04-03 03:28:57 +00:00
Daniel Dunbar fd6cfcffa2 Add target hook for setting symbol prefix and section of unicode
string literals.

llvm-svn: 68363
2009-04-03 00:57:44 +00:00
Mike Stump d3e3885f2d Remove -ftrapu.
llvm-svn: 68330
2009-04-02 18:15:54 +00:00
Mike Stump 36c36ebc8b Oops, almost forgot the testcases.
llvm-svn: 68270
2009-04-02 01:14:26 +00:00
Daniel Dunbar e80bd1897c x86-32 Darwin ABI: Handle small structures correctly.
- Small structures are returned in a register if: 
    1. They fit nicely in a  register.
    2. All fields fit nicely in a register.
   (more or less)

 - We now pass the first 5000 ABITests if unions are disabled.

 - <rdar://problem/6497882> [irgen] x86-32 ABI compatibility with
   small structs

llvm-svn: 68197
2009-04-01 07:45:00 +00:00
Daniel Dunbar 58e2971bb0 x86-32 Darwin ABI: Single element arrays can be part of "single
element structures", which have different ABI rules.
 - Current return-arguments-32 status is: 1 out of 1000 failures (-7)

 - Also, vectors inside "single element structs" require special
   handling.

llvm-svn: 68196
2009-04-01 07:08:38 +00:00
Daniel Dunbar cd76e673eb x86-32 Darwin ABI: Handle direct return of vectors.
- Current return-arguments-32 status is: 8 out of 1000 failures (-7)

llvm-svn: 68192
2009-04-01 06:13:08 +00:00
Daniel Dunbar f77e292a0f Fix a subtle bug where the cleanup scope entries had a dangling block reference
- <rdar://problem/6732143> Crash when generating @synchronize for
   zero-cost exception

 - Thanks to Anders for helping track down the problem.

llvm-svn: 68186
2009-04-01 04:37:47 +00:00
Eli Friedman 1c3fb22cad Fix pascal string support; testcase from mailing list message.
llvm-svn: 68181
2009-04-01 03:17:08 +00:00
Daniel Dunbar 08b216abf1 Add Target hooks for IRgen of [cf]string literals.
- Notably, set section on cfstring literal string data (for now, this
   is done everywhere because it matches what we were already doing
   for the CFString data itself)

 - <rdar://problem/6599098> [irgen] linker requires objc string data
   to go into cstring

llvm-svn: 68160
2009-03-31 23:42:16 +00:00
Chris Lattner f41e87f4cd Change UsedArray to be a vector of WeakVH to fix a dangling pointer problem that occurs when
attribute(used) and asm renaming are used together.

llvm-svn: 68155
2009-03-31 22:37:52 +00:00
Daniel Dunbar 35579146aa x86_32 Darwin ABI: Treat empty unions like empty structures.
- Current return-arguments-32 status: 15/1000 failures

llvm-svn: 68132
2009-03-31 19:01:39 +00:00
Chris Lattner 5d68896c7b Codegen sometimes crashes on comparisons that aren't legal, just
disable this feature for now, to err on the side of rejecting instead
of sometimes crashing.  rdar://6326239

llvm-svn: 68088
2009-03-31 07:46:52 +00:00
Eli Friedman 09a9b6e335 Move where block-related variables are initialized so that block
types don't get generated when blocks aren't used.

llvm-svn: 67898
2009-03-28 03:24:54 +00:00
Eli Friedman 7c7a0e86ae Fix silly mistake in test.
llvm-svn: 67897
2009-03-28 03:14:28 +00:00
Eli Friedman e381f7e3e9 Misc small fixes/cleanups/comment changes.
llvm-svn: 67895
2009-03-28 02:45:41 +00:00
Eli Friedman 8b7b1b1aee Change compound assignment operators to keep track of both the promoted
LHS type and the computation result type; this encodes information into 
the AST which is otherwise non-obvious.  Fix Sema to always come up with the 
right answer for both of these types.  Fix IRGen and the analyzer to 
account for these changes.  This fixes PR2601.  The approach is inspired 
by PR2601 comment 2.

Note that this changes real *= complex in CodeGen from a silent 
miscompilation to an explicit error.

I'm not really sure that the analyzer changes are correct, or how to 
test them... someone more familiar with the analyzer should check those 
changes.

llvm-svn: 67889
2009-03-28 01:22:36 +00:00
Douglas Gregor 8aa6bf5b8e Fix <rdar://problem/6724396>, where we were silently dropping
GNU-style array designators, causing us to emit broken initializers.

llvm-svn: 67878
2009-03-27 23:40:29 +00:00
Daniel Dunbar adf511c056 Driver: Forward -fno-common to clang.
- <rdar://problem/6710978> ccc/clang-driver ignore -fno-common

llvm-svn: 67762
2009-03-26 16:37:00 +00:00
Eli Friedman 8d7ff4098c Fix for PR3869: actually enforce that the argument of an indirect goto
is of type void*.  I'll try to add the appropriate checking later.

llvm-svn: 67721
2009-03-26 00:18:06 +00:00
Mike Stump 871c1f6f88 Remove -f__block as codegen for __block variables should be solid.
llvm-svn: 67697
2009-03-25 18:05:39 +00:00
Mike Stump d2142cffbf Fixup codegen for block literals that bleed copy/dispose information
from previous block literals.

llvm-svn: 67696
2009-03-25 17:58:24 +00:00
Daniel Dunbar bf1fe8c36c Support member reference on ?: of struct type.
llvm-svn: 67603
2009-03-24 02:38:23 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Daniel Dunbar 4aacad1f93 Use not instead of ! in tests.
llvm-svn: 67601
2009-03-24 01:59:55 +00:00
Eli Friedman 703a77f313 Fix a couple of tests.
llvm-svn: 67592
2009-03-24 01:11:18 +00:00
Eli Friedman 7b4716750b Fix a subtle bug in CodeGen for the increment of a bitfield.
llvm-svn: 67499
2009-03-23 03:00:06 +00:00
Chris Lattner e64911a4ae switch getBuiltinLibFunction to use the new GetOrCreateLLVMFunction
functionality, fixing a crash on the attached testcase.  Eliminate the
BuiltinFunctions cache, as it can contain dangling pointers.  This fixes
a bunch of valgrind errors on test/CodeGen/builtins.c

llvm-svn: 67484
2009-03-22 21:56:56 +00:00
Chris Lattner 827a3552a4 make alias definition logic more similar to functions/globals.
llvm-svn: 67481
2009-03-22 21:39:12 +00:00
Chris Lattner a5ae54acc4 fix PR3200 by making alias emission use the new infrastructure. Fold
some tests into the alias.c file.

llvm-svn: 67479
2009-03-22 21:21:57 +00:00
Chris Lattner 75acb0c356 fix a fixme: non-proto struct returning function definitions should be compiled
to something like:
define void @bar(%struct.foo* noalias sret %agg.result) nounwind {
instead of:
define void @bar(%struct.foo* noalias sret %agg.result, ...) nounwind {

llvm-svn: 67475
2009-03-22 19:35:37 +00:00
Mike Stump efd7caa825 Fixup codegen for nested block literals so that we generate
copy_helpers and dispose_helpers as necessary for them.

llvm-svn: 67453
2009-03-21 21:00:35 +00:00
Chris Lattner a85d68e5d8 fix a crash that could occur when a variable declaration became a
function definition.

llvm-svn: 67446
2009-03-21 09:25:43 +00:00
Chris Lattner 149927c9f8 simplify and cleanup global variable creation stuff to all go through one
code path.

llvm-svn: 67445
2009-03-21 09:16:30 +00:00
Chris Lattner 6574906818 fix several problems with asm renaming, by pulling it into the mangling code:
1. it wasn't applying to definitions, only declarations, e.g. int x __asm("foo")
2. multiple definitions were conflicting, they weren't getting merged.
3. the code was duplicated in several places.

llvm-svn: 67442
2009-03-21 08:24:40 +00:00
Douglas Gregor 07d8e3a500 Allow flexible array initializers that are not surrounded by
braces. We now build the appropriate fully-structured initializer list
for such things. Per PR3618, verified that we're getting the right
code generation.

llvm-svn: 67353
2009-03-20 00:32:56 +00:00
Daniel Dunbar 4e004ed124 IRgen support for alias of global variable.
- PR3818.

llvm-svn: 67297
2009-03-19 08:27:24 +00:00
Daniel Dunbar c230443178 PR3835: Interaction with ABI structure passing can inhibit
readnone/readonly attributes.

llvm-svn: 67224
2009-03-18 19:51:01 +00:00
Chris Lattner ab17fb2c98 fix the more complex cases by actually codegen'ing the right expr :)
llvm-svn: 67219
2009-03-18 18:30:44 +00:00
Chris Lattner 28bcf1a429 add codegen support for casting an element to a union.
There are some more complex cases (_Complex and structs)
that I'm still working on.

llvm-svn: 67218
2009-03-18 18:28:57 +00:00
Mike Stump bc7d67ce08 Add codegen support for aggregate BlockDeclRefExprs.
llvm-svn: 67207
2009-03-18 15:54:29 +00:00
Chris Lattner c2a0b97950 fix PR3809, codegen for inc/dec of function pointers.
llvm-svn: 67165
2009-03-18 04:25:13 +00:00
Chris Lattner 63d06ab65a teach codegen to handle noop casts as lvalues.
llvm-svn: 67164
2009-03-18 04:02:57 +00:00
Anders Carlsson fe2e680509 Fix failing test case.
llvm-svn: 67147
2009-03-18 01:10:22 +00:00
Anders Carlsson e73e3ecc04 Initialize the cleanup.dst variable if necessary. Fixes PR3789.
llvm-svn: 67075
2009-03-17 05:53:35 +00:00
Anders Carlsson e8911a9a13 We want to grep the output, not the input :-)
llvm-svn: 67074
2009-03-17 05:49:13 +00:00
Mike Stump 5469f29aa9 Do up codegen for function static data and externs in functions in block
literals.

llvm-svn: 66984
2009-03-13 23:34:28 +00:00
Daniel Dunbar 8ce48d8c10 x86_32 ABI: Don't try and expand structures with bitfields.
- This is an ABI incompatiblity, but this is not likely to be a huge
   deal in practice. For now we at least generate self consistent code
   instead of crashing.
 - <rdar://problem/6657601> x86-32 ABI: Bitfields in small structures
   are not passed correctly

llvm-svn: 66713
2009-03-11 22:05:26 +00:00
Chris Lattner f85a938985 Fix PR3682 by just disabling a broken assertion. This check should be
done in sema, and is reflected by the existing PR3258.  In the meantime,
fix PR3682 by disabling a bogus assertion (which doesn't account for + 
operands).

llvm-svn: 66533
2009-03-10 06:42:37 +00:00
Chris Lattner 6dd0f9263d reduce duplication of parsing code between %0 and %x0 and
add support for modifiers on named references, like %c[foo].

llvm-svn: 66532
2009-03-10 06:38:02 +00:00
Chris Lattner d7d5fdf090 move matching of named operands into AsmStmt class. At the same
time handle + operands in operand counting, fixing asm.c:t7 to
expand into $2 instead of $1.

llvm-svn: 66531
2009-03-10 06:33:24 +00:00
Mike Stump 6f7d9f8774 codegen support for dispose helpers for block literals.
llvm-svn: 66320
2009-03-07 02:53:18 +00:00
Mike Stump aeb0ffd56c Codegen support for copy helpers for block literals.
llvm-svn: 66319
2009-03-07 02:35:30 +00:00
Daniel Dunbar 94911a91d5 x86_64 ABI: Handle long double in union when upper eightbyte results
in a lone X87 class.
 - PR3735.

llvm-svn: 66277
2009-03-06 17:50:25 +00:00
Daniel Dunbar 8e79b8491f IRgen support for weak_import.
- <rdar://problem/6652110> clang should support weak_import

llvm-svn: 66270
2009-03-06 16:20:49 +00:00
Mike Stump cfc045e36c Testcase for last fix.
llvm-svn: 66258
2009-03-06 06:35:21 +00:00
Mike Stump fbe25dd1e4 Finish off __Block_byref_id_object_dispose codegen for block literals.
llvm-svn: 66247
2009-03-06 04:53:30 +00:00
Mike Stump ee2a5ee5f7 More codegen support for the copy/dispose helpers for block literals.
llvm-svn: 66241
2009-03-06 02:29:21 +00:00
Mike Stump 0c74327715 Framework for codegen for copy/dispose helpers.
llvm-svn: 66231
2009-03-06 01:33:24 +00:00
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