Commit Graph

2133 Commits

Author SHA1 Message Date
Chris Lattner 2bb5cb490c reimplement codegen for indirect goto with the following advantages:
1. CGF now has fewer bytes of state (one pointer instead of a vector).
2. The generated code is determinstic, instead of getting labels in
   'map order' based on pointer addresses.
3. Clang now emits one 'indirect goto switch' for each function, instead
   of one for each indirect goto.  This fixes an M*N = N^2 IR size issue
   when there are lots of address-taken labels and lots of indirect gotos.
4. This also makes the default cause do something useful, reducing the
   size of the jump table needed (by one).

llvm-svn: 83952
2009-10-13 06:55:33 +00:00
Chris Lattner 92ae16b0ae number address-taken labels from 1. This allows 0 to be used as a sentinel
for a null pointer.  In other words, "&&foo != NULL" will always work out to
true.

llvm-svn: 83948
2009-10-13 06:04:29 +00:00
Chris Lattner dd7eaad7d4 Use the new Type::getInt8PtrTy method. This should probably be used in a lot
more places in clang codegen now.

llvm-svn: 83947
2009-10-13 06:02:42 +00:00
Devang Patel 5b294f4330 Enable "debug info attached to an instruction" mode.
llvm-svn: 83928
2009-10-12 23:31:25 +00:00
Devang Patel dac79decf3 There is no need to attach debug location info with alloca instruction.
llvm-svn: 83913
2009-10-12 22:29:02 +00:00
Devang Patel 551e112e99 Encode long double.
llvm-svn: 83912
2009-10-12 22:28:31 +00:00
Anders Carlsson 1d116976b4 Store the key function of a record decl inside CGRecordLayout.
llvm-svn: 83900
2009-10-12 21:16:22 +00:00
Anders Carlsson a1b54fdbe1 Even more devirtualization cleverness.
llvm-svn: 83886
2009-10-12 19:59:15 +00:00
Anders Carlsson 2a01709204 More devirtualization improvements.
llvm-svn: 83883
2009-10-12 19:51:33 +00:00
Anders Carlsson b61301f353 Devirtualize calls on temporaries. A().f() for example.
llvm-svn: 83882
2009-10-12 19:45:47 +00:00
Anders Carlsson d7432dfb0a Factor out devirtualization checking into a separate function and make it handle references correctly.
llvm-svn: 83880
2009-10-12 19:41:04 +00:00
Anders Carlsson b5296558f1 If the base type of a member call is a record type we don't need to emit a virtual call.
llvm-svn: 83816
2009-10-11 23:55:52 +00:00
Benjamin Kramer bb0a07bf92 Remove dead variable.
llvm-svn: 83808
2009-10-11 22:57:54 +00:00
Benjamin Kramer 2e8301dd62 Add CGVtable.cpp to CMakeLists.
llvm-svn: 83800
2009-10-11 22:22:38 +00:00
Anders Carlsson 2bb27f53e0 Move the vtable builder to CGVtable.cpp, general cleanup.
llvm-svn: 83798
2009-10-11 22:13:54 +00:00
Anders Carlsson 2295f31810 Change mangleCXXVtable and mangleCXXRtti to take CXXRecordDecls instead of QualTypes.
llvm-svn: 83793
2009-10-11 21:24:51 +00:00
Anders Carlsson 6ce51fdf43 Move our (non-existing) RTTI emission code into CGRtti.cpp. No functionality change.
llvm-svn: 83732
2009-10-10 20:49:04 +00:00
Fariborz Jahanian 07ca72725a Generate weak read barriers when reading a weak __block
variable inside the block.

llvm-svn: 83729
2009-10-10 20:07:56 +00:00
Devang Patel 3028a43f57 Revert 83567.
llvm-svn: 83676
2009-10-09 22:06:15 +00:00
Mike Stump fc8ff639cb Allow customization for the producer information in the debug output.
llvm-svn: 83659
2009-10-09 18:38:12 +00:00
Mike Stump 0d479e6653 Avoid warning.
llvm-svn: 83609
2009-10-09 01:25:47 +00:00
Douglas Gregor 01249503fe Installation of Clang libraries and headers, from Axel Naumann!
llvm-svn: 83582
2009-10-08 22:15:31 +00:00
Devang Patel abf71fa9fc Record location info before emiting alloca for arguments. This allows arguments to have proper location info.
llvm-svn: 83567
2009-10-08 18:53:37 +00:00
Anders Carlsson a18ed9b113 If a global initializer has a non-trivial constructor or destructor, we never want to defer generation of it, even if it is declared static.
With this change we're finally able to compile and run the (infamous)

#include <string>
#include <iostream>

int main(int argc, char **argv) {
  std::cout << "Hello, World" << std::endl;
}

$ clang hello.cpp -lstdc++ -o hello
$ ./hello 
Hello, World

llvm-svn: 83559
2009-10-08 17:28:59 +00:00
Anders Carlsson 3482b819db Mangle std::basic_ostream<char, std::char_traits<char>> as So.
llvm-svn: 83557
2009-10-08 17:20:26 +00:00
Anders Carlsson 1e39bd944b Mangle anonymous structs/unions correctly. Fixes PR5139.
llvm-svn: 83448
2009-10-07 01:45:02 +00:00
Anders Carlsson ff971e8bf4 Add a MangleContext and pass it to all mangle functions. It will be used for keeping state, such as identifiers assigned to anonymous structs as well as scope encoding.
llvm-svn: 83442
2009-10-07 01:06:45 +00:00
Anders Carlsson b703fd2216 Uncomment some commented out code.
llvm-svn: 83428
2009-10-06 23:02:00 +00:00
Anders Carlsson c6d171ec77 Change GetAddressCXXOfBaseClass to use CXXBasePaths for calculating base class offsets. Fix the code to handle virtual bases as well.
llvm-svn: 83426
2009-10-06 22:43:30 +00:00
Anders Carlsson 11d00cf972 When mangling names, always use the canonical decl. Fixes PR5144.
llvm-svn: 83420
2009-10-06 21:58:01 +00:00
Devang Patel 542ab5f551 InsertSubprogramStart if ATTACH_DEBUG_INFO_TO_AN_INSN is not defined.
llvm-svn: 83419
2009-10-06 21:53:41 +00:00
Devang Patel 5d90d62701 Add support to attach debug info to an instruction.
This is not yet enabled.

llvm-svn: 83399
2009-10-06 18:36:08 +00:00
Anders Carlsson 6b7378bbe1 Emit the destructor epilogue in a cleanup block so a return from a destructor body still calls the epilogue.
llvm-svn: 83397
2009-10-06 18:09:57 +00:00
Anders Carlsson 80ef6f1a46 Pass the right type to GetAddrOfFunction when getting functions for the VTable. Fixes PR5021.
llvm-svn: 83395
2009-10-06 17:54:23 +00:00
Devang Patel faf7e9ad24 Set appropriate context for a global variable while emitting debug info.
llvm-svn: 83352
2009-10-06 00:35:31 +00:00
Mike Stump 916c006735 Fix thinko and simplify.
llvm-svn: 83342
2009-10-05 23:08:21 +00:00
Mike Stump 3472ae5bac Ensure we have atleast 2-byte alignment for member functions.
llvm-svn: 83337
2009-10-05 22:49:20 +00:00
Mike Stump c5e153c50e Respect alignments better.
llvm-svn: 83328
2009-10-05 21:58:44 +00:00
Benjamin Kramer dde0fee82e Use new predicates for some type equality tests.
llvm-svn: 83303
2009-10-05 13:47:21 +00:00
Anders Carlsson d5931cd2b7 Pass the canonical method decl to GetVtableIndex. Fixes PR5120.
llvm-svn: 83272
2009-10-03 19:56:56 +00:00
Anders Carlsson 2ee3c011d9 Implement code generation of member function pointer calls. Fixes PR5121.
llvm-svn: 83271
2009-10-03 19:43:08 +00:00
Anders Carlsson c46bf276e1 Teach AggExprEmitter about pointers to member functions.
llvm-svn: 83266
2009-10-03 15:43:24 +00:00
Anders Carlsson 3162e4945a Handle base-to-derived casts of member function pointers in CGExprConstant.cpp
llvm-svn: 83265
2009-10-03 15:13:22 +00:00
Anders Carlsson 128a5d5147 Handle members to function pointers in CGExprConstant.
llvm-svn: 83264
2009-10-03 15:02:02 +00:00
Anders Carlsson 32bfb1ce8f Move some functions from CodeGenFunctions to CodeGenModule so they can be used by CGExprConstant.
llvm-svn: 83263
2009-10-03 14:56:57 +00:00
Anders Carlsson 8a744ad8a6 Don't update the struct alignment when adding fields to a packed struct. Fixes PR5118.
llvm-svn: 83235
2009-10-02 04:52:12 +00:00
Mike Stump 581b9ad124 More magic pixie dust.
llvm-svn: 83232
2009-10-02 02:30:50 +00:00
Mike Stump 440af3d903 Fix up debug information for block pointers a bit more.
llvm-svn: 83231
2009-10-02 02:23:37 +00:00
Anders Carlsson 39e3eb12ae When building constant structs, check if the resulting LLVM struct will be bigger than the record layout size and use a packed struct if that's the case. Fixes PR5108.
llvm-svn: 83230
2009-10-02 02:15:20 +00:00
Mike Stump 017460ab6c Implement a FIXME. This improves codegen just a tad.
llvm-svn: 83221
2009-10-01 22:29:41 +00:00