Anders Carlsson
d829a02514
Add a new GetAddressOfBaseClass overload that takes a base path and. Use it for derived-to-base casts.
...
llvm-svn: 102270
2010-04-24 21:06:20 +00:00
Douglas Gregor
914af2182b
Handle compound assignment expressions (i += j) as lvalues, which is
...
permitted in C++ but not in C. Fixes PR6900. Clang can now handle all
of Boost.Lambda's regression tests.
llvm-svn: 102170
2010-04-23 04:16:32 +00:00
John McCall
2e6567ae60
Call PerformCopyInitialization to properly initialize the exception temporary
...
in a throw expression. Use EmitAnyExprToMem to emit the throw expression,
which magically elides the final copy-constructor call (which raises a new
strict-compliance bug, but baby steps). Give __cxa_throw a destructor pointer
if the exception type has a non-trivial destructor.
llvm-svn: 102039
2010-04-22 01:10:34 +00:00
John McCall
bf814c79b6
I failed to notice that my last patch wasn't doing as much as it could
...
because EmitBranch actually clears the insert point. This version
actually accomplishes what I initially wanted.
llvm-svn: 101998
2010-04-21 11:18:06 +00:00
John McCall
2188696d98
Miscellaneous codegen cleanups. Mostly, don't create new basic blocks
...
just to save the current insertion state! This change significantly
simplifies the IR CFG in exceptions code.
llvm-svn: 101996
2010-04-21 10:05:39 +00:00
Anders Carlsson
91baecfeb3
Back out r101911 and see if it makes the bots happy.
...
llvm-svn: 101921
2010-04-20 18:05:10 +00:00
Anders Carlsson
6a0227df49
Fix a bug which triggered the assertion I added yesterday. Basically, when we initialize the vtable pointer for a virtual base, and there was another path from the most derived class to another base with the same class type, we would use the wrong base.
...
llvm-svn: 101911
2010-04-20 16:22:16 +00:00
Anders Carlsson
652758c3ec
Pass the nearest virtual base decl to InitializeVTablePointers. No functionality change right now.
...
llvm-svn: 101872
2010-04-20 05:22:15 +00:00
Fariborz Jahanian
7e9d52aaca
Variation of objc_copyStruct API generation when
...
property (atomic/nonatomic) is of aggregate type with
gc'able member objects) (NeXT runtime).
llvm-svn: 101156
2010-04-13 18:32:24 +00:00
Fariborz Jahanian
08b0f66d2e
Add support for objc_copyStruct to enforce
...
atomicity of aggregate properties in setter/getter
methods. wip.
llvm-svn: 101107
2010-04-13 00:38:05 +00:00
Benjamin Kramer
9e2e1c9024
Minor include pruning.
...
llvm-svn: 100007
2010-03-31 15:04:05 +00:00
Anders Carlsson
093bdff0c5
Factor emitting a call to a copy constructor out into a separate function.
...
llvm-svn: 99866
2010-03-30 03:27:09 +00:00
Anders Carlsson
b9fd57f198
Introduce a CXXTemporariesCleanupScope RAII object and use it to cleanup the temporaries code.
...
llvm-svn: 99865
2010-03-30 03:14:41 +00:00
Anders Carlsson
d589593c93
Reapply r99775 with a fix for a silly bug - we were setting the vtable pointer for all bases, even those without a vtable pointer :)
...
llvm-svn: 99777
2010-03-28 21:07:49 +00:00
Anders Carlsson
fcc9f91287
Looks like I broke self-host again :(.
...
llvm-svn: 99776
2010-03-28 20:55:21 +00:00
Anders Carlsson
74eab715ae
More improvements to setting the vtable pointer. We now no longer set the vtable pointer for non-virtual primary bases. We also do a pre-order traversal of the class hierarchy; this is necessary in order to get the right vbase offset offsets in base ctors/dtors.
...
llvm-svn: 99775
2010-03-28 20:34:31 +00:00
Anders Carlsson
e87fae9afa
Factor vtable pointer setting code out into a separate function.
...
llvm-svn: 99773
2010-03-28 19:40:00 +00:00
Anders Carlsson
1f9348c1fc
Simplify InitializeVtablePtrs in preparation of making it work with construction vtables.
...
llvm-svn: 99609
2010-03-26 04:39:42 +00:00
Anders Carlsson
b35ea55e2e
More vtable work; preparations for moving over to the new vtable layout code (finally).
...
llvm-svn: 99381
2010-03-24 03:57:14 +00:00
Anders Carlsson
95e0223baf
Remove old thunks code.
...
llvm-svn: 99374
2010-03-24 00:57:54 +00:00
Anders Carlsson
bad991dbfd
Add CodeGenFunction::GenerateThunk and implement it.
...
llvm-svn: 99365
2010-03-24 00:39:18 +00:00
Anders Carlsson
a864caff8c
Rename CGVtableInfo to CodeGenVTables in preparation of adding another VTableInfo class.
...
llvm-svn: 99250
2010-03-23 04:11:45 +00:00
Daniel Dunbar
fe06df4bf3
C++: Add support for -fno-use-cxa-atexit.
...
- So much typing, so little gain...
Also, rename the __cxx_global_initialization function just to match llvm-gcc.
llvm-svn: 99039
2010-03-20 04:15:41 +00:00
Daniel Dunbar
7572284f4f
IRgen: Inline GenerateCXXGlobal[VarDecl]InitFunc into sole caller.
...
llvm-svn: 99038
2010-03-20 04:15:29 +00:00
Chris Lattner
5cc15e058b
add framework for ARM builtins, Patch by Edmund Grimley Evans!
...
llvm-svn: 97656
2010-03-03 19:03:45 +00:00
John McCall
d4f4b7f5ee
Add proper target hooks for __builtin_extract_return_address and
...
__builtin_frob_return_address. The implementations for both are
still trivial in the default case.
llvm-svn: 97638
2010-03-03 04:15:11 +00:00
Blaine Garst
fc83aa04db
Unconditionally support block introspection data in a new field at the end
...
of the block descriptor field. This field is the ObjC style @encode
signature of the implementation function, and was to this point
conditionally provided in the block literal data structure. That
provisional support is removed.
Additionally, eliminate unused enumerations for the block literal flags field.
The first shipping ABI unconditionally set (1<<29) but this bit is unused
by the runtime, so the second ABI will unconditionally have (1<<30) set so
that the runtime can in fact distinguish whether the additional data is
present or not.
llvm-svn: 96989
2010-02-23 21:51:17 +00:00
John McCall
f8ff7b9fd1
Perform two more constructor/destructor code-size optimizations:
...
1) emit base destructors as aliases to their unique base class destructors
under some careful conditions. This is enabled for the same targets that can
support complete-to-base aliases, i.e. not darwin.
2) Emit non-variadic complete constructors for classes with no virtual bases
as calls to the base constructor. This is enabled on all targets and in
theory can trigger in situations that the alias optimization can't (mostly
involving virtual bases, mostly not yet supported).
These are bundled together because I didn't think it worthwhile to split them,
not because they really need to be.
llvm-svn: 96842
2010-02-23 00:48:20 +00:00
John McCall
b81884d347
More refactoring around constructor/destructor code generation.
...
Fix some bugs with function-try-blocks and simplify normal try-block
code generation.
This implementation excludes a deleting destructor's call to
operator delete() from the function-try-block, which I believe
is correct but which I can't find straightforward support for at
a moment's glance.
llvm-svn: 96670
2010-02-19 09:25:03 +00:00
John McCall
89b12b34f6
Extract out function-body code generation into its own method. No functionality
...
change.
llvm-svn: 96564
2010-02-18 03:17:58 +00:00
John McCall
347132b32f
IRgen optimization: cache the value of 'this' and 'vtt' instead of
...
repeatedly reloading from an alloca. We still need to create the alloca
for debug info purposes (although we currently create it in all cases
because of some abstraction boundaries that're hard to break down).
llvm-svn: 96403
2010-02-16 22:04:33 +00:00
Daniel Dunbar
d004918ccb
IRgen: Add CreateIRTemp, which creates a temporary alloca but with type converted "not-for-memory". Dunno a better name.
...
llvm-svn: 96374
2010-02-16 19:44:13 +00:00
John McCall
6ce747220a
When emitting complete destructors for classes with virtual bases, compute
...
the offset to the virtual bases statically inside of relying on the virtual
base offsets in the object's vtable(s). This is both more efficient and
sound against the destructor's manipulation of the vtables.
Also extract a few helper routines.
Oh and we seem to pass all tests with an optimized clang now.
llvm-svn: 96327
2010-02-16 04:15:37 +00:00
Daniel Dunbar
a7566f163a
IRgen: Add CreateMemTemp, for creating an temporary memory object for a particular type, and flood fill. - CreateMemTemp sets the alignment on the alloca correctly, which fixes a great many places in IRgen where we were doing the wrong thing.
...
- This fixes many many more places than the test case, but my feeling is we need to audit alignment systematically so I'm not inclined to try hard to test the individual fixes in this patch. If this bothers you, patches welcome!
PR6240.
llvm-svn: 95648
2010-02-09 02:48:28 +00:00
Anders Carlsson
cee2d2f016
Use the right linkage for static variables inside C++ inline functions.
...
llvm-svn: 95512
2010-02-07 02:03:08 +00:00
Daniel Dunbar
d0bc7b9d13
IRgen: Factor out EmitAggExprToLValue.
...
llvm-svn: 95416
2010-02-05 19:38:31 +00:00
Anders Carlsson
ae612d22ac
Rename StartConditionalBranch/FinishConditionalBranch to BeginConditionalBranch/EndConditionalBranch.
...
llvm-svn: 95308
2010-02-04 17:18:07 +00:00
Anders Carlsson
3b227bd629
Revert the new reference binding code; I came up with a way simpler solution for the reference binding bug that is preventing self-hosting.
...
llvm-svn: 95223
2010-02-03 16:38:03 +00:00
Anders Carlsson
259688ce29
Move pointer to data member emission to CodeGenModule and use it in CGExprConstant. Fixes PR5674.
...
llvm-svn: 95063
2010-02-02 03:37:46 +00:00
Anders Carlsson
ab0ddb57b1
Start creating CXXBindReferenceExpr nodes when binding complex types to references.
...
llvm-svn: 94964
2010-01-31 18:34:51 +00:00
Anders Carlsson
84673e200f
Some class related cleanup.
...
llvm-svn: 94938
2010-01-31 01:36:53 +00:00
Anders Carlsson
db78f0ad04
Add a new EmitLValueForFieldInitialization that will be used for initializing fields (and reference type fields in particular).
...
llvm-svn: 94799
2010-01-29 05:24:29 +00:00
Anders Carlsson
5d8645b150
Simplify EmitLValueForField - we can get whether the field is part of a union or not from the FieldDecl (through its DeclContext).
...
llvm-svn: 94798
2010-01-29 05:05:36 +00:00
Ken Dyck
5262b11962
Use CharUnits for alignments in character units.
...
llvm-svn: 94571
2010-01-26 19:13:33 +00:00
Anders Carlsson
60ddba67a8
Fix a nasty bug where temporaries weren't marked as being conditional in some cases.
...
llvm-svn: 94341
2010-01-24 00:20:05 +00:00
Ken Dyck
40775003e6
Roll out ASTContext::getTypeSizeInChars(), replacing instances of
...
"ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits
ones as appropriate.
Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType,
fromQuantity(), and getQuantity() for clarity.
llvm-svn: 93153
2010-01-11 17:06:35 +00:00
Chris Lattner
116ce8f172
refactor pre/postinc logic into CGF and require the caller to pass in the
...
lvalue to poke, no functionality change.
llvm-svn: 93075
2010-01-09 21:40:03 +00:00
Eli Friedman
5866fe306d
Fix for PR5967: Make const-marking for LLVM globals correct for cases requiring
...
run-time initialization, and emit run-time initializers aggresively to avoid
ordering issues with deferred globals.
llvm-svn: 92976
2010-01-08 00:50:11 +00:00
Eli Friedman
6257e08a3d
Get rid of more dead code.
...
llvm-svn: 92439
2010-01-03 01:11:47 +00:00
Anders Carlsson
93a1884fde
Move address points to CGVtableInfo, no functionality change.
...
llvm-svn: 92420
2010-01-02 18:02:32 +00:00
Anders Carlsson
e36a6b3e44
Correctly pass VTT parameters to constructors and destructors. The VTTs aren't yet used in the ctors/dtors, but that will follow.
...
llvm-svn: 92409
2010-01-02 01:01:18 +00:00
Anders Carlsson
bfb3671b25
Pass the return value slot to all call exprs.
...
llvm-svn: 92145
2009-12-24 21:13:40 +00:00
Anders Carlsson
1749083e2e
Fill in the return value slot in CGExprAgg::VisitCallExpr. This takes us halfway towards fixing PR5824.
...
llvm-svn: 92142
2009-12-24 20:40:36 +00:00
Anders Carlsson
61a401caec
Pass ReturnValueSlot to EmitCall. No functionality change yet.
...
llvm-svn: 92138
2009-12-24 19:25:24 +00:00
Anders Carlsson
0435ed5875
Add a ReturnValueSlot class. Change the argument order in EmitCall to match the other overload better.
...
llvm-svn: 92136
2009-12-24 19:08:58 +00:00
Eli Friedman
70724ad2ff
Work in progress for setting the vtable pointers for all bases correctly in
...
the constructor. This doesn't handle cases requiring the VTT at the moment,
and generates unnecessary stores, but I think it's essentially correct.
llvm-svn: 91731
2009-12-18 23:47:41 +00:00
Mike Stump
3f6f9febad
Implement additional undefined checks for additional loads and stores. WIP.
...
llvm-svn: 91498
2009-12-16 02:57:00 +00:00
Mike Stump
e8c3b3eca4
Switch codegen for -fcatch-undefined-bahavior over to __builtin_trap
...
instead of abort to improve codesize and codegen.
llvm-svn: 91374
2009-12-15 00:35:12 +00:00
Mike Stump
ba6a0c40c4
Add support for detecting undefined shift behavior. WIP.
...
llvm-svn: 91341
2009-12-14 21:58:14 +00:00
Mike Stump
d954638f02
Implement runtime checks for undefined behavior. WIP.
...
This implements a new flag -fcatch-undefined-behavior. The flag turns
on additional runtime checks for:
T a[I];
a[i] abort when i < 0 or i >= I.
Future stuff includes shifts by >= bitwidth amounts.
llvm-svn: 91198
2009-12-12 01:27:46 +00:00
Eli Friedman
d5bc94e2eb
Get rid of static variable.
...
llvm-svn: 91041
2009-12-10 02:21:21 +00:00
Mike Stump
f5cbb08c4b
Ensure we only generate one terminate handler.
...
llvm-svn: 90998
2009-12-10 00:02:42 +00:00
Mike Stump
102530719f
Add terminate handler to cleanups on exceptional edges.
...
llvm-svn: 90996
2009-12-09 23:49:53 +00:00
Fariborz Jahanian
531c16f9fb
Code gen for ObjCIsaExpr AST used as lvalue.
...
(fixes radar 7457534).
llvm-svn: 90995
2009-12-09 23:35:29 +00:00
Mike Stump
2b488873bf
Break out code for reuse. WIP.
...
llvm-svn: 90991
2009-12-09 22:59:31 +00:00
Mike Stump
aff69af918
Add cleanups for exceptional edges. WIP.
...
llvm-svn: 90940
2009-12-09 03:35:49 +00:00
Eli Friedman
bb5008a32a
Fix for PR5707: make sure implicit copy constructors initialize the vtable
...
pointer.
llvm-svn: 90840
2009-12-08 06:46:18 +00:00
Mike Stump
1d849219a5
Add codegen support for exception specifications. WIP.
...
llvm-svn: 90817
2009-12-07 23:38:24 +00:00
Chris Lattner
e99c110d06
implement rdar://7346691 by codegen'ing struct/array initializers
...
to a memset or a memcpy from a global when possible.
llvm-svn: 90658
2009-12-05 08:22:11 +00:00
Mike Stump
bee78dd31b
Add support for function try blocks.
...
llvm-svn: 90622
2009-12-04 23:26:17 +00:00
Eli Friedman
4b1942cb8b
Make functions returning a struct indirectly evaluate the returned struct
...
directly into the sret pointer. This is an optimization in C, but is required
for correctness in C++ for classes with a non-trivial copy constructor.
llvm-svn: 90526
2009-12-04 02:43:40 +00:00
Eli Friedman
551fe84d0e
Minor cleanup.
...
llvm-svn: 90411
2009-12-03 04:27:05 +00:00
Mike Stump
e2d4a2c3a8
Add support for thunking dtors. Oh why does this make my head hurt?
...
llvm-svn: 90409
2009-12-03 03:47:56 +00:00
Mike Stump
33270211a0
More exception handling improvements... WIP.
...
Highlights include:
Add a helper to generate __cxa_free_exception and _ZSt9terminatev.
Add a region to handle EH object deallocation for ctor failures for throw.
Add a terminate handler for __cxa_end_catch.
A framework for adding cleanup actions for the exceptional edges only.
llvm-svn: 90305
2009-12-02 07:41:41 +00:00
Mike Stump
e5311b0d79
Reflow comments and fix 80-col violation.
...
llvm-svn: 90152
2009-11-30 20:08:49 +00:00
Anders Carlsson
2f87c4f1a5
Add a CovariantThunkAdjustment struct that represents the adjustments needed for a covariant thunk.
...
llvm-svn: 89933
2009-11-26 03:09:37 +00:00
Anders Carlsson
c778540f9a
Add a ThunkAdjustment struct which holds a non-virtual and a virtual adjustment offset. Start using it. General cleanup in Mangle.cpp.
...
llvm-svn: 89925
2009-11-26 02:32:05 +00:00
Anders Carlsson
82ba57c8f0
Add VTT parameter to base ctors/dtors with virtual bases. (They aren't used yet).
...
llvm-svn: 89835
2009-11-25 03:15:49 +00:00
Douglas Gregor
7bab5ff8e7
Eliminate CXXConditionDeclExpr with extreme prejudice.
...
All statements that involve conditions can now hold on to a separate
condition declaration (a VarDecl), and will use a DeclRefExpr
referring to that VarDecl for the condition expression. ForStmts now
have such a VarDecl (I'd missed those in previous commits).
Also, since this change reworks the Action interface for
if/while/switch/for, use FullExprArg for the full expressions in those
expressions, to ensure that we're emitting
Note that we are (still) not generating the right cleanups for
condition variables in for statements. That will be a follow-on
commit.
llvm-svn: 89817
2009-11-25 00:27:52 +00:00
Douglas Gregor
680f861d74
Clean up the AST for while loops and fix several problems with
...
cleanups for while loops:
1) Make sure that we destroy the condition variable of a while statement each time through the loop for, e.g.,
while (shared_ptr<WorkInt> p = getWorkItem()) {
// ...
}
2) Make sure that we always enter a new cleanup scope for the body of the while loop, even when there is no compound expression, e.g.,
while (blah)
RAIIObject raii(blah+1);
llvm-svn: 89800
2009-11-24 21:15:44 +00:00
Anders Carlsson
3a202f601e
Handle cases where we're constructing an array of objects and the constructor has default arguments.
...
llvm-svn: 89783
2009-11-24 18:43:52 +00:00
Douglas Gregor
965f450d42
Introduce cleanup scopes for "if" statements in two places:
...
- Outside the "if", to ensure that we destroy the condition variable
at the end of the "if" statement rather than at the end of the
block containing the "if" statement.
- Inside the "then" and "else" branches, so that we emit then- or
else-local cleanups at the end of the corresponding block when the
block is not a compound statement.
To make adding these new cleanup scopes easier (and since
switch/do/while will all need the same treatment), added the
CleanupScope RAII object to introduce a new cleanup scope and make
sure it gets cleaned up.
llvm-svn: 89773
2009-11-24 16:43:22 +00:00
Douglas Gregor
48a409eb39
Rename CleanupScope -> DelayedCleanupBlock. No functionality change.
...
llvm-svn: 89769
2009-11-24 16:21:10 +00:00
Anders Carlsson
8c793172c2
Handle base-to-derived casts. Will land test case shortly.
...
llvm-svn: 89678
2009-11-23 17:57:54 +00:00
Anders Carlsson
0a66c26191
Fix lifetime of conditional temporaries. Patch by Victor Zverovich!
...
llvm-svn: 89467
2009-11-20 17:27:56 +00:00
Eli Friedman
794290ca29
Add an assertion to catch bad calls to EmitCallArgs.
...
llvm-svn: 89190
2009-11-18 03:42:04 +00:00
Eli Friedman
24f55430c8
Missing piece of r89173.
...
llvm-svn: 89174
2009-11-18 00:57:03 +00:00
Anders Carlsson
cfd3012756
More const is always good.
...
llvm-svn: 89033
2009-11-17 03:57:07 +00:00
Mike Stump
65511704f7
Implement most of dynamic_cast. WIP.
...
llvm-svn: 88901
2009-11-16 06:50:58 +00:00
Mike Stump
c9b231c8d1
Implement typeid for class types.
...
llvm-svn: 88843
2009-11-15 08:09:41 +00:00
Fariborz Jahanian
6814eaa2cc
Code gen for arrady delete operator. Fixes pr5472.
...
llvm-svn: 88680
2009-11-13 19:27:47 +00:00
Daniel Dunbar
1b4441915a
Wherein the TargetInfo argument to Preprocessor is made 'const' and propogated.
...
llvm-svn: 87087
2009-11-13 05:51:54 +00:00
Anders Carlsson
e828c36933
Add a special BuildVirtualCall that's going to be used for building calls to destructors. This is needed because when compiling:
...
struct A {
virtual ~A();
};
void f(A* a) {
delete a;
}
A's deleting destructor should be called.
llvm-svn: 87083
2009-11-13 04:45:41 +00:00
Fariborz Jahanian
1254a0978c
This patch implements Code gen. for destruction of
...
global array of objects.
llvm-svn: 86701
2009-11-10 19:24:06 +00:00
Mike Stump
d846d0825b
Add vtable caching to prevent multiple vtables for the same class from
...
being generated.
Add the most derived vtable pointer to the VTT.
llvm-svn: 86671
2009-11-10 07:44:33 +00:00
Mike Stump
9f23a149cb
Be sure to clear out VCall when we clear out VCalls.
...
Start implementing VTTs. WIP.
llvm-svn: 86650
2009-11-10 02:30:51 +00:00
Anders Carlsson
509850ebec
Change EmitPointerToDataMemberLValue to take a FieldDecl. No intended functionality change.
...
llvm-svn: 86407
2009-11-07 22:00:15 +00:00
Chris Lattner
4f24225e8e
indirectbr seems to work! Rip out the old code.
...
llvm-svn: 86256
2009-11-06 17:38:18 +00:00
Fariborz Jahanian
09cc10f9f8
This patch extends CleanupScope to support destruction
...
of array objects on block exit. Patch is by Anders Calrsson.
llvm-svn: 86032
2009-11-04 17:57:40 +00:00
Mike Stump
53f9ded62b
Refine volatile handling, specifically, we must have the canonical
...
type to look at the volatile specifier. I found these all from just
hand auditing the code.
llvm-svn: 85967
2009-11-03 23:25:48 +00:00