Commit Graph

4972 Commits

Author SHA1 Message Date
Ken Dyck 3563aa6520 Replace a couple of divide-by-8s with divide-by-charwidths. No change in
functionality intended.

llvm-svn: 129496
2011-04-14 01:00:39 +00:00
Ken Dyck c5ca87675e Replace a couple of divisions-by-'8' with divisions-by-charwidth. No change
in functionality intended.

llvm-svn: 129491
2011-04-14 00:43:09 +00:00
Bill Wendling a865185ad6 Removing the unaligned load tests from builtins-x86.c since they're generated by a regular 'load' now.
llvm-svn: 129464
2011-04-13 20:17:22 +00:00
Bill Wendling 88ae43772a It looks like the FreeBSD buildbot needs this for the builtins-x86.c test.
llvm-svn: 129433
2011-04-13 10:02:54 +00:00
Bill Wendling b9c9e34cb3 Just use a native "load" instead of translating the builtin later. Clang can
take it!

I wasn't able to get __builtin_ia32_loaddqu to transform into an unaligned
load...I'll have to look into it further.

llvm-svn: 129427
2011-04-13 05:58:17 +00:00
Anders Carlsson bbe277c4a9 Use EmitCallOrInvoke in EmitBadTypeidCall and EmitBadCastCall.
llvm-svn: 129424
2011-04-13 02:35:36 +00:00
Bill Wendling 3137d3cb49 Convert the unaligned load builtins to the first-class versions.
llvm-svn: 129420
2011-04-13 00:36:37 +00:00
Daniel Dunbar 9c8cd4c097 IRgen/Obj-C: Emit CFStrings and NSStrings with the alignment of the char type,
there is no reason to align them higher.
 - This roughly matches llvm-gcc's r126913.
 - It is an open question whether or not we should do this for cstring's in
   general (code size vs optimization potential), for now we just match llvm-gcc
   until someone wants to run some experiments.

llvm-svn: 129410
2011-04-12 23:30:52 +00:00
John McCall 58989b7125 We can't emit an aggregate cast as its sub-expression in general just
because the result is ignored.  The particular example here is with
property l-values, but there could be all sorts of lovely casts that this
isn't safe for.  Sink the check into the one case that seems to actually
be capable of honoring this.

llvm-svn: 129397
2011-04-12 22:02:02 +00:00
John McCall a97f329869 Template static data members can have weak_odr linkage, not just
weak linkage.  Also, fix a problem where global weak variables
with non-trivial initializers were getting guard variables, or at
least were checking for them and then crashing.

llvm-svn: 129342
2011-04-12 01:46:54 +00:00
John McCall 32f44bd0fc Ignore indirect field declarations. Fixes PR9570.
llvm-svn: 129337
2011-04-12 01:01:22 +00:00
John McCall 2979fe01da After some discussion with Doug, we decided that it made a lot more sense
for __unknown_anytype resolution to destructively modify the AST.  So that's
what it does now, which significantly simplifies some of the implementation.
Normal member calls work pretty cleanly now, and I added support for
propagating unknown-ness through &.

llvm-svn: 129331
2011-04-12 00:42:48 +00:00
Anders Carlsson 0c63350b0b If there's an invoke destination, we should use invoke instead of call when calling the __cxa_bad_typeid function. Fixes PR7400.
llvm-svn: 129273
2011-04-11 14:13:40 +00:00
John McCall 2d2e870745 More __unknown_anytype work.
llvm-svn: 129269
2011-04-11 07:02:50 +00:00
Anders Carlsson 8a01a751c9 Remove CK_DynamicToNull.
llvm-svn: 129265
2011-04-11 02:03:26 +00:00
Anders Carlsson c1c9971cab When we know that a dynamic_cast always returns null, we can make
CodeGenFunction::EmitDynamicCast always return null or throw a bad_cast 
exception.

llvm-svn: 129264
2011-04-11 01:45:29 +00:00
Anders Carlsson 882d790f72 Clean up CodeGenFunction::EmitDynamicCast. No functionality change.
llvm-svn: 129262
2011-04-11 00:46:40 +00:00
Anders Carlsson 98981b10c8 Replace a couple of Builder.CreateICmpEQ with Builder.CreateIsNull. No functionality change.
llvm-svn: 129261
2011-04-11 00:30:07 +00:00
Anders Carlsson c602006638 As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind which
represents a dynamic cast where we know that the result is always null.

For example:

struct A {
  virtual ~A();
};
struct B final : A { };
struct C { };

bool f(B* b) {
  return dynamic_cast<C*>(b);
}

llvm-svn: 129256
2011-04-10 20:33:22 +00:00
Anders Carlsson c53d9e8350 Strip off parens and no-op casts when deciding if an expr can be devirtualized. Fixes the second half of PR9660.
llvm-svn: 129253
2011-04-10 18:20:53 +00:00
Anders Carlsson e5ec21c977 Change CollectPrimaryBases to collect the bases in the right order. Fixes one half of PR9660.
llvm-svn: 129252
2011-04-10 18:00:32 +00:00
Anders Carlsson 68aad14dd3 Make -fdump-vtable-layouts also dump vtable indices for all virtual member functions in the class.
llvm-svn: 129250
2011-04-10 17:42:45 +00:00
Eli Friedman 493c34a86c PR9580: Handle vectors correctly in ScalarExprEmitter::EmitRem.
While I'm here, FileCheck-ize the ext-vector test, so we actually check
what it is generating.

llvm-svn: 129241
2011-04-10 04:44:11 +00:00
Eli Friedman db42a3e876 Make sure we or together the overflow flags of the multiply and add, so the
check is triggered appropriately.  Reported on cfe-dev.

llvm-svn: 129231
2011-04-09 19:54:33 +00:00
Eli Friedman c5b20b5283 PR8369: make __attribute((regparm(0))) work correctly. Original patch by
pageexec@freemail.hu, tweaks by me.

llvm-svn: 129206
2011-04-09 08:18:08 +00:00
Chris Lattner e4ec5abf1b fix indentation
llvm-svn: 129202
2011-04-09 07:11:53 +00:00
Chris Lattner 9cb59fa834 add a __sync_swap builtin to fill out the rest of the __sync builtins.
Patch by Dave Zarzycki!

llvm-svn: 129189
2011-04-09 03:57:26 +00:00
Ken Dyck df01628e08 Convert the PointerWidthInBytes variable in EmitMemberPointer() to CharUnits
to eliminate a divide-by-8. No change in functionality intended.

llvm-svn: 129180
2011-04-09 01:30:02 +00:00
Ken Dyck 499e93d7ee Eliminate a divide-by-8 in BuildVMIClassTypeInfo() by using CharUnits for
the base offset. No change in functionality intended.

llvm-svn: 129179
2011-04-09 01:09:56 +00:00
Nick Lewycky d85ae78c48 Apply explicit braces to avoid ambiguous 'else' [-Wparentheses]
llvm-svn: 129176
2011-04-09 00:25:15 +00:00
Devang Patel 0b37e79891 Do not use zero as an upper bound for unbounded array because upper bound zero also indicates one element array.
llvm-svn: 129157
2011-04-08 21:56:52 +00:00
Ken Dyck bb4e977218 [Reapply r128776, modified so that it does not break debug info.]
Change the return type of CodeGenVTables::getVirtualBaseOffsetOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 129072
2011-04-07 12:37:09 +00:00
John McCall 319963434c Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use.  I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.

llvm-svn: 129065
2011-04-07 08:22:57 +00:00
Ken Dyck 3a09bc5ab0 [Reapply r128773. This is not the source of the issues Devang was seeing
with debug info.]

Use CharUnits for the offsets in the VirtualBaseClassOffsetOffsetsMapTy. No
change in functionality intended.

llvm-svn: 129048
2011-04-07 01:22:42 +00:00
Ken Dyck 25c82240e9 [Reapply r128771. It wasn't the source of the issues Devang saw with debug
info.]

Use CharUnits for the offset type in the ClassNamesAndOffsets map in
dumpLayout(). No change in functionality intended.

llvm-svn: 129046
2011-04-07 00:59:42 +00:00
Ken Dyck 42a9d29c2c Reapply r128770. It's not the cause of the issues Devang saw with debug info.
Use CharUnits for the offsets in the VBaseOffsetOffsetsMapTy types. No
change in functionality intended.

llvm-svn: 129043
2011-04-07 00:55:01 +00:00
Fariborz Jahanian 5de5313abe Refine rules for atomic property api to
pass a previously failing clang test.
// rdar://8808439

llvm-svn: 129004
2011-04-06 16:05:26 +00:00
Peter Collingbourne eafa4e4b5b If this is an intrinsic function, set the function's attributes to the intrinsic's attributes.
llvm-svn: 129000
2011-04-06 12:29:04 +00:00
Devang Patel 78019ec14d Simplify.
llvm-svn: 128957
2011-04-05 23:26:36 +00:00
Fariborz Jahanian 10a95ca876 Fixes a regression caused by my last patch.
As a result, I had to remove a c++ version of a clang
test which requires more scrutiny on my part.

llvm-svn: 128950
2011-04-05 23:01:27 +00:00
Devang Patel b87c428055 Emit debug info for function template parameters.
llvm-svn: 128948
2011-04-05 22:54:11 +00:00
Fariborz Jahanian 0f4c711895 Generate atomic api for atomic properties (x86 and x86_64
targets) when load/store results in multiple instructions.
// rdar://8808439

llvm-svn: 128937
2011-04-05 21:41:23 +00:00
Devang Patel e1dd424380 Remove unintentional check-in.
llvm-svn: 128928
2011-04-05 21:05:56 +00:00
Devang Patel 095421b4a8 Fix typo.
llvm-svn: 128921
2011-04-05 20:28:21 +00:00
Devang Patel 98d26c91da Use TemplateParameterList to extract template parameter name.
llvm-svn: 128915
2011-04-05 20:15:06 +00:00
Andrew Trick 15e36e8edd Added *hidden* flags -print-options and -print-all-options so
developers can see if their driver changed any cl::Option's. The
current implementation isn't perfect but handles most kinds of
options. This is nice to have when decomposing the stages of
compilation and moving between different drivers. It's also a good
sanity check when comparing results produced by different command line
invocations that are expected to produce the comparable results.

Note: This is not an attempt to prolong the life of cl::Option. On the
contrary, it's a placeholder for a feature that must exist when
cl::Option is replaced by a more appropriate framework. A new
framework needs: a central option registry, dynamic name lookup,
non-global containers of option values (e.g. per-module,
per-function), *and* the ability to print options values and their defaults at
any point during compilation.

llvm-svn: 128911
2011-04-05 18:56:55 +00:00
Andrew Trick b2a84726f6 whitespace
llvm-svn: 128908
2011-04-05 18:49:32 +00:00
Devang Patel 7522abd3ce Refactor.
llvm-svn: 128893
2011-04-05 17:30:54 +00:00
David Chisnall ec343e8544 Fix copy-and-paste bug that I introduced while tidying up the code.
Does anyone want to buy me a new brain?

llvm-svn: 128890
2011-04-05 17:15:18 +00:00
Sandeep Patel 45df3dd3fe Set AAPCS-VFP calling convention accordingly and hard float ABI command handling.
llvm-svn: 128866
2011-04-05 00:23:47 +00:00
Devang Patel 44927690c3 Eliminate conservative check that is covered by isIncompleteType() check.
llvm-svn: 128857
2011-04-04 23:23:39 +00:00
Devang Patel a540f1462c Incomplete type does not have any size.
llvm-svn: 128855
2011-04-04 23:18:38 +00:00
Devang Patel 84852bbb42 Revert r128770, r128771, r128773 and r128776 for now. It breaks debug info.
llvm-svn: 128842
2011-04-04 20:36:06 +00:00
Ken Dyck 1473c9a7c4 Change the return type of CodeGenVTables::getVirtualBaseOffsetOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 128776
2011-04-02 17:52:22 +00:00
Ken Dyck 1b23db93df Use CharUnits for the offsets in the VirtualBaseClassOffsetOffsetsMapTy. No
change in functionality intended.

llvm-svn: 128773
2011-04-02 17:13:02 +00:00
Ken Dyck cf4ef5314f Use CharUnits for the offset type in the ClassNamesAndOffsets map in
dumpLayout(). No change in functionality intended.

llvm-svn: 128771
2011-04-02 17:03:24 +00:00
Ken Dyck 1eac9f1546 Use CharUnits for the offsets in the VBaseOffsetOffsetsMapTy types. No
change in functionality intended.

llvm-svn: 128770
2011-04-02 16:57:20 +00:00
Ken Dyck 6b20919317 Convert BaseOffset::NonVirtualOffset to CharUnits. No change in
functionality intended.

llvm-svn: 128756
2011-04-02 01:32:03 +00:00
Ken Dyck 872d74a591 Convert offset parameters and return values of VTableComponent methods to
CharUnits. No change in functionality intended.

llvm-svn: 128754
2011-04-02 01:14:48 +00:00
Ken Dyck 496906629b Convert the offsets in VCallOffsetMap to CharUnits. No change in
functionality intended.

llvm-svn: 128753
2011-04-02 00:51:15 +00:00
Ken Dyck eff7fe645b Convert offset parameters of VTableBuilder::IsOverriderUsed() to CharUnits.
No change in functionality intended.

llvm-svn: 128752
2011-04-02 00:44:58 +00:00
Devang Patel 1ffe23464a Do not try calculate the size of forward-declared template type array.
llvm-svn: 128725
2011-04-01 19:02:33 +00:00
Daniel Dunbar 826342774e IRgen: Reapply r128691 with a fix to ensure we don't increase alignment past
that of the array element type.

llvm-svn: 128698
2011-04-01 00:49:43 +00:00
Daniel Dunbar ea6b81a2ad Revert r128691, "IRgen: Improve GCC compatibility when dealing with packed
arrays by propagating", it's breaking test in ways I don't understand yet.

llvm-svn: 128693
2011-04-01 00:13:33 +00:00
Daniel Dunbar 417bf0f147 IRgen: Improve GCC compatibility when dealing with packed arrays by propagating
the array alignment to the array access.
 - This is more or less the best we can do without having alignment present in
   the type system, but is a long way from truly matching how GCC handles this.

llvm-svn: 128691
2011-03-31 23:32:15 +00:00
John McCall 7c623641a6 Whoops.
llvm-svn: 128621
2011-03-31 09:19:20 +00:00
John McCall f9b056b002 After much contemplation, I've decided that we probably shouldn't "unique"
__block object copy/dispose helpers for C++ objects with those for
different variables with completely different semantics simply because
they happen to both be no more aligned than a pointer.

Found by inspection.

Also, internalize most of the helper generation logic within CGBlocks.cpp,
and refactor it to fit my peculiar aesthetic sense.

llvm-svn: 128618
2011-03-31 08:03:29 +00:00
John McCall 7306487077 Move all the significant __block code into CGBlocks.cpp. No functionality
change.

llvm-svn: 128608
2011-03-31 01:59:53 +00:00
Matt Beaumont-Gay 873c6dd875 Oops, prefer C-style cast here
llvm-svn: 128607
2011-03-31 01:56:27 +00:00
Matt Beaumont-Gay a25fce8e9e Silence GCC warning about differing types on the branches of a conditional expression
llvm-svn: 128605
2011-03-31 01:43:22 +00:00
Ken Dyck 4680e9219a Convert the return value of
VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() to CharUnits. No change
in functionality intended.

llvm-svn: 128603
2011-03-31 01:08:46 +00:00
Ken Dyck 47e1e54343 Convert the OffsetInLayoutClass parameter of
VCallAndVBaseOffsetBuilder::AddVBaseOffsets() to CharUnits. No change in
functionality intended.

llvm-svn: 128600
2011-03-31 00:56:47 +00:00
Ken Dyck 1a93b3b080 Convert the OffsetInLayoutClass of the VCallAndVBaseOffsetBuilder
constructor to CharUnits. No change in functionality intended.

llvm-svn: 128598
2011-03-31 00:48:04 +00:00
Ken Dyck 9b32ee1611 Convert the RealBaseOffset parameter of
VCallAndVBaseOffsetBuilder::AddVCallAndVBaseOffsets() to
CharUnits. No change in functionality intended.

llvm-svn: 128596
2011-03-31 00:37:24 +00:00
Bob Wilson 7201af3914 Use intrinsics for Neon vmull operations. Radar 9208957.
llvm-svn: 128590
2011-03-31 00:09:00 +00:00
Fariborz Jahanian 7a26ba4d0d Fix IRGen issues related to using property-dot syntax
for prperty reference types. // rdar://9208606.

llvm-svn: 128551
2011-03-30 16:11:20 +00:00
Jay Foad 20c0f02cc5 Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
PHINode::Create() giving the (known or expected) number of operands.

llvm-svn: 128538
2011-03-30 11:28:58 +00:00
Jay Foad 27e20c3c58 (Almost) always call reserveOperandSpace() on newly created PHINodes.
llvm-svn: 128534
2011-03-30 11:19:06 +00:00
Ken Dyck b3ba775523 Convert the offset parameter of
VCallAndVBaseOffsetBuilder::AddVCallOffsets() to CharUnits. No change in
functionality intended.

llvm-svn: 128531
2011-03-30 10:11:40 +00:00
Ken Dyck 075de167f8 Convert local offset variable to CharUnits in AddVCallOffsets. No change in
functionality intended.

llvm-svn: 128522
2011-03-30 01:21:33 +00:00
Ken Dyck 078f3e6905 Convert a local offset variable to CharUnits. No change in functionality
intended.

llvm-svn: 128521
2011-03-30 01:14:22 +00:00
Ken Dyck 032a903982 Convert the OffsetInLayoutClass parameter of DeterminePrimaryVirtualBases()
to CharUnits. No change in functionality intended.

llvm-svn: 128520
2011-03-30 01:10:23 +00:00
Ken Dyck 45956a467e Convert the OffsetInLayoutClass parameter of LayoutSecondaryVTables to
CharUnits. No change in functionality intended.

llvm-svn: 128516
2011-03-30 00:50:28 +00:00
Devang Patel 4d7612744f Fix in r128471 is very broad. Some of the unconditional branches need line number information for better user experience.
Restrict the fix. This fixes break.exp failures from gdb testsuite.

llvm-svn: 128513
2011-03-30 00:08:31 +00:00
Devang Patel 6f2e41e0d4 Do not line number entry for unconditional branches. Usually, users do not want to stop at closing '}'.
llvm-svn: 128471
2011-03-29 18:35:54 +00:00
Fariborz Jahanian b24b568725 Implements property of reference types. Adding
an executable test to llvm test suite.
// rdar://9070460.

llvm-svn: 128435
2011-03-28 23:47:18 +00:00
Daniel Dunbar 67919b2a5b Integrated-As: Support -Wa,-L when using the integrated assembler.
llvm-svn: 128433
2011-03-28 22:49:28 +00:00
Anton Yartsev 93900c7d1e refactoring
llvm-svn: 128427
2011-03-28 21:00:05 +00:00
Ken Dyck f9742cca31 Convert offset parameter in LayoutPrimaryAndSecondaryVTables() to CharUnits.
No change in functionality intended.

llvm-svn: 128393
2011-03-27 20:33:38 +00:00
Ken Dyck 9a7e532dd8 Convert VTableBuilder::MostDerivedClassOffset to CharUnits. No change in
functionality intended.

llvm-svn: 128392
2011-03-27 20:20:28 +00:00
Ken Dyck 0d5804a622 Convert FinalOverriders::MostDerivedClassOffset to CharUnits. No change in
functionality intended.

llvm-svn: 128391
2011-03-27 20:10:29 +00:00
Ken Dyck 5f3601d35a Remove a fixed FIXME comment (the base offset has already been converted to
CharUnits).

llvm-svn: 128386
2011-03-27 19:19:52 +00:00
Ken Dyck f4be03ae04 Convert the offset parameters of AddMethods() to CharUnits. No change in
functionality intended.

llvm-svn: 128385
2011-03-27 19:15:11 +00:00
Ken Dyck f736d9cb75 Convert the BaseOffsetInLayoutClass parameter of ComputeThisAdjustment() to
CharUnits. No change in functionality intended.

llvm-svn: 128384
2011-03-27 19:03:44 +00:00
Ken Dyck 7d876f3649 Convert offset members in MethodInfo to CharUnits. No change in
functionality intended.

llvm-svn: 128383
2011-03-27 18:57:53 +00:00
Anton Yartsev 530deb9a39 AltiVec vector comparison logic now affect only vectors of fundamental AltiVec vector types. It fixes bug 9347.
llvm-svn: 128381
2011-03-27 15:36:07 +00:00
Anton Yartsev 28ccef788b supported: AltiVec vector initialization with a single literal according to PIM section 2.5.1 - after initialization all elements have the value specified by the literal
llvm-svn: 128375
2011-03-27 09:32:40 +00:00
John McCall 358d056c14 We were emitting construction v-tables with internal linkage all the time.
Emit them instead with the linkage of the VTT.

I'm actually really ambivalent about this;  it's what GCC does, but outside
of improving code size (if the linkage is coalescing), I'm not sure it's
at all relevant.  Construction vtables are naturally referenced only by the
VTT, which is itself only referenced by complete-object constructors and
destructors;  giving the construction vtables possibly-external linkage is
important if you have an optimization that drills through the VTT to a
reference to a particular construction vtable which it cannot just emit
itself.

llvm-svn: 128374
2011-03-27 09:00:25 +00:00
Douglas Gregor 1baf38f5a6 On Mac OS X, the presence of an 'availability' attribute for that
platform implies default visibility. To achieve these, refactor our
lookup of explicit visibility so that we search for both an explicit
VisibilityAttr and an appropriate AvailabilityAttr, favoring the
VisibilityAttr if it is present.

llvm-svn: 128336
2011-03-26 12:10:19 +00:00
David Chisnall 34d00052cb Reformatted doc comments so that they are now difficult to edit in any editor that doesn't have explicit doxygen support, as per LLVM style guidelines.
llvm-svn: 128335
2011-03-26 11:48:37 +00:00
Ken Dyck 58863dc46a Convert the OffsetInLayoutClass parameter of
FinalOverriders::ComputeBaseOffsets() to CharUnits. No change in
functionality intended.

llvm-svn: 128323
2011-03-26 01:36:26 +00:00
Ken Dyck 785cbdb6da Convert FinalOverriders::Offset to CharUnits. No change in functionality
intended.

llvm-svn: 128321
2011-03-26 01:29:16 +00:00
Ken Dyck 808457cfd6 Convert offset in MethodBaseOffsetPairTy to CharUnits. No change in
functionality intended.

llvm-svn: 128318
2011-03-26 01:18:17 +00:00
Ken Dyck 70b47e08dc Convert the offsets in SubobjectOffsetMapTy to CharUnits. No change in
functionality intended.

llvm-svn: 128317
2011-03-26 01:09:13 +00:00
Ken Dyck ce81203d9b Convert several local variables to CharUnits. No change in functionality
intended.

llvm-svn: 128315
2011-03-26 00:51:24 +00:00
Devang Patel 5f070a51e7 Provide blockDecl's startLoc to startFunction. This fixes hidden bug exposed by recent code gen changes. This is tested by global-blocks-lines.exp in gdb testsuite.
llvm-svn: 128303
2011-03-25 21:26:13 +00:00
Daniel Dunbar 7c9295a5b4 Obj-C/NeXT: Update and reapply 108847, now that changes are more baked.
llvm-svn: 128300
2011-03-25 20:09:09 +00:00
David Chisnall 3e57560c10 Refactor CGObjCMac to use the shared code for EH stuff.
Sanity checked by John McCall.

llvm-svn: 128287
2011-03-25 17:46:35 +00:00
Anders Carlsson 843c69119b Unbreak CMake build.
llvm-svn: 128276
2011-03-25 14:16:48 +00:00
David Chisnall e8ebed3520 Added some doc comments.
llvm-svn: 128275
2011-03-25 14:06:20 +00:00
David Chisnall d3858d6b0c Continuing work on ObjC tidyup:
- Moved the CGObjCRuntime functions out of CGObjCMac.cpp into CGObjCRuntime.cpp

- Added generic functions in CGObjCRuntime for emitting @try and @synchronize
  blocks, usable by any runtime that uses DWARF exceptions.

- Made the GNU runtimes use these functions.

It should now be possible to replace the equivalent functions in
CGObjCNonFragileABIMac with simple calls to these two functions, providing the
runtime functions as arguments.  I'll post a diff to the list for review before
making any changes to the Mac runtime stuff.

llvm-svn: 128274
2011-03-25 11:57:33 +00:00
Eli Friedman b4d3c99929 Make sure we aggressively attach nounwind (etc.) to calls to library
functions of the form __builtin_XXX.

llvm-svn: 128198
2011-03-24 05:09:45 +00:00
Ken Dyck 16ffcac1a2 Convert the BaseOffset member of BaseSubobject to CharUnits from bits. No
change in functionality intended.

llvm-svn: 128190
2011-03-24 01:21:01 +00:00
David Chisnall 76803410c2 Fixed type error in last commit (forgot that now that selectors are not
accessed via the indirect pointer, they don't need to be pointers to pointers).

Finished moving the message lookup code into separate subclasses for each
runtime.  Also performed a few smallish related tidies.

We're now bitcasting the result of the message lookup functions, rather than
casting the lookup functions themselves, so the messages.m test needed updating
to reflect this.

llvm-svn: 128180
2011-03-23 22:52:06 +00:00
Andrew Trick 4a3ee93447 Revert r128156 because of CodeGenObjC/messages.m and Coverage/codegen-gnu.m.
llvm-svn: 128157
2011-03-23 19:43:59 +00:00
David Chisnall f1a38cf32d Remove the redundant loads / stores to globals that we were generating for selectors (GNU runtimes).
llvm-svn: 128156
2011-03-23 18:39:12 +00:00
David Chisnall d7972f5bf8 Initial work on refactoring GNU runtime code (long overdue - it's quite obvious
that I hadn't used C++ for several years before writing most of this code).
Still lots more to do.  This set of changes includes:

- Remove the distinction between typed and untyped selectors.  More accurately
  reflect what the runtime does, by using typed selectors everywhere, with an
  empty type field if the types are unknown.  Now we just store a small list of
  types for each selector (in theory, this should always be exactly one, but
  this constraint was not enforced back in 1986 when it should have been).

- Add some consistency to how runtime functions are created.  These are all
  generated via the LazyRuntimeFunction class (which might be useful outside
  CGObjCGNU - feel free to move it into a header if it is).  This function
  stores the types of a function, looks it up the first time it's used, and
  caches the result.  This means that we're now not wasting time constructing
  the llvm::FunctionType every time some of the functions are looked up, but
  also not inserting references to runtime functions into the module if they're
  not actually used.

- Started separating out the fragile and non-fragile ABI behaviours into two
  subclasses of CGObjCGNU: CGObjCGCC for the legacy GCC runtime ABI and
  CGObjCGNUstep for the new GNUstep ABI.  Not all of the differences in
  behaviour are factored out yet, but they will be in future commits.

- Removed all of the CodeGen:: things: we've been using namespace CodeGen in
  this file for ages, so having explicit namespace specifiers is just a bit
  confusing.

- Added a few more comments.

- Used llvm::StringRef instead of std::string in a few places.

- Finally got around to storing the module path in the module structure.  The
  ABI says that the compiler should do this, although it's not used in the
  runtime or exposed outside the runtime, so it's pretty useless.  

Still to do:

- We currently have two code paths for generating try blocks, one for ObjC and
  one for ObjC++.  Not only are these substantially similar, they are also very
  similar to the CGObjCMac version.  These need factoring out into a single
  parameterised implementation, either in CGObjCRuntime or CodeGenFunction.
  The EmitObjCXXTryStmt() function was added so that the changes to fix a bug
  in time for the 2.9 release would be self-contained and reduce the chances of
  breaking anything else, but these should be done properly as soon as
  possible.

- Split up some large functions (e.g. GenerateClass()) into smaller functions
  for generating the various data structures.

- The method lookup code into the two subclasses, removing the conditionals in
  the message send functions.

- Add doxygen comments on the remaining undocumented functions.

- We seem to be generating global pointer variables for selectors, then storing
  a pointer to the selector, then generating a load of this pointer (and then a
  load of the real selector later) every time a static selector is used.  I can
  only assume I was asleep or drunk when I did this - we should just be
  referencing the selectors directly in the selector array.

llvm-svn: 128152
2011-03-23 16:36:54 +00:00
Devang Patel 945b8aed2a Update type cache when a type is completed.
Radar 9168773

llvm-svn: 128150
2011-03-23 16:29:39 +00:00
Ken Dyck 3fb4c8920d Convert OffsetFromNearestVBast parameter of InitializeVTablePointer(s) to
CharUnits. No change in functionality intended.

llvm-svn: 128129
2011-03-23 01:04:18 +00:00
Douglas Gregor 20b2ebd785 Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

  void foo()
  __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

  - If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
    will result in a deprecation warning, as if we had placed
    attribute((deprecated)) on it (but with a better diagnostic)
  - If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
    will result in an "unavailable" warning (in C)/error (in C++), as
    if we had placed attribute((unavailable)) on it
  - If we choose a deployment target prior to 10.2, foo() is
    weak-imported (if it is a kind of entity that can be weak
    imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.

llvm-svn: 128127
2011-03-23 00:50:03 +00:00
Ken Dyck cfc332cc43 Convert NonVirtual parameter of ApplyNonVirtualAndVirtualOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 128126
2011-03-23 00:45:26 +00:00
David Chisnall 067f0ed468 Simplify Mac runtime selection - it's the factory function's job to select which class to produce, not CodeGenModule's.
llvm-svn: 128109
2011-03-22 21:21:24 +00:00
David Chisnall 08a45257de Make the property accessor functions that take a ptrdiff_t actually take a ptrdiff_t instead of a long (should have no impact on any sane platforms, but win64 is not sane).
llvm-svn: 128104
2011-03-22 20:03:13 +00:00
David Chisnall 6a566d2c1e Make the ivar offset always be a ptrdiff_t, because stuff in CGObjC.cpp expects this. Actually, it expects a long, but that's a bug that will be fixed in the next commit...
llvm-svn: 128102
2011-03-22 19:57:51 +00:00
Nick Lewycky d2348d8d3f Fix typo in comment.
llvm-svn: 128088
2011-03-22 17:35:47 +00:00
Daniel Dunbar 12100e2c7f Frontend: Add a more explicit -backend-option flag for passing backend command
line options, instead of leveraging the blanket -mllvm option.
 - This allows using the frontend itself without requiring the backend have
   those options available (i.e., if the target wasn't built).

llvm-svn: 128087
2011-03-22 16:48:17 +00:00
John McCall 6a4fa52b37 The emission of an Objective-C++'s class .cxx_destruct method should be
conditioned on whether it has any destructible ivars, not on whether
it has any non-trivial class-object initializers.

llvm-svn: 128074
2011-03-22 07:05:39 +00:00
Ken Dyck 6aa767c18e Convert Offset variable in GetAddressOfDirectBaseInCompleteClass() to
CharUnits. No change in functionality intended.

llvm-svn: 128060
2011-03-22 01:21:15 +00:00
Ken Dyck a1a4ae34d0 Change return value of ComputeNonVirtualBaseClassOffset() to CharUnits. No
change in functionality intended.

llvm-svn: 128050
2011-03-22 00:53:26 +00:00
Ken Dyck 664569965f Eliminate some literal '8's in FillInNullDataMemberPointers() by switching
to CharUnits. No change in functionality intended.

llvm-svn: 128047
2011-03-22 00:24:31 +00:00
David Chisnall e1d2584d44 Fix Objective-C++ exceptions (GNU runtime).
llvm-svn: 127980
2011-03-20 21:35:39 +00:00
Anders Carlsson 6dc204de40 __cxa_atexit does not throw.
llvm-svn: 127977
2011-03-20 20:52:32 +00:00
Ken Dyck 6d470d9398 Use CharUnits's new increment operator. No change in functionality intended.
llvm-svn: 127938
2011-03-19 01:28:06 +00:00
Ken Dyck 0f2f30b241 Replace literal '8's with CharWidth in AppendBitField. No change in
functionality intended.

llvm-svn: 127927
2011-03-19 00:57:28 +00:00
Peter Collingbourne 599cb8e430 Add support for language-specific address spaces. On top of that,
add support for the OpenCL __private, __local, __constant and
__global address spaces, as well as the __read_only, _read_write and
__write_only image access specifiers.  Patch originally by ARM;
language-specific address space support by myself.

llvm-svn: 127915
2011-03-18 22:38:29 +00:00
John McCall 7ef5cb3038 The Darwin kernel does not provide useful guard variable support.
Issue this as an IR-gen error;  it's not really worthwhile doing this
"right", i.e. in Sema, because IR gen knows a lot of tricks beyond
what the constant evaluator knows.

llvm-svn: 127854
2011-03-18 02:56:14 +00:00
Ken Dyck a1b35109cf Convert alignment values to CharUnits. No change in functionality intended.
llvm-svn: 127848
2011-03-18 01:26:17 +00:00
Ken Dyck 33fa9ee4fd Convert getSizeInBytes() to getSizeInChars(), which returns its result in
CharUnits. No change in functionality intended.

llvm-svn: 127846
2011-03-18 01:12:13 +00:00
Ken Dyck 4e54dcaca1 Convert variables to CharUnits in ConvertStructToPacked(). No change in
functionality intended.

llvm-svn: 127844
2011-03-18 00:55:06 +00:00
David Chisnall a9e5460f03 Remove code that was intentionally generating bad code on the GNU runtime for no reason (failing to emit .cxx_constructor / .cxx_destructor methods).
llvm-svn: 127806
2011-03-17 14:19:08 +00:00
Ken Dyck db205d1828 Convert NextOffsetInBytes to CharUnits and rename to NextOffsetInChars. No
change in functionality intended.

llvm-svn: 127787
2011-03-17 01:33:18 +00:00
Matt Beaumont-Gay 145e2eb0e3 Politely inform GCC that we will never fall off the end of that switch.
llvm-svn: 127783
2011-03-17 00:46:34 +00:00
Eli Friedman b6069255da PR9494: Get rid of bitcast which was both unnecessary and written incorrectly.
llvm-svn: 127768
2011-03-16 22:34:09 +00:00
David Chisnall 803adc1bcf Fix foreign exception handling (GNU runtime).
llvm-svn: 127736
2011-03-16 15:44:28 +00:00
John McCall e99e5dcbd3 Don't emit read barriers for reading __weak __block variables
in non-GC mode.

llvm-svn: 127725
2011-03-16 02:53:38 +00:00
John McCall 2de87f67e5 Reorganize the emission of (unfoldable) constant casts a bit, and
make sure that upcasts of member pointer types are covered as constants.
Fixed rdar://problem/9130221

llvm-svn: 127702
2011-03-15 21:17:48 +00:00
Sebastian Redl 0b94c9fb69 Reintroduce r127617: "Code generation for noexcept." with fixes.
llvm-svn: 127685
2011-03-15 18:42:48 +00:00
Ken Dyck 1c80fd1346 Introduce a CharUnits FieldOffsetInChars variable in AppendField() to
replace some uses of FieldOffsetInBytes. The remaining uses of
FieldOffsetInBytes will be replaced once NextFieldOffsetInBytes is converted
to CharUnits. No change in functionality intended.

llvm-svn: 127641
2011-03-15 01:09:02 +00:00
Jakob Stoklund Olesen fcaa2e1ba4 Revert r127617: "Code generation for noexcept."
The tests fail in a -Asserts build.

llvm-svn: 127635
2011-03-15 00:18:21 +00:00
Rafael Espindola 0c1f098284 Switch from internal to linker_private linkage, it is sufficient to please the new linker.
llvm-svn: 127622
2011-03-14 21:08:19 +00:00
Sebastian Redl 97022fd325 Code generation for noexcept.
llvm-svn: 127617
2011-03-14 20:33:20 +00:00
Eric Christopher cf5e83b471 __clear_cache() is varargs and people will occasionally write it without
arguments. Process only the arguments that people write, but process
all of them.

Fixes rdar://8900346

llvm-svn: 127616
2011-03-14 20:30:34 +00:00
Rafael Espindola 7a6cf01895 Fix link of libxul with LTO and the linker in xcode4. It is not clear if this
is working around a bug in ld or if the new linker has a reasonable reason
for wanting the string constant to be linker visible.

llvm-svn: 127594
2011-03-14 17:55:00 +00:00
David Chisnall f836b5bc3f Fix incorrect linkage specifiers for selectors.
llvm-svn: 127580
2011-03-14 15:01:16 +00:00
Sebastian Redl 31ad754c96 Instead of storing an ASTContext* in FunctionProtoTypes with computed noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall.
llvm-svn: 127568
2011-03-13 17:09:40 +00:00
Ken Dyck a862d95054 Use CharUnits for argument passed to AppendPadding() from AppendBitField().
No change in functionality intended.

llvm-svn: 127538
2011-03-12 12:03:11 +00:00
Sebastian Redl fa453cfdc3 Propagate the new exception information to FunctionProtoType.
Change the interface to expose the new information and deal with the enormous fallout.
Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications.
Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support.

llvm-svn: 127537
2011-03-12 11:50:43 +00:00
Ken Dyck 30a87e38d9 Change parameter to AppendPadding from bytes to CharUnits. No change in
functionality intended.

llvm-svn: 127513
2011-03-11 23:42:54 +00:00
John McCall 32ea969415 Use a slightly more semantic interface for emitting call arguments.
llvm-svn: 127494
2011-03-11 20:59:21 +00:00
Peter Collingbourne e190dee7a5 Add support for the OpenCL vec_step operator, by generalising and
extending the existing support for sizeof and alignof.  Original
patch by Guy Benyei.

llvm-svn: 127475
2011-03-11 19:24:49 +00:00
Ken Dyck 327b77a442 Convert the RecordSize parameter of AppendTailPadding() to CharUnits to
avoid converting to bits and back again. No change in functionality
intended.

llvm-svn: 127455
2011-03-11 02:17:05 +00:00
NAKAMURA Takumi dd63436808 lib/CodeGen/CGCall.cpp: Don't invoke multiple Builder.CreateBitCast() on Builder.CreateMemCpy. Or we would see sideeffect incompatibility among gcc and clang.
llvm-svn: 127405
2011-03-10 14:02:21 +00:00
Abramo Bagnara 29c2d46786 Fixed InnerLocStart.
llvm-svn: 127330
2011-03-09 14:09:51 +00:00
John McCall 85915250c0 Remove a rather egregious use of getFunctionInfo.
llvm-svn: 127324
2011-03-09 08:39:33 +00:00
John McCall 46288eff24 Fix three of the four places where I left breadcrumbs to avoid unnecessary
recomputation.

llvm-svn: 127322
2011-03-09 08:12:35 +00:00
John McCall 5fe009660d Tame this assert, hopefully fixing self-host.
llvm-svn: 127319
2011-03-09 07:12:35 +00:00
John McCall a738c25f5e Use the "undergoes default argument promotion" bit on parameters to
simplify the logic of initializing function parameters so that we don't need
both a variable declaration and a type in FunctionArgList.  This also means
that we need to propagate the CGFunctionInfo down in a lot of places rather
than recalculating it from the FAL.  There's more we can do to eliminate
redundancy here, and I've left FIXMEs behind to do it.

llvm-svn: 127314
2011-03-09 04:27:21 +00:00
John McCall 5c8f6c47c4 Emit block capture initializers as if they were normal initializers for a local
variable that just happens to be stored in a wierd place.

llvm-svn: 127235
2011-03-08 09:38:48 +00:00
John McCall 91ca10fe64 Extract a function to emit an arbitrary expression as if it were the initializer
for a local variable.

llvm-svn: 127227
2011-03-08 09:11:50 +00:00
Abramo Bagnara dff1930bf7 Fixed source range for all DeclaratorDecl's.
llvm-svn: 127225
2011-03-08 08:55:46 +00:00
Bill Wendling ec9d2633f1 When we adjust the inline ASM type, we need to take into account an early
clobber with the 'y' constraint. Otherwise, we get the wrong return type and an
assert, because it created a '<1 x i64>' vector type instead of the x86_mmx
type.

llvm-svn: 127185
2011-03-07 22:47:14 +00:00
Devang Patel 6e40c61596 CodeGenFunction::GenerateBlockFunction() should initialize DebugInfo just like CodeGenFunction::GenerateCode()
llvm-svn: 127174
2011-03-07 21:53:18 +00:00
Devang Patel d6ffebb077 DebugInfo can be enabled or disabled at function level (e.g. using an attribute). However, at module level it is determined by command line option and the state of command line option does not change during compilation. Make this layering explicit and fix accidental cases where the code generator was checking whether module has debug info enabled instead of checking whether debug info is enabled for this function or not.
llvm-svn: 127165
2011-03-07 18:45:56 +00:00
Devang Patel e65982c8c8 Do not emit stop point for CXXDefaultArgExpr. It results in suboptimial user experience.
21 int main() {
22  A a;

For example, here user would expect to stop at line 22, even if A's constructor leads to a call through CXXDefaultArgExpr.

This fixes ostream-defined.exp regression from gdb testsuite.

llvm-svn: 127164
2011-03-07 18:29:53 +00:00
John McCall 75f9498a7c The conditional needs to be pushed before the branch. Make the test less
trivial to check this.  Adjust for style.

llvm-svn: 127151
2011-03-07 03:12:35 +00:00
John McCall f7dcf320a7 An operator new with an empty exception specifier returns null on a bad
allocation and therefore requires a null-check.  We were doing that, but
we weren't treating the new-initializer as being conditionally executed,
which means it was possible to get ill-formed IR as in PR9298.

llvm-svn: 127147
2011-03-07 01:52:56 +00:00
Douglas Gregor 19da4e4397 Revert r126422 "Use private linkage to avoid symbol conflicts in
corner cases like the one in PR9301." which caused PR9416. 

llvm-svn: 127136
2011-03-06 23:28:21 +00:00
Anders Carlsson 829c4134b8 Correctly unwrap 'auto' types. Fixes PR9414.
llvm-svn: 127121
2011-03-06 16:43:04 +00:00
Benjamin Kramer 0cd19fbfdf StringRefify.
llvm-svn: 127082
2011-03-05 13:45:23 +00:00
Bill Wendling 6c9540e92b Initialize variable.
llvm-svn: 127039
2011-03-04 21:46:03 +00:00
Devang Patel d3a6b0f184 Emit a stop point before a call expression so that debugger has some chance of getting some footing when user wants to stop at 2nd bar() in following expression when all function calls are inlined.
= bar() + ... + bar() + ...

clang keeps track of column numbers, so we could put location entries for all subexpressions but that will significantly bloat debug info in general, but a location for call expression is helpful here.

llvm-svn: 127018
2011-03-04 18:54:42 +00:00
John McCall 74186ab391 Access ivars with inbounds GEPs, even in -fwrapv. It's unlikely that
this can have any optimization effect, given the opacity of objects pointers,
but you never know.

llvm-svn: 126990
2011-03-04 08:25:59 +00:00
John McCall 6647584951 Let's do super message sends with static allocas instead of dynamic ones.
llvm-svn: 126989
2011-03-04 08:00:29 +00:00
John McCall 4223a9ee7a Make AttributedTypes for GC-qualified types and fix some miscellaneous
bugs with such types.  Not sure this is quite how I want the desugaring
and a.k.a. logic to go, but it suffices.

llvm-svn: 126986
2011-03-04 04:00:19 +00:00
Devang Patel 68a1525290 Encode argument numbering in debug info so that code generator can emit them in order.
This fixes few blocks.exp regressions.

llvm-svn: 126960
2011-03-03 20:13:15 +00:00
Dan Gohman 6ca9982757 Fix a typo.
llvm-svn: 126890
2011-03-02 22:39:34 +00:00
Tilmann Scheller 99cc30c371 Revert "Add CC_Win64ThisCall and set it in the necessary places."
This reverts commit 126863.

llvm-svn: 126886
2011-03-02 21:36:49 +00:00
Benjamin Kramer 0f074df979 Only emit string initializers in-place if types match. Fixes PR9373.
llvm-svn: 126883
2011-03-02 21:27:44 +00:00
Tilmann Scheller e60baf731b Revert "Add preliminary support for MSVC-style vtables."
This reverts commit 126865.

llvm-svn: 126876
2011-03-02 20:40:50 +00:00
Devang Patel bd6f7f9770 revert r126858.
llvm-svn: 126874
2011-03-02 20:31:22 +00:00
Fariborz Jahanian ff9890302c IRGen. Fix IR when message returns reference type.
// rdar://8604515.

llvm-svn: 126869
2011-03-02 20:09:49 +00:00
Tilmann Scheller a6c995dbb2 Add preliminary support for MSVC-style vtables.
llvm-svn: 126865
2011-03-02 19:38:28 +00:00
Tilmann Scheller 454464b491 Add CC_Win64ThisCall and set it in the necessary places.
llvm-svn: 126863
2011-03-02 19:36:23 +00:00
Devang Patel 31e5fb52d1 Encode argument numbering in debug info so that code generator can emit them in order.
This fixes few blocks.exp regressions.

Reapply r126795 with a fix (one character change) for gdb testsuite regressions.

llvm-svn: 126858
2011-03-02 19:11:22 +00:00
Devang Patel a54696de8a Revert r126794.
llvm-svn: 126848
2011-03-02 17:54:58 +00:00
John McCall 81a325e038 Hack in something so that we emit better debug information about
captured __block variables in the block-literal type.

llvm-svn: 126834
2011-03-02 06:57:14 +00:00
Eli Friedman 846ded2e53 PR9350: increment/decrement of char (and anything else narrower than int)
can't overflow due to promotion rules; emit a wrapping add for those cases.

llvm-svn: 126816
2011-03-02 01:49:12 +00:00
Devang Patel 3bc2dedb40 Encode argument numbering in debug info so that code generator can emit them in order.
This fixes few blocks.exp regressions.

llvm-svn: 126795
2011-03-01 22:59:40 +00:00
Fariborz Jahanian cf7f66f16f objc IRGen for Next runtime message API.
The prototype for objc_msgSend() is technically variadic - 
`id objc_msgSend(id, SEL, ...)`. 
But all method calls should use a prototype that matches the method, 
not the prototype for objc_msgSend itself().
// rdar://9048030

llvm-svn: 126754
2011-03-01 17:28:13 +00:00
Chris Lattner 2e72da947c -fwrapv should turn off the inbounds markers from geps used for pointer
arithmetic.  This is part of PR9256, it would be great if someone else
wired up -fno-strict-overflow in the driver to -fwrapv.

llvm-svn: 126718
2011-03-01 00:03:48 +00:00