Commit Graph

4619 Commits

Author SHA1 Message Date
Ted Kremenek 582a0999fb Null initialize a few variables flagged by
clang's -Wuninitialized-experimental warning.
While these don't look like real bugs, clang's
-Wuninitialized-experimental analysis is stricter
than GCC's, and these fixes have the benefit
of being general nice cleanups.

llvm-svn: 124072
2011-01-23 17:04:59 +00:00
Benjamin Kramer 1e1888979b Use a FunctionType::get overload that doesn't require an empty vector.
llvm-svn: 124029
2011-01-22 12:15:57 +00:00
Douglas Gregor 9c399a29fd Send code generation for xvalues down the same path as lvalues
llvm-svn: 124023
2011-01-22 02:44:21 +00:00
Douglas Gregor b8c7fe9dc9 Debug info generation for rvalue references
llvm-svn: 124020
2011-01-22 01:58:15 +00:00
Fariborz Jahanian 252a47f635 Move cheking of kext into canDevirtualizeMemberFunctionCalls().
Improve on test case. Per Doug's comment. wip.

llvm-svn: 123954
2011-01-21 01:04:41 +00:00
Fariborz Jahanian 47609b088c apple kext abi requires all vf calls, including qualified
vf calls, be made indirect. This patch is towards that goal.

llvm-svn: 123922
2011-01-20 17:19:02 +00:00
Ken Dyck 7d381c48fe Add CharUnits::RoundUpToAlignment() to simplify rounding in character units.
llvm-svn: 123868
2011-01-20 01:59:55 +00:00
John McCall 424cec97bd Change QualType::getTypePtr() to return a const pointer, then change a
thousand other things which were (generally inadvertantly) relying on that.

llvm-svn: 123814
2011-01-19 06:33:43 +00:00
Ken Dyck 705ba07ef0 Replace calls to getTypeSize() and getTypeAlign() with their 'InChars'
counterparts where char units are needed.

llvm-svn: 123805
2011-01-19 01:58:38 +00:00
Devang Patel d2d6665c71 Emit DW_TAG_lexical_scope to surround foreach.
llvm-svn: 123802
2011-01-19 01:36:36 +00:00
NAKAMURA Takumi e03c603624 lib/CodeGen/TargetInfo.cpp: Fix coding style and erase an obsolete comment.
llvm-svn: 123790
2011-01-19 00:11:33 +00:00
Rafael Espindola d661a853fd Add unnamed_addr in CreateRuntimeVariable.
llvm-svn: 123773
2011-01-18 21:07:57 +00:00
Francois Pichet 6422579411 Add support for explicit constructor calls in Microsoft mode.
For example: 

class A{ 
public:
  A& operator=(const A& that) {
      if (this != &that) {
          this->A::~A();
          this->A::A(that);  // <=== explicit constructor call.
      }
      return *this;
  }
};

More work will be needed to support an explicit call to a template constructor.

llvm-svn: 123735
2011-01-18 05:04:39 +00:00
Ken Dyck 9a6486934c Replace calls to CharUnits::fromQuantity() with ones to
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units.

llvm-svn: 123720
2011-01-18 02:01:14 +00:00
Jeffrey Yasskin 8dfa5f1776 Fix warnings found by gcc-4.6, from -Wunused-but-set-variable and
-Wint-to-pointer-cast.

llvm-svn: 123719
2011-01-18 02:00:16 +00:00
NAKAMURA Takumi bd91f50190 lib/CodeGen/TargetInfo.cpp: Add Win64 calling conversion.
FIXME: It would be incompatible to Microsoft's in one point.
On mingw64-gcc, {i128} is expanded for args and returned as {rax, rdx}.

llvm-svn: 123692
2011-01-17 22:56:31 +00:00
Devang Patel 283e89dd22 Simplify.
llvm-svn: 123682
2011-01-17 22:23:07 +00:00
Rafael Espindola 2e217d6555 More unnamed_addr.
llvm-svn: 123681
2011-01-17 22:22:52 +00:00
Rafael Espindola de089d462c merge strings created by
const NSConstantString *appKey =  @"MyApp";

llvm-svn: 123680
2011-01-17 22:11:21 +00:00
Rafael Espindola e79d43da3b Add unnamed_addr to the special strings created by
__builtin___CFStringMakeConstantString
This fixes PR8993. A darwin expert might want to check that this is safe.

llvm-svn: 123658
2011-01-17 16:31:00 +00:00
Rafael Espindola facb7d0ade Also set unnamed_addr on declarations.
llvm-svn: 123531
2011-01-15 08:23:14 +00:00
John McCall a08ffd22d5 Support the zero-initialization of VLAs when that really means a zero
bit-pattern.  Continue punting on zero-initializing VLAs with a nonzero
pattern.

llvm-svn: 123439
2011-01-14 10:37:58 +00:00
John McCall 5461a7523f When simplifying a cleanup's entry by merging it into a single predecessor,
replace all uses of the entry with the predecessor.  There are no cleanups
relying on this right now, but if we ever want a cleanup with a phi inside
it, this will be important.

llvm-svn: 123438
2011-01-14 10:35:38 +00:00
Fariborz Jahanian f59e80e0ed Save getObjCGCAttrKind and use it in two places
for efficiancy (still part of //rdar://8761767).
Per John's comment.

llvm-svn: 123401
2011-01-13 21:35:27 +00:00
Fariborz Jahanian d133979628 Generate write-barriers for global objc
assigns. // rdar://8761767 

llvm-svn: 123391
2011-01-13 20:00:54 +00:00
Peter Collingbourne 0ff0b37627 Move name mangling support from CodeGen to AST. In the
process, perform a number of refactorings:

- Move MiscNameMangler member functions to MangleContext
- Remove GlobalDecl dependency from MangleContext
- Make MangleContext abstract and move Itanium/Microsoft functionality
  to their own classes/files
- Implement ASTContext::createMangleContext and have CodeGen use it

No (intended) functionality change.

llvm-svn: 123386
2011-01-13 18:57:25 +00:00
Douglas Gregor b720ff2f62 When your comments and your code are out-of-sync, the test case is wrong.
llvm-svn: 123379
2011-01-13 17:44:36 +00:00
Douglas Gregor d81c7c1659 Add tests for name mangling of variadic templates.
llvm-svn: 123378
2011-01-13 16:39:34 +00:00
John McCall 294c2db42b Ensure an insertion point at the end of a statement-expression.
Fixes PR8967.

llvm-svn: 123360
2011-01-13 02:03:06 +00:00
Rafael Espindola d09776b945 Only add unnamed_addr to definitions.
llvm-svn: 123354
2011-01-13 01:12:55 +00:00
Douglas Gregor be7b54889f Add IR generation support for SizeOfPackExpr.
llvm-svn: 123332
2011-01-12 22:11:34 +00:00
John McCall 20f6ab828a Fix a latent bug where, after emitting an expression statement, we would
delete the block we began emitting into if it had no predecessors.  We never
want to do this, because there are several valid cases during statement
emission where an existing block has no known predecessors but will acquire
some later.  The case in my test case doesn't inherently fall into this 
category, because we could safely emit the case-range code before the statement
body, but there are examples with labels that can't be fallen into 
that would also demonstrate this bug.

rdar://problem/8837067

llvm-svn: 123303
2011-01-12 03:41:02 +00:00
Rafael Espindola 25f4620c67 Set unnamed_addr in every type info.
llvm-svn: 123293
2011-01-11 23:55:05 +00:00
Rafael Espindola bb7f7686c5 Set unnamed_addr in VTTs.
llvm-svn: 123280
2011-01-11 22:29:55 +00:00
Rafael Espindola b1e879c80f Set unnamed_addr for type infos that we are confortable marking as hidden. I
think it is safe to mark all type infos with unnamed_addr, but I am not sure.

llvm-svn: 123275
2011-01-11 21:44:37 +00:00
Rafael Espindola 5674c644cf Add unnamed_addr to vtables.
llvm-svn: 123272
2011-01-11 21:10:26 +00:00
Bob Wilson b9fa00e0c2 Remove special handling for opaque Neon vector types.
Clang does not wrap the vectors in structs anymore so this isn't needed.

llvm-svn: 123241
2011-01-11 16:53:49 +00:00
Devang Patel bc47498973 Fix debug info for __block variable referenced outside of block.
llvm-svn: 123199
2011-01-11 00:30:27 +00:00
Rafael Espindola 0ee986c1f1 Add unnamed_addr to constructors and destructors.
llvm-svn: 123197
2011-01-11 00:26:26 +00:00
Bob Wilson bd4520b535 Move DefaultABIInfo::classifyReturnType where it belongs. No functional change.
llvm-svn: 123195
2011-01-10 23:54:17 +00:00
Rafael Espindola b7f60e3474 Add unnamed_addr when creating artificial string globals. For example, in
static const char foo[] = "foo";
static const char *bar = "bar";

the global created to hold "bar" will have it, but foo will not.

llvm-svn: 123192
2011-01-10 22:34:03 +00:00
Benjamin Kramer 39f987ffd0 Make a helper function static.
llvm-svn: 123118
2011-01-09 13:21:33 +00:00
Alexis Hunt 1d7926502f Renamed CXXBaseOrMemberInitializer to CXXCtorInitializer. This is both shorter,
more accurate, and makes it make sense for it to hold a delegating constructor
call.

llvm-svn: 123084
2011-01-08 20:30:50 +00:00
John McCall 1c926b78fe Rework a few things about how we emit ObjC's for enumeration statement.
In particular, the iteration variable (if present) should be created and
destroyed in a narrow span around the loop body, and the body should
be emitted in a cleanup scope in case it's not a compound statement.
Otherwise, rename a few variables and use phis instead of temporary
variables for the index and buffer count.

llvm-svn: 122988
2011-01-07 01:49:06 +00:00
John McCall 8190451ddc Introduce an AttributedType, but don't actually use it anywhere yet.
The initial TreeTransform is a cop-out, but it's more-or-less equivalent
to what we were doing before, or rather what we're doing now and might
eventually stop doing in favor of using this type.
I am simultaneously intrigued by the possibilities of rebuilding a
dependent Attri

llvm-svn: 122942
2011-01-06 01:58:22 +00:00
Douglas Gregor e4ff4b56fe Replace the representation of template template argument pack
expansions with something that is easier to use correctly: a new
template argment kind, rather than a bit on an existing kind. Update
all of the switch statements that deal with template arguments, fixing
a few latent bugs in the process. I"m happy with this representation,
now.

And, oh look! Template instantiation and deduction work for template
template argument pack expansions.

llvm-svn: 122896
2011-01-05 18:58:31 +00:00
Chris Lattner 63c41a2458 fix a -Wself-assign warning
llvm-svn: 122894
2011-01-05 18:41:53 +00:00
John McCall 3882ace207 Refactor the application of type attributes so that attributes from
the declaration-specifiers and on the declarator itself are moved
to the appropriate declarator chunk.  This permits a greatly
simplified model for how to apply these attributes, as well as
allowing a much more efficient query for the GC attribute.
Now all qualifier queries follow the same basic strategy of
"local qualifiers, local qualifiers on the canonical type,
then look through arrays".  This can be easily optimized by
changing the canonical qualified-array-type representation.

Do not process type attributes as decl attributes on declarations
with declarators.

When computing the type of a block, synthesize a prototype
function declarator chunk if the decl-spec type was not a
function.  This simplifies the logic for building block signatures.

Change the logic which inserts an objc_read_weak on a block
literal to only fire if the block has a __weak __block variable,
rather than if the return type of the block is __weak qualified,
which is not actually a sensible thing to ask.

llvm-svn: 122871
2011-01-05 12:14:39 +00:00
Douglas Gregor be63bbfd24 Implement name mangling for sizeof...(pack), to silence the last of
the switch-enum warnings. Test is forthcoming, once I've dealt with
some template argument deduction issues.

llvm-svn: 122820
2011-01-04 18:56:13 +00:00
Douglas Gregor 752a595655 Implement pack expansions whose pattern is a base-specifier.
llvm-svn: 122782
2011-01-03 22:36:02 +00:00
Fariborz Jahanian 9a7d57d57f Consider zero-length array of structs when
computing ivar layouts for objc-gc.
Fixes // rdar://8800513

llvm-svn: 122762
2011-01-03 19:23:18 +00:00
Douglas Gregor e8e9dd624c Implement support for pack expansions whose pattern is a non-type
template argument (described by an expression, of course). For
example:

  template<int...> struct int_tuple { };

  template<int ...Values>
  struct square {
    typedef int_tuple<(Values*Values)...> type;
  };

It also lays the foundation for pack expansions in an initializer-list.
  

llvm-svn: 122751
2011-01-03 17:17:50 +00:00
Rafael Espindola 47731fe3f1 Add support for passing variables declared to use a xmm register to asm
statements using the "x" constraint.

llvm-svn: 122679
2011-01-02 03:59:13 +00:00
Rafael Espindola 478abcab3d Produce a better error message for invalid register names.
llvm-svn: 122670
2011-01-01 21:47:03 +00:00
Rafael Espindola 5734edc109 Fix typo and add comment.
llvm-svn: 122669
2011-01-01 21:12:33 +00:00
Rafael Espindola c56f847a96 Add support for declaring register contraints in variables. They are only used
in asm statements:

register int foo asm("rdi");

asm("..." : ... "r" (foo) ...

We also only accept these variables if the constraint in the asm statement is "r".

This fixes most of PR3933.

llvm-svn: 122643
2010-12-30 22:59:32 +00:00
Nick Lewycky 8a7d90b152 Correct function name in comment.
llvm-svn: 122640
2010-12-30 20:21:55 +00:00
Benjamin Kramer acc6b4e2fd Simplify mem{cpy, move, set} creation with IRBuilder.
llvm-svn: 122634
2010-12-30 00:13:21 +00:00
David Chisnall 168b80f2c0 Add support for GNU runtime property set / get structure functions. Minor refactoring of Mac runtime (returns the same function for both, as the Mac runtimes currently only provide a single entry point for setting and getting struct properties, although this will presumably be fixed at some point).
llvm-svn: 122569
2010-12-26 22:13:16 +00:00
Chris Lattner ad3467ee89 The -fshort-wchar option causes wchar_t to become unsigned, in addition to being
16-bits in size.  Implement this by splitting WChar into two enums, like we have
for char.  This fixes a miscompmilation of XULRunner, PR8856.

llvm-svn: 122558
2010-12-25 23:25:43 +00:00
Douglas Gregor d2fa766ad0 Introduce a new type, PackExpansionType, to capture types that are
pack expansions, e.g. given

  template<typename... Types> struct tuple;

  template<typename... Types>
  struct tuple_of_refs {
    typedef tuple<Types&...> types;
  };

the type of the "types" typedef is a PackExpansionType whose pattern
is Types&. 

This commit introduces support for creating pack expansions for
template type arguments, as above, but not for any other kind of pack
expansion, nor for any form of instantiation.

llvm-svn: 122223
2010-12-20 02:24:11 +00:00
Wesley Peck 36a1f68fec 1. Add some ABI information for the Microblaze.
2. Add attibutes "interrupt_handler" and "save_volatiles" for the Microblaze target.

llvm-svn: 122184
2010-12-19 19:57:51 +00:00
John McCall 09982c0a49 Give hidden visibility to RTTI for derived types. This is kindof a hacky
way to do this, but it fixes rdar://problem/8778973

llvm-svn: 122033
2010-12-17 02:58:03 +00:00
Bob Wilson 63fbbc6ef8 Implement builtins for Neon half-precision float conversions.
Also tweak the VCVT_F32_F16 entry in arm_neon.td to be more consistent with
the other floating-point conversion builtins.  Radar 8068427.

llvm-svn: 121916
2010-12-15 23:36:44 +00:00
John McCall 357d0f3caf Set the "implicitly inline" bit on a method as soon as we see a definition
within the class.  Teach IR gen to look for function definitions in record
lexical contexts when deciding whether to emit a function whose address    
was taken.  Fixes PR8789.

llvm-svn: 121833
2010-12-15 04:00:32 +00:00
John McCall db40c7f573 Restore r121752 without modification.
llvm-svn: 121763
2010-12-14 08:05:40 +00:00
John McCall 5546da68bb Pull out r121752 in case it's causing the selfhost breakage.
llvm-svn: 121759
2010-12-14 07:30:51 +00:00
John McCall aa6d98c160 Factor out most of the extra state in a FunctionProtoType into a separate
class to be passed around.  The line between argument and return types and
everything else is kindof vague, but I think it's justifiable.

llvm-svn: 121752
2010-12-14 06:51:39 +00:00
Dan Gohman c2897692c3 Implement CodeGen support for the may_alias attribute.
llvm-svn: 121734
2010-12-13 23:51:08 +00:00
Bob Wilson 546b691c73 Add missing switch case for the quad-register version of the Neon vmul builtin.
llvm-svn: 121595
2010-12-10 23:09:09 +00:00
Bob Wilson 0348af667a Fix clang crashes on Neon vld[234]_dup intrinsics with 64-bit element types.
The 64-bit element vectors need to be handled as a special case.

llvm-svn: 121592
2010-12-10 22:54:58 +00:00
Abramo Bagnara 924a8f3573 Added ParenType type node.
llvm-svn: 121488
2010-12-10 16:29:40 +00:00
John McCall 717d9b0e2f It's kindof silly that ExtQuals has an ASTContext&, and we can use that
space better.  Remove this reference.  To make that work, change some APIs
(most importantly, getDesugaredType()) to take an ASTContext& if they
need to return a QualType.  Simultaneously, diminish the need to return a
QualType by introducing some useful APIs on SplitQualType, which is
just a std::pair<const Type *, Qualifiers>.

llvm-svn: 121478
2010-12-10 11:01:00 +00:00
Bob Wilson 4c4a00a10b Add missing switch case to handle builtin for Neon vqnegq.
llvm-svn: 121468
2010-12-10 06:26:19 +00:00
Bob Wilson d1767c5c15 LLVM's intrinsics for vpaddl and vpadal have 2 overloaded types.
Clang was only specifying the overloaded result type.  PR8483.

llvm-svn: 121464
2010-12-10 05:51:07 +00:00
Bob Wilson 571c907cdf Neon compare absolute LLVM intrinsics are not overloaded. PR8484.
llvm-svn: 121447
2010-12-10 01:11:38 +00:00
Argyrios Kyrtzidis 648fcbef5b Fix another obscure corner layout case.
llvm-svn: 121436
2010-12-10 00:11:00 +00:00
Devang Patel 8c44529c85 Remove unused parameter. getContextDescriptor() and getOrCreateNameSpace().
llvm-svn: 121333
2010-12-09 00:33:05 +00:00
Devang Patel 4591f7736a Remove unused parameter.
llvm-svn: 121326
2010-12-09 00:25:29 +00:00
Devang Patel 00afcbe366 Start using DIBuilder. It provides cleaner interface.
llvm-svn: 121302
2010-12-08 22:42:58 +00:00
Bob Wilson 482afae812 Stop using builtins for the "_lane" variants of saturating multiply intrinsics.
Remove the "splat" parameter from the EmitNeonCall function, since it is no
longer needed.

llvm-svn: 121300
2010-12-08 22:37:56 +00:00
Francois Pichet 34b2113250 Remove the TypesCompatibleExprClass AST node. Merge its functionality into BinaryTypeTraitExpr.
llvm-svn: 121298
2010-12-08 22:35:30 +00:00
Bob Wilson b038120094 Stop using clang builtins for Neon vabdl and vabal intrinsics.
llvm-svn: 121288
2010-12-08 21:39:47 +00:00
Bob Wilson 7d66df9c33 Stop using clang builtins for Neon vaba intrinsics.
llvm-svn: 121277
2010-12-08 20:09:54 +00:00
Chandler Carruth 8005adf031 Silence an unused variable warning.
llvm-svn: 121221
2010-12-08 01:29:17 +00:00
Bob Wilson 8811c3a72e Stop using clang builtins for Neon vadd[lw] and vsub[lw] intrinsics.
llvm-svn: 121214
2010-12-08 00:14:43 +00:00
Bob Wilson f81b09db68 Stop using clang builtins for Neon vmlal{_n,_lane} and vmlsl{_n,_lane}.
llvm-svn: 121210
2010-12-07 23:54:55 +00:00
Bob Wilson 210f6ddecc Stop using a clang builtin for Neon vdup_lane intrinsics.
llvm-svn: 121191
2010-12-07 22:40:02 +00:00
Bob Wilson 7f3c0aa96f Stop using a clang builtin for Neon vmull_lane intrinsic.
llvm-svn: 121189
2010-12-07 22:03:46 +00:00
Bob Wilson 160fdf49e4 Add a missing parameter, without which clang crashes for vqshlu_n intrinsics.
llvm-svn: 121188
2010-12-07 22:03:43 +00:00
Jay Foad 6d4db0c885 PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

llvm-svn: 121121
2010-12-07 08:25:34 +00:00
Francois Pichet 9dfa3ce94f Type traits intrinsic implementation: __is_base_of(T, U)
New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics.

llvm-svn: 121074
2010-12-07 00:08:36 +00:00
John McCall 5d41378146 Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoretical
reason this is limited to C++, and it's certainly not limited to temporaries.

llvm-svn: 120996
2010-12-06 08:20:24 +00:00
John McCall d0a300162e __block variables require us to evaluate the RHS of an assignment before
the LHS, or else the pointer might be invalid.  This is kindof dumb, but
go ahead and make sure we're doing that for l-value scalar assignment,
which fixes a miscompile of obj-c++.dg/block-seq.mm.

Leave a FIXME for how to solve this problem for agg __blocks.

llvm-svn: 120992
2010-12-06 06:10:02 +00:00
John McCall a2342eb857 Fix a bug in the emission of __real/__imag l-values on scalar operands.
Fix a bug in the emission of complex compound assignment l-values.
Introduce a method to emit an expression whose value isn't relevant.
Make that method evaluate its operand as an l-value if it is one.
Fixes our volatile compliance in C++.

llvm-svn: 120931
2010-12-05 02:00:02 +00:00
Anders Carlsson a518b2a5a1 Add a LayoutBase member function. No functionality change.
llvm-svn: 120924
2010-12-04 23:59:48 +00:00
Anders Carlsson d74cad80b0 Replace calls to AppendBytes with calls to AppendPadding when the bytes appended are padding.
llvm-svn: 120922
2010-12-04 23:53:18 +00:00
John McCall 594827281c Silly special case: never load when dereferencing void*.
llvm-svn: 120905
2010-12-04 12:43:24 +00:00
Francois Pichet d583da04d0 More anonymous struct/union redesign. This one deals with anonymous field used in a constructor initializer list:
struct X {
  X() : au_i1(123) {}
  union {
    int au_i1;
    float au_f1;
  };
};

clang will now deal with au_i1 explicitly as an IndirectFieldDecl.

llvm-svn: 120900
2010-12-04 09:14:42 +00:00
John McCall e26a872b02 Remove some defensive calls to EmitLoadOfPropertyRefLValue that shouldn't
be required, and then fix up some missing loads on overloaded-operator
paths which that exposed.

llvm-svn: 120896
2010-12-04 08:14:53 +00:00
John McCall 34376a68c4 Although we currently have explicit lvalue-to-rvalue conversions, they're
not actually frequently used, because ImpCastExprToType only creates a node
if the types differ.  So explicitly create an ICE in the lvalue-to-rvalue
conversion code in DefaultFunctionArrayLvalueConversion() as well as several
other new places, and consistently deal with the consequences throughout the
compiler.

In addition, introduce a new cast kind for loading an ObjCProperty l-value,
and make sure we emit those nodes whenever an ObjCProperty l-value appears
that's not on the LHS of an assignment operator.

This breaks a couple of rewriter tests, which I've x-failed until future
development occurs on the rewriter.

Ted Kremenek kindly contributed the analyzer workarounds in this patch.

llvm-svn: 120890
2010-12-04 03:47:34 +00:00
John McCall 0692a32a3e Test case for the l-value base only being evaluated once.
Also, move the l-value emission code into CGObjC.cpp and teach it, for
completeness, to store away self for a super send.

Also, inline the super cases for property gets and sets and make them
use the correct result type for implicit getter/setter calls.

llvm-svn: 120887
2010-12-04 03:11:00 +00:00
John McCall f3eb96fccf Kill the KVC l-value kind and calculate the base expression when emitting
the l-value.

llvm-svn: 120884
2010-12-04 02:32:38 +00:00
Peter Collingbourne 422542625b Implement -cl-mad-enable
llvm-svn: 120881
2010-12-04 01:51:33 +00:00
Peter Collingbourne b8d9995c0e Implement -cl-unsafe-math-optimizations
llvm-svn: 120879
2010-12-04 01:51:14 +00:00
Peter Collingbourne 0ba5ac8544 Implement -cl-finite-math-only
llvm-svn: 120878
2010-12-04 01:51:05 +00:00
Bob Wilson 7795599f4b Add support for vmul_p8 Neon intrinsic. Radar 8446141.
llvm-svn: 120812
2010-12-03 17:29:39 +00:00
Bob Wilson 4fa993fc51 Add a separate rightShift flag instead of reusing the existing "poly" variable
to distinguish vsri/vsli.

llvm-svn: 120806
2010-12-03 17:10:22 +00:00
Chris Lattner 5cd8475564 Reflow to a style doug prefers, increasing indentation :-)
llvm-svn: 120746
2010-12-02 22:52:04 +00:00
Chris Lattner c5cc2fb980 fix PR8726 by teaching the aggregate init optimization code to handle
structs with references in them correctly.

llvm-svn: 120722
2010-12-02 18:29:00 +00:00
Fariborz Jahanian 50198098b9 IR Gen. part of API support for __block cxx
objects imported into blocks. //rdar://8594790.
Will have a test case coming (as well as one
sent to llvm test suite).

llvm-svn: 120713
2010-12-02 17:02:11 +00:00
Chris Lattner 27a3631bac Improve codegen for initializer lists to use memset more aggressively
when an initializer is variable (I handled the constant case in a previous
patch).  This has three pieces:

1. Enhance AggValueSlot to have a 'isZeroed' bit to tell CGExprAgg that
   the memory being stored into has previously been memset to zero.
2. Teach CGExprAgg to not emit stores of zero to isZeroed memory.
3. Teach CodeGenFunction::EmitAggExpr to scan initializers to determine
   whether they are profitable to emit a memset + inividual stores vs
   stores for everything.

The heuristic used is that a global has to be more than 16 bytes and
has to be 3/4 zero to be candidate for this xform.  The two testcases
are illustrative of the scenarios this catches.  We now codegen test9 into:

 call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 400, i32 4, i1 false)
 %.array = getelementptr inbounds [100 x i32]* %Arr, i32 0, i32 0
 %tmp = load i32* %X.addr, align 4
 store i32 %tmp, i32* %.array

and test10 into:

  call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 392, i32 8, i1 false)
  %tmp = getelementptr inbounds %struct.b* %S, i32 0, i32 0
  %tmp1 = getelementptr inbounds %struct.a* %tmp, i32 0, i32 0
  %tmp2 = load i32* %X.addr, align 4
  store i32 %tmp2, i32* %tmp1, align 4
  %tmp5 = getelementptr inbounds %struct.b* %S, i32 0, i32 3
  %tmp10 = getelementptr inbounds %struct.a* %tmp5, i32 0, i32 4
  %tmp11 = load i32* %X.addr, align 4
  store i32 %tmp11, i32* %tmp10, align 4

Previously we produced 99 stores of zero for test9 and also tons for test10.
This xforms should substantially speed up -O0 builds when it kicks in as well
as reducing code size and optimizer heartburn on insane cases.  This resolves
PR279.

llvm-svn: 120692
2010-12-02 07:07:26 +00:00
Chris Lattner 4fc8fb09d0 attempt to fix a buildbot failure, apparently apache fails to build.
llvm-svn: 120688
2010-12-02 04:27:29 +00:00
Eric Christopher 8a2ee390be Add support for the common and nocommon attributes.
rdar://8560647

llvm-svn: 120650
2010-12-02 02:45:55 +00:00
Chris Lattner e6af88628f Enhance the init generation logic to emit a memset followed by a few stores when
a global is larger than 32 bytes and has fewer than 6 non-zero values in the
initializer.  Previously we'd turn something like this:

char test8(int X) {
  char str[10000] = "abc";

into a 10K global variable which we then memcpy'd from.  Now we generate:

  %str = alloca [10000 x i8], align 16
  %tmp = getelementptr inbounds [10000 x i8]* %str, i64 0, i64 0
  call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 10000, i32 16, i1 false)
  store i8 97, i8* %tmp, align 16
  %0 = getelementptr [10000 x i8]* %str, i64 0, i64 1
  store i8 98, i8* %0, align 1
  %1 = getelementptr [10000 x i8]* %str, i64 0, i64 2
  store i8 99, i8* %1, align 2

Which is much smaller in space and also likely faster.

This is part of PR279

llvm-svn: 120645
2010-12-02 01:58:41 +00:00
John McCall b7bd14fa08 Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ObjCPropertyRefExpr
into the latter.

llvm-svn: 120643
2010-12-02 01:19:52 +00:00
John McCall f3735e01ce Restore the lvalue-to-rvalue conversion patch with a minimal fix.
llvm-svn: 120555
2010-12-01 04:43:34 +00:00
Chris Lattner b85025fedd add some infrastructure that will let us codegen
http://llvm.org/bugs/show_bug.cgi?id=279#c3 better.

No functionality change yet.

llvm-svn: 120530
2010-12-01 02:05:19 +00:00
Chris Lattner 46a7ad7605 get some i32/i8/i1 constants from Builder, which is much less painful than
using ConstantInt::get.

llvm-svn: 120527
2010-12-01 01:47:15 +00:00
John McCall 5a39bd2443 A CGRecordLayout object persists. Since its contained types may
refer to opaque types, they must be held via PATypeHolders.  I'm
not sure why this hasn't blown up before.

llvm-svn: 120491
2010-11-30 23:21:46 +00:00
John McCall bcd38217f3 CGRecordLayoutBuilder does not need to be exported from this module.
llvm-svn: 120489
2010-11-30 23:17:27 +00:00
Fariborz Jahanian 3a4ea9a76c Declaring local static in global block
literal declaration caused crash in CodeGen.
This patch fixes it. pr8707

llvm-svn: 120486
2010-11-30 23:07:14 +00:00
John McCall 4f22c9de48 L-value to r-value conversion is not ready for prime-time.
llvm-svn: 120433
2010-11-30 17:58:55 +00:00
John McCall 824fd1dcff Introduce an r-value to l-value cast kind. I'm not promising anything
about the reliability of this yet.

llvm-svn: 120422
2010-11-30 10:13:06 +00:00
Douglas Gregor 2f53a0bbf2 Harden CGDebugInfo::CreateType() a bit for cases where we couldn't generate type info for its component types
llvm-svn: 120401
2010-11-30 06:38:09 +00:00
Michael J. Spencer 8aaf49959c Merge System into Support.
llvm-svn: 120297
2010-11-29 18:12:39 +00:00
Anders Carlsson acf877be12 Don't store the maximum alignment, we can trivially compute it.
llvm-svn: 120268
2010-11-28 23:06:23 +00:00
Anders Carlsson a459adb2ff More work on laying out virtual bases.
llvm-svn: 120257
2010-11-28 19:18:44 +00:00
Anders Carlsson 3378d870d2 BuildVirtualCall doesn't need to take a reference to a pointer.
llvm-svn: 120252
2010-11-28 17:53:32 +00:00
Anders Carlsson e8ba473ed2 Make the destructor be the 'vtable anchor' of the CGCXXABI class.
llvm-svn: 120251
2010-11-28 17:50:09 +00:00
Anders Carlsson fdee32f8ed Move CGCXXABI functions to CGCXXABI.cpp
llvm-svn: 120250
2010-11-28 17:49:03 +00:00
Anders Carlsson 81f6f3626e Add a CGCXXABI.cpp file.
llvm-svn: 120249
2010-11-28 17:46:52 +00:00
Benjamin Kramer 90b5b68535 Hide a bunch of symbols.
llvm-svn: 120153
2010-11-25 18:29:30 +00:00
Anders Carlsson 1f95ee3016 Begin work on actually laying out virtual bases.
llvm-svn: 120140
2010-11-25 01:59:35 +00:00
Anders Carlsson 7f95cd1817 Rename RecordLayout::getPrimaryBaseWasVirtual to isPrimaryBaseVirtual.
llvm-svn: 120133
2010-11-24 23:12:57 +00:00
Anders Carlsson cadbc463e2 Move code off the primary base info iterator. No functionality change.
llvm-svn: 120132
2010-11-24 23:04:03 +00:00
Anders Carlsson 4131f00a1f Add CXXRecordDecl::getIndirectPrimaryBases.
llvm-svn: 120129
2010-11-24 22:50:27 +00:00
Anders Carlsson 72b1968d92 Simplify code.
llvm-svn: 120118
2010-11-24 21:53:50 +00:00
Anders Carlsson 0c75b49dc1 Fix a (probably very old) regression where we weren't using the typedef name for anonymous tag types.
llvm-svn: 120113
2010-11-24 21:05:09 +00:00
Anders Carlsson 0e4dfebe63 Revert r120110. We don't want to call ConvertType from within getCGRecordLayout.
llvm-svn: 120112
2010-11-24 20:22:04 +00:00
Anders Carlsson 449bbc5bde Use ConvertType instead of ConvertTagDeclType, since ConvertType will assign a name to the type.
llvm-svn: 120110
2010-11-24 20:05:21 +00:00
Anders Carlsson 6277615cbb Simplify code.
llvm-svn: 120109
2010-11-24 19:57:04 +00:00
Anders Carlsson c5bcaa373b Fix build.
llvm-svn: 120108
2010-11-24 19:52:29 +00:00
Anders Carlsson 63e0f2050f Make CodeGenTypes::getCGRecordLayout compute the layout lazily if it doesn't exist. This matches ASTContext::getASTRecordLayout and is less confusing.
llvm-svn: 120107
2010-11-24 19:51:04 +00:00
Anders Carlsson 36e2fa8209 CGRecordLayout types are always struct types.
llvm-svn: 120106
2010-11-24 19:37:16 +00:00
John McCall 086a464e24 Switch a lot of call-sites over to using the new value-kind calculations.
llvm-svn: 120084
2010-11-24 05:12:34 +00:00
Anders Carlsson 849ea413c6 Refactor the null-initialization for record types and make it handle bases that aren't i8 arrays.
llvm-svn: 119980
2010-11-22 18:42:14 +00:00
Anders Carlsson 39a6b22023 Remove FIXME; we don't ever want to lay out empty bases.
llvm-svn: 119957
2010-11-22 00:03:08 +00:00
Anders Carlsson a7dd96ce77 Rename BaseLLVMType to NonVirtualBaseLLVMType.
llvm-svn: 119956
2010-11-21 23:59:45 +00:00
Anders Carlsson e64fbe2a6c Add getCGRecordLayout helper function. No functionality change.
llvm-svn: 119955
2010-11-21 23:56:06 +00:00
Francois Pichet df946c3702 Fix warning: enumeration value 'IndirectField' not handled in switch.
llvm-svn: 119924
2010-11-21 06:49:41 +00:00
Fariborz Jahanian 44a41d1c25 Minor cleanup. No change otherwise.
llvm-svn: 119814
2010-11-19 18:17:09 +00:00
Fariborz Jahanian 148d113e55 Fix a bug where write-barriers for assignment through reference
types was not being generated for objc pointers.
// rdar://8681766.

llvm-svn: 119751
2010-11-18 22:39:16 +00:00
Argyrios Kyrtzidis d004064864 Refactoring of Diagnostic class.
-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
   SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

llvm-svn: 119730
2010-11-18 20:06:41 +00:00
John McCall 7decc9e4ea Calculate the value kind of an expression when it's created and
store it on the expression node.  Also store an "object kind",
which distinguishes ordinary "addressed" l-values (like
variable references and pointer dereferences) and bitfield,
@property, and vector-component l-values.

Currently we're not using these for much, but I aim to switch
pretty much everything calculating l-valueness over to them.
For now they shouldn't necessarily be trusted.

llvm-svn: 119685
2010-11-18 06:31:45 +00:00
Anton Yartsev 3f8f2886c1 comparison of AltiVec vectors now gives bool result (fix for 7533)
llvm-svn: 119678
2010-11-18 03:19:30 +00:00
Chris Lattner 11feaf5921 When forming the !srcloc mdnode for an inline asm, add the SourceLocations
of all the lines of the inline asm.  With the refactoring and enhancement
of the backend, we can now reports errors on the correct source line when
an asm contains multiple lines of text.  For something like this:

void foo() {
  asm("push %rax\n"
      ".code32\n");
}

we used to get this: (note that the line 4 in t.c isn't helpful)

t.c:4:7: error: warning: ignoring directive for now
  asm("push %rax\n"
      ^
<inline asm>:2:1: note: instantiated into assembly here
.code32
^

now we get:

t.c:5:8: error: warning: ignoring directive for now
      ".code32\n"
       ^
<inline asm>:2:1: note: instantiated into assembly here
.code32
^

Note that we're pointing to line 5 properly now.  This implements
rdar://7839391 - inline asm errors should point to the right line in the asm
and makes the error message in PR8595 much less confusing.

llvm-svn: 119489
2010-11-17 08:25:26 +00:00
Chris Lattner 068f2ab10f adjust for llvm mainline, yay type safety
llvm-svn: 119487
2010-11-17 08:13:04 +00:00
Chris Lattner 776a30ddfc factor some code out to a helper function, no functionality change.
llvm-svn: 119464
2010-11-17 05:58:54 +00:00
Fariborz Jahanian a00076cda5 Fixes synthesis of type for the object which holds info.
about a __block cxx object.

llvm-svn: 119411
2010-11-17 00:21:28 +00:00
John McCall 5b26f65b3d Reset the lifetime-managed flag between emission of the agg conditional
branches.  Fixes PR8623.

llvm-svn: 119408
2010-11-17 00:07:33 +00:00
John McCall 4f29b49de1 Support compound complex operations as l-values in C++. Add a test
case based on CodeGen/volatile-1.c which tests the current C++
semantics, and note the many, many places we fall short of them.

llvm-svn: 119402
2010-11-16 23:07:28 +00:00
Fariborz Jahanian a3e54bd33e Implements __block API for c++ objects. There is still
issue with runtime which I am discussing it with Blaine.
This is wip (so no test yet).

llvm-svn: 119368
2010-11-16 19:29:39 +00:00
John McCall 07bb19667a Simplify some complex emission and implement correct semantics for
assignment to volatiles in C.  This in effect reverts some of mjs's
work in and around r72572.  Basically, the C++ standard is quite
clear, except that it lies about volatile behavior approximating
C's, whereas the C standard is almost actively misleading.

llvm-svn: 119344
2010-11-16 10:08:07 +00:00
John McCall 3eba6e67ec Now that we have reliable cast kinds, simplify scalar cast IR gen.
llvm-svn: 119332
2010-11-16 06:21:14 +00:00
John McCall d50a27111c Kill CK_Unknown and flesh out the documentation for the existing CastKinds.
llvm-svn: 119331
2010-11-16 05:46:29 +00:00
John McCall fa8edb11e1 Teach complex compound assignment IR-generation that the RHS of
a compound assignment is always already in the computation type.

llvm-svn: 119330
2010-11-16 05:45:35 +00:00
Bob Wilson e4652b1f22 Change CXXNameMangler::mangleNeonVectorType to require the vector type to be
one of the special Neon types.  We'll check for invalid Neon vectors when
they are created, so there's no point in handling them when mangling.

llvm-svn: 119299
2010-11-16 00:32:18 +00:00
Bob Wilson 59f9dec8cd Use getTypeSize() method.
llvm-svn: 119297
2010-11-16 00:32:12 +00:00
John McCall 8d69a2160e Add a new expression kind, OpaqueValueExpr, which is useful for
certain internal type-checking procedures as well as for representing
certain implicitly-generated operations.  Uses to follow.

llvm-svn: 119289
2010-11-15 23:31:06 +00:00
Fariborz Jahanian 9db7b8b1ef Some cleanup of block API code.
llvm-svn: 119174
2010-11-15 19:19:38 +00:00
Chandler Carruth 99da11cf04 Silence an unused variable warning during release builds by folding the
expression into the assert.

llvm-svn: 119143
2010-11-15 13:54:43 +00:00
John McCall 8cb679e4e1 Assorted work leading towards the elimination of CK_Unknown.
llvm-svn: 119138
2010-11-15 09:13:47 +00:00
John McCall 83fe49d1e1 Always emit full loads from volatile complex l-values.
Return the result of a complex assignment with the original values,
not by performing a load from the l-value;  this is the correct
semantics in C, although not in C++.

llvm-svn: 119037
2010-11-14 09:40:28 +00:00
John McCall d764625448 Add a few more complex-related cast kinds that arise due to arbitrary
implicit conversions;  the last batch was specific to promotions.
I think this is the full set we need.  I do think dividing the cast
kinds into floating and integral is probably a good idea.

Annotate a *lot* more C casts with useful cast kinds.

llvm-svn: 119036
2010-11-14 08:17:51 +00:00
Fariborz Jahanian 574940e16f Removed unnecessary initialization of a flag which
somehow got several block tests fail with a linux built
compiler.

llvm-svn: 119027
2010-11-14 05:25:15 +00:00
Fariborz Jahanian 9ffe24f186 Initialize couple of fields.
llvm-svn: 119014
2010-11-13 23:48:30 +00:00
Fariborz Jahanian e988bdac44 Block API patch to do copy ctor of copied-in cxx objects in
copy helper function and dtor of copied cxx objects
in dispose helper functions. __block variables
TBD next.

llvm-svn: 119011
2010-11-13 21:53:34 +00:00
John McCall c5e62b47af Introduce five new cast kinds for various conversions into and
between complex types.

llvm-svn: 118994
2010-11-13 09:02:35 +00:00
John McCall e84af4e486 Introduce a null-to-pointer implicit cast kind.
llvm-svn: 118966
2010-11-13 01:35:44 +00:00
Benjamin Kramer c78d86a2af Reduce string thrashing.
llvm-svn: 118915
2010-11-12 18:45:23 +00:00
Bob Wilson f58e8a4db7 Use ASTContext::getTypeInfo to find the vector element size.
llvm-svn: 118899
2010-11-12 17:24:49 +00:00
Bob Wilson 8470b33762 Add a separate NeonPolyVector kind to distinguish polynomial vector types.
Add support for mangling those types according to ARM's ABI.

llvm-svn: 118898
2010-11-12 17:24:46 +00:00
Bob Wilson c155521a96 Add special-case mangling for Neon vector types.
llvm-svn: 118897
2010-11-12 17:24:43 +00:00
Benjamin Kramer 8c173cc364 Use a twine.
llvm-svn: 118892
2010-11-12 15:42:18 +00:00
Douglas Gregor ad3832e213 Teach debug-info generation that SourceManager::getPresumedLoc() can
produce an invalid location even when given a valid location, if the
file system has changed underneath us. Recovery more gracefully.

llvm-svn: 118834
2010-11-11 20:45:16 +00:00
Fariborz Jahanian 2a5deb56a4 Adding couple of Block API, a bug fix and
a test change, all for blocks. wip.

llvm-svn: 118745
2010-11-11 00:11:38 +00:00
Bob Wilson aeb56444f9 Add a variant of GCC-style vector types for ARM NEON.
NEON vector types need to be mangled in a special way to comply with ARM's ABI,
similar to some of the AltiVec-specific vector types.  This patch is mostly
just renaming a bunch of "AltiVecSpecific" things, since they will no longer
be specific to AltiVec.  Besides that, it just adds the new "NeonVector" enum.

llvm-svn: 118724
2010-11-10 21:56:12 +00:00
Charles Davis 99202b358f Use the right calling convention when mangling names in the Microsoft C++
mangler. Now member functions and pointers thereof have their calling
convention mangled as __thiscall if they have the default CC (even though,
they technically still have the __cdecl CC).

llvm-svn: 118598
2010-11-09 18:04:24 +00:00
David Chisnall 82f755c58d Remove the use of aliases in outputted code from ObjC (GNU runtime).
llvm-svn: 118498
2010-11-09 11:21:43 +00:00
Nick Lewycky 30d939681c Remove debugging printf.
Fix linux build.

llvm-svn: 118497
2010-11-09 09:53:02 +00:00
Anders Carlsson c1351cac17 Introduce the concept of a non-virtual base type to CGRecordLayoutBuilder as a first step towards fixing PR6995.
llvm-svn: 118491
2010-11-09 05:25:47 +00:00
Argyrios Kyrtzidis 8909686b22 Fix miscompilation regarding VLAs; subscription of VLA pointers was incorrect.
Fixes rdar://8644873 & http://llvm.org/PR8567.

llvm-svn: 118468
2010-11-09 01:30:48 +00:00
John McCall 478382521e When re-using a vtable slot for the nearest overridden method, just because
there's no return adjustment from the overridden to the overrider doesn't
mean there isn't a return adjustment from the overrider to the final
overrider.  This matters if we're emitting a virtual this-adjustment thunk
because the overrider virtually inherits from the class providing the
nearest overridden method.  Do the appropriate return adjustment in this case.

Fixes PR7611.

llvm-svn: 118466
2010-11-09 01:18:05 +00:00
Douglas Gregor 1ccc8416a0 Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.

But don't get too excited about that happening now.

llvm-svn: 118385
2010-11-07 23:05:16 +00:00
John McCall 2faab302e0 ARM EH uses a different personality function in C.
llvm-svn: 118366
2010-11-07 02:35:25 +00:00
John McCall cdf7ef5437 Simplify the logic for emitting guard variables for template static
data members by delaying the emission of the initializer until after
linkage and visibility have been set on the global.  Also, don't
emit a guard unless the variable actually ends up with vague linkage,
and don't use thread-safe statics in any case.

llvm-svn: 118336
2010-11-06 09:44:32 +00:00
Anders Carlsson ba37e1eb49 std::nullptr_t is a fundamental type for RTTI purposes.
llvm-svn: 118238
2010-11-04 05:28:09 +00:00
Anders Carlsson 2683fd6f8c Mangle std::nullptr_t as specified by the Itanium C++ ABI.
llvm-svn: 118236
2010-11-04 04:31:32 +00:00
David Chisnall e8431a7766 Some fixes for synthesized ivar metadata (GNU runtime).
llvm-svn: 118172
2010-11-03 16:12:44 +00:00