Commit Graph

248 Commits

Author SHA1 Message Date
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