Commit Graph

211 Commits

Author SHA1 Message Date
John McCall 7a9aac2d9f Abstract out everything having to do with member pointers into the ABI
class;  they should just be completely opaque throughout IR gen now,
although I haven't really audited that.

Fix a bug apparently inherited from gcc-4.2 where we failed to null-check
member data pointers when performing derived-to-base or base-to-derived
conversions on them.

llvm-svn: 111789
2010-08-23 01:21:21 +00:00
John McCall 614dbdcd55 Go back to asking CodeGenTypes whether a type is zero-initializable.
Make CGT defer to the ABI on all member pointer types.
This requires giving CGT a handle to the ABI.
It's way easier to make that work if we avoid lazily creating the ABI.
Make it so.

llvm-svn: 111786
2010-08-22 21:01:12 +00:00
John McCall a1dee5300b Experiment with using first-class aggregates to represent member function
pointers.  I find the resulting code to be substantially cleaner, and it
makes it very easy to use the same APIs for data member pointers (which I have
conscientiously avoided here), and it avoids a plethora of potential
inefficiencies due to excessive memory copying, but we'll have to see if it
actually works.

llvm-svn: 111776
2010-08-22 10:59:02 +00:00
John McCall 1c456c89dc Abstract out member-pointer creation. I'm really unhappy about the current
duplication between the constant and non-constant paths in all of this.

Implement ARM ABI semantics for member pointer constants and conversion.

llvm-svn: 111772
2010-08-22 06:43:33 +00:00
John McCall 84fa510aa9 Abstract more member-pointerness out.
llvm-svn: 111771
2010-08-22 04:16:24 +00:00
Eli Friedman 04831926ec Detabify.
llvm-svn: 111768
2010-08-22 01:00:03 +00:00
Daniel Dunbar b1d94a98dd IRgen: Eliminate EmitPredefinedFunctionName(), it doesn't need to be factored out.
llvm-svn: 111715
2010-08-21 03:01:12 +00:00
John McCall cf14216509 Store inheritance paths after CastExprs instead of inside them.
This takes some trickery since CastExpr has subclasses (and indeed,
is abstract).

Also, smoosh the CastKind into the bitfield from Expr.

Drops two words of storage from Expr in the common case of expressions
which don't need inheritance paths.  Avoids a separate allocation and
another word of overhead in cases needing inheritance paths.  Also has
the advantage of not leaking memory, since destructors for AST nodes are
never run.

llvm-svn: 110507
2010-08-07 06:22:56 +00:00
Eli Friedman 3ee1022f37 Fix crash initializing a bit-field with a non-constant in a place where we
try to evaluate the initializer as a constant.

llvm-svn: 108632
2010-07-17 23:55:01 +00:00
Chris Lattner 53b479ff6a fix PR7564 a cast where the bitfield struct init code
wasn't handling array padding elements right.

llvm-svn: 107621
2010-07-05 18:03:30 +00:00
Chris Lattner 9a3459f1a6 AppendBitField really can never fail, so return its return value.
Everyone knows that no bugs are ever possible with bitfields.

llvm-svn: 107620
2010-07-05 17:04:23 +00:00
Chris Lattner fa20e95043 use more efficient type comparison predicates.
llvm-svn: 106958
2010-06-26 21:52:32 +00:00
Anders Carlsson bcb2e4cb63 Don't try to explicitly zero out bit-fields.
llvm-svn: 105391
2010-06-03 15:36:07 +00:00
Eli Friedman c8731be34d Fix for PR7040: Don't try to compute the LLVM type for a function where it
isn't possible to compute.

This patch is mostly refactoring; the key change is the addition of the code
starting with the comment, "Check whether the function has a computable LLVM
signature."  The solution here is essentially the same as the way the
vtable code handles such functions.

llvm-svn: 105151
2010-05-30 06:03:20 +00:00
Anders Carlsson da265b8d63 When null-initializing bases with data member pointers, don't assert on virtual bases. Just initialize them to null.
llvm-svn: 104868
2010-05-27 18:51:01 +00:00
Anders Carlsson be48c548c5 Correctly initialize bases with member pointers. This should fix PR6441 but that test case is a bit weird and I'd like to investigate further before closing that bug.
llvm-svn: 104025
2010-05-18 16:51:41 +00:00
Anders Carlsson 1cf9274a5a Move ContainsPointerToDataMember to CodeGenTypes. No functionality change.
llvm-svn: 103792
2010-05-14 19:41:56 +00:00
Anders Carlsson 3572d44190 When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
llvm-svn: 102921
2010-05-03 16:05:06 +00:00
Anders Carlsson 795213efde Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to use the new version.
llvm-svn: 102274
2010-04-24 21:27:51 +00:00
Nuno Lopes 247a138ec6 recommit r101568 to fix PR6766
as a side-effect, remove two FIXMEs now fixed

llvm-svn: 101726
2010-04-18 19:06:43 +00:00
Anders Carlsson 11e5140db9 Vtable -> VTable renames across the board.
llvm-svn: 101666
2010-04-17 20:15:18 +00:00
Chris Lattner b714a4b4a0 revert r101568, which miscompiles this testcase, distilled from ldecod:
void exit_picture()
{
  char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
  foo(yuv_types);
}

llvm-svn: 101623
2010-04-17 06:53:44 +00:00
Nuno Lopes 74b595256a fix PR6766: codegen of var initialized with wide char
llvm-svn: 101568
2010-04-16 23:19:41 +00:00
Chris Lattner 3cff64ab58 fix a bogus assertion exposed by a recent change: packing the
struct may cause it to shrink more than one byte.  Before
my recent changes we compiled the new test into:

%0 = type { [6 x i8] }
@x = global %0 { [6 x i8] undef }, align 2        ; <%0*> [#uses=0]

which is obviously bogus.  Now we compile it into:

%0 = type <{ i32, i8, i8 }>
@x = global %0 zeroinitializer, align 2           ; <%0*> [#uses=0]

Where the last byte only is tail padding.

llvm-svn: 101536
2010-04-16 21:02:32 +00:00
Nuno Lopes 5863c999e7 emit padding as undef values, take 2
merge also a few tests I had here for this feature, and FileCheck'ize one file

llvm-svn: 101535
2010-04-16 20:56:35 +00:00
Chris Lattner ff0e2a36e2 Rework the ConstStructBuilder code to emit missing initializer
elements with explicit zero values instead of with tail padding.
On an example like this:

struct foo { int a; int b; };

struct foo fooarray[] = {
    {1, 2},
    {4},
};

We now lay this out as:

@fooarray = global [2 x %struct.foo] [%struct.foo { i32 1, i32 2 }, %struct.foo { i32 4, i32 0 }]

instead of as:

@fooarray = global %0 <{ %struct.foo { i32 1, i32 2 }, %1 { i32 4, [4 x i8] zeroinitializer } }>

Preserving both the struct type of the second element, but also the array type of the entire thing.

llvm-svn: 101155
2010-04-13 18:16:19 +00:00
Chris Lattner cfa3e7ae6a move a bunch of ConstStructBuilder methods out of line.
llvm-svn: 101152
2010-04-13 17:45:57 +00:00
Chris Lattner 933f67887f fix PR6660/6168: emit padding as zeros instead of undef. Because
trailing fields may not be represented in initializer lists, they
are being handled as padding and those fields *must* be zero 
initialized.

llvm-svn: 101067
2010-04-12 21:10:05 +00:00
Daniel Dunbar 034299ef25 IRGen: Move the auxiliary data structures tracking AST -> LLVM mappings out of CodeGenTypes, to per-record CGRecordLayout structures.
- I did a cursory check that this was perf neutral, FWIW.

llvm-svn: 99978
2010-03-31 01:09:11 +00:00
Daniel Dunbar 072d0bb247 IRgen: Move CGRecordLayout to its own happy little file.
llvm-svn: 99945
2010-03-30 22:26:10 +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
Rafael Espindola bef98689ad really fix 6473 by handling weakref in constant expressions.
llvm-svn: 97750
2010-03-04 21:26:03 +00:00
Chris Lattner c55042c20f hopefully silence a warning on the clang-i386-darwin9 tester.
llvm-svn: 95812
2010-02-10 21:41:43 +00:00
Anders Carlsson 6d0e5bd8f3 Use the right type when taking the address of a non-virtual member function pointer. Fixes PR6258.
llvm-svn: 95524
2010-02-07 17:37:13 +00:00
Anders Carlsson cb86e1088a Fix the bug that was breaking self-host, and re-land the static ctor fixes.
llvm-svn: 95400
2010-02-05 18:38:45 +00:00
Douglas Gregor af77cd220a Revert r95363 and r95375, which broke self-host.
llvm-svn: 95389
2010-02-05 16:18:08 +00:00
Anders Carlsson 893555ce66 Fix array initialization test.
llvm-svn: 95375
2010-02-05 07:00:11 +00:00
Anders Carlsson ecac409cb0 If a global initializer has a non-trivial destructor it can't be emitted as a constant (even if it has a trivial constructor).
llvm-svn: 95363
2010-02-05 05:19:42 +00:00
Anders Carlsson 7914dad72d Calculate offset correctly when taking the address of a virtual member function.
llvm-svn: 95305
2010-02-04 16:38:05 +00:00
Daniel Dunbar 45858d2d59 Revert "Numerous changes to selector handling:", this breaks a whole bunch of
working code, for no apparent reason.

llvm-svn: 95244
2010-02-03 20:11:42 +00:00
David Chisnall 92b762e256 Numerous changes to selector handling:
- Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon.  This also simplifies the code generated by the GNU runtime a bit.  

- Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant.

- Recognise @selector() expressions as valid static initialisers (as GCC does).

- Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants.  These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load.

- Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector.  This is needed for generating typed selectors from @selector() expressions (as GCC does).  Ideally, this information should be stored in the Selector, but that would be an invasive change.  We should eventually add checks for common uses of @selector() expressions.  Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this:

- (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL)
           withObject: (id)object;

Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature.  We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes.

- Made @selector() expressions emit type info if available and the runtime supports it.

Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac.  This currently just assert()s.

llvm-svn: 95189
2010-02-03 02:09:30 +00:00
Chandler Carruth 173bfe477b Use the Arg variable rather than re-computing it. This also silences GCC's
unused variable warning.

llvm-svn: 95085
2010-02-02 12:15:55 +00:00
John McCall 49786a6c31 Codegen CXXConstructExprs with trivial constructors as constants.
Eliminates a lot of spurious global initializers, fixing PR6205.

llvm-svn: 95077
2010-02-02 08:02:49 +00:00
Anders Carlsson e8bfe412ec Improve handling of emitting 'null' pointers to data members.
llvm-svn: 95066
2010-02-02 05:17:25 +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 84673e200f Some class related cleanup.
llvm-svn: 94938
2010-01-31 01:36:53 +00:00
David Chisnall 481e3a87fe Created __builtin___NSStringMakeConstantString() builtin, which generates constant Objective-C strings.
llvm-svn: 94274
2010-01-23 02:40:42 +00:00
Ken Dyck 02990837ad Convert the type of the LValue offset variable in APValue to CharUnits, moving
the LValue-related methods of APValue out of line to avoid header file leaching.

llvm-svn: 93512
2010-01-15 12:37:54 +00:00
Anders Carlsson a0b025e40f When emitting member function pointers, use the canonical decl if the member function is virtual. Fixes PR5940.
llvm-svn: 92680
2010-01-05 05:04:05 +00:00
Eli Friedman c52a9367b3 Get rid of some unnecessary code.
llvm-svn: 92432
2010-01-02 23:43:59 +00:00