Ken Dyck
7ad11e70b6
Convert RecordLayout::Alignment to CharUnits from bit units. No change in
...
functionality intended.
llvm-svn: 125549
2011-02-15 02:32:40 +00:00
Ken Dyck
b0fcc59e19
Add a helper function, ASTContext::toBits(), that converts sizes in
...
CharUnits to sizes in bits, and use it to tidy up the places where the
conversion was done explicitly.
llvm-svn: 125332
2011-02-11 01:54:29 +00:00
Ken Dyck
89d9f360cd
Drop the 'InBits' part from the name of RecordSizeInBits as the value is in
...
character units.
llvm-svn: 125281
2011-02-10 12:36:29 +00:00
Ken Dyck
f18bf0d2e1
Eliminate some signed-to-unsigned comparision warnings introduced in
...
r125156.
llvm-svn: 125280
2011-02-10 12:20:05 +00:00
Ken Dyck
c8ae55050d
Convert RecordLayout::Size to CharUnits from bits. No changes to
...
functionality intended.
llvm-svn: 125156
2011-02-09 01:59:34 +00:00
Ken Dyck
bec0285d7f
Convert RecordLayout::NonVirtualAlign to CharUnits. No change in
...
functionality intended.
llvm-svn: 125069
2011-02-08 02:02:47 +00:00
Ken Dyck
316d6f69bc
Convert RecordLayout::NonVirtualSize from bit units to CharUnits.
...
llvm-svn: 124646
2011-02-01 01:52:10 +00:00
Argyrios Kyrtzidis
648fcbef5b
Fix another obscure corner layout case.
...
llvm-svn: 121436
2010-12-10 00:11:00 +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
bcd38217f3
CGRecordLayoutBuilder does not need to be exported from this module.
...
llvm-svn: 120489
2010-11-30 23:17:27 +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
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
4131f00a1f
Add CXXRecordDecl::getIndirectPrimaryBases.
...
llvm-svn: 120129
2010-11-24 22:50:27 +00:00
Anders Carlsson
6277615cbb
Simplify code.
...
llvm-svn: 120109
2010-11-24 19:57:04 +00:00
Anders Carlsson
36e2fa8209
CGRecordLayout types are always struct types.
...
llvm-svn: 120106
2010-11-24 19:37:16 +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
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
Anders Carlsson
fd88a6160d
Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset.
...
llvm-svn: 117881
2010-10-31 23:22:37 +00:00
Daniel Dunbar
c7f9bbafe4
IRgen: Move CGBitFieldInfo strategy computation helpers to static member
...
functions.
llvm-svn: 112913
2010-09-02 23:53:28 +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
Daniel Dunbar
401304462a
AST: Rename PragmaPackAttr to MaxFieldAlignmentAttr, which is more accurate.
...
llvm-svn: 104795
2010-05-27 01:12:46 +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
061ca524b7
Keep track of the LLVM field numbers for non-virtual bases.
...
llvm-svn: 104013
2010-05-18 05:22:06 +00:00
Anders Carlsson
af9e5afe54
Start laying out bases as individual fields. We still use ugly i8 arrays but this is a step in the right direction.
...
llvm-svn: 104012
2010-05-18 05:12:20 +00:00
Anders Carlsson
58fe1756fb
Use a more appropriate LLVM type for the vtable pointer.
...
llvm-svn: 103078
2010-05-05 05:47:36 +00:00
Daniel Dunbar
5981377698
IRgen: Fix another case where we generated an invalid access component when we
...
immediately narrowed the access size. Fix this (and previous case) by just
choosing a better access size up-front.
llvm-svn: 102068
2010-04-22 15:22:33 +00:00
Daniel Dunbar
5d6c07e0e9
IRgen: Fix case where we might generate an access component with width == 0, if
...
we have to narrow the access side immediately (can happen with packed,
-fno-bitfield-type-align).
llvm-svn: 102067
2010-04-22 14:56:10 +00:00
Daniel Dunbar
fc66e0ed87
IRgen: Set alignment correctly on bit-field accesses.
...
llvm-svn: 102046
2010-04-22 03:17:04 +00:00
Daniel Dunbar
488f55c271
IRgen: Rewrite bit-field access policy to not access data beyond the bounds of the structure, which we also now verify as part of the post-layout consistency checks.
...
- This fixes some pedantic bugs with packed structures, as well as major problems with -fno-bitfield-type-align.
- Fixes PR5591, PR5567, and all known -fno-bitfield-type-align issues.
- Review appreciated.
llvm-svn: 102045
2010-04-22 02:35:46 +00:00
Daniel Dunbar
b6f4b05914
IRgen: Fix CGRecordLayout::print to print the bit-field infos in a consistent order.
...
llvm-svn: 102044
2010-04-22 02:35:36 +00:00
Daniel Dunbar
2ba67440b6
IRgen: Add checking that the LLVM and AST record layout offsets agree (for
...
non-bit-fields).
llvm-svn: 102014
2010-04-21 19:10:49 +00:00
Daniel Dunbar
20b551a443
IRgen: Always use i8 arrays to access union bit-fields. This is ugly, but
...
matches how we currently handle structs, and this correctly handles
-fno-bitfield-type-align.
llvm-svn: 101918
2010-04-20 17:52:30 +00:00
Daniel Dunbar
ccabe48235
AST: Dump ASTRecordLayout objects when they are created with -fdump-record-layouts.
...
llvm-svn: 101815
2010-04-19 20:44:53 +00:00
Daniel Dunbar
2ea5183b59
IRgen: Kill unused function and move the type match assert to after record dumping.
...
llvm-svn: 101814
2010-04-19 20:44:47 +00:00
Anders Carlsson
d5f27b0583
Simplify wide bit-field layout in CGRecordLayoutBuilder, and also fix a bug where assigning to a bit-field member would overwrite other parts of the struct.
...
llvm-svn: 101681
2010-04-17 22:54:57 +00:00
Anders Carlsson
2295f13bb0
Unnamed bit-fields in a union should be laid out with a type that doesn't affect alignment.
...
llvm-svn: 101673
2010-04-17 21:04:52 +00:00
Anders Carlsson
1de2f5710b
Factor union field layout code out into a separate function. No functionality change.
...
llvm-svn: 101671
2010-04-17 20:49:27 +00:00
Anders Carlsson
11e5140db9
Vtable -> VTable renames across the board.
...
llvm-svn: 101666
2010-04-17 20:15:18 +00:00
Anders Carlsson
be6f3181dd
Make CGRecordLayoutBuilder deal with wide bit-fields. Will land tests shortly (Daniel, please review).
...
llvm-svn: 101472
2010-04-16 16:23:02 +00:00
Daniel Dunbar
9c78d63fbc
IRgen: Change CGBitFieldInfo to take the AccessInfo as constructor arguments, it is now an immutable object.
...
Also, add some checking of various invariants that should hold on the CGBitFieldInfo access.
llvm-svn: 101345
2010-04-15 05:09:32 +00:00
Daniel Dunbar
bb13845c5f
IRgen: Eliminate now unused fields from CGBitFieldInfo.
...
llvm-svn: 101344
2010-04-15 05:09:28 +00:00
Daniel Dunbar
b935b9370d
IRgen: Enhance CGBitFieldInfo with enough information to fully describe the "policy" with which a bit-field should be accessed.
...
- For now, these policies are computed to match the current IRgen strategy, although the new information isn't being used yet (except in -fdump-record-layouts).
- Design comments appreciated.
llvm-svn: 101178
2010-04-13 20:58:55 +00:00
Daniel Dunbar
f9c24f8403
IRgen: Factor out ComputeBitFieldInfo.
...
llvm-svn: 101066
2010-04-12 21:01:28 +00:00
Daniel Dunbar
b97bff9aa9
IRgen: Add CGRecordLayout::dump, and dump (irgen) record layouts as part of -fdump-record-layouts.
...
llvm-svn: 101051
2010-04-12 18:14:18 +00:00
Daniel Dunbar
c75c8bd757
IRgen: Move the bit-field access type into CGBitFieldInfo, and change bit-field LValues to just store the base address of object containing the bit-field.
...
llvm-svn: 100745
2010-04-08 02:59:45 +00:00
Daniel Dunbar
196ea449ed
IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.
...
llvm-svn: 100513
2010-04-06 01:07:44 +00:00
Daniel Dunbar
d45491077a
Simplify.
...
llvm-svn: 100512
2010-04-06 01:07:41 +00:00
Daniel Dunbar
cd3d5e76ce
IRgen: Lift BitFieldInfo to CGBitFieldInfo at namespace level.
...
llvm-svn: 100433
2010-04-05 16:20:44 +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
e75a64f2d3
CGRecordLayoutBuilder: Switch unions to use same mechanism for tracking field and bit-field info as structs.
...
- Anders, please check.
llvm-svn: 99977
2010-03-31 00:55:13 +00:00
Daniel Dunbar
23ee4b7710
IRGen: Hide CGRecordLayoutBuilder class, because I can.
...
llvm-svn: 99967
2010-03-31 00:11:27 +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
e8bfe412ec
Improve handling of emitting 'null' pointers to data members.
...
llvm-svn: 95066
2010-02-02 05:17:25 +00:00
Anders Carlsson
b1ef991097
Fix an incorrect union layout assert. Fixes PR6164.
...
llvm-svn: 94754
2010-01-28 18:22:03 +00:00
Anders Carlsson
d681a29ac0
Baby steps towards fixing PR5589. If a class needs a vtable pointer, add one.
...
llvm-svn: 91545
2009-12-16 17:27:20 +00:00
Anders Carlsson
220bf4fc5a
No need to add tail padding if the resulting LLVM struct type will have the same size as the final record size.
...
llvm-svn: 90820
2009-12-08 01:24:23 +00:00
Anders Carlsson
b1d3f7c909
Have ASTRecordLayout keep track of the key function, in preparation of fixing a synthetic ctor/dtor bug.
...
llvm-svn: 90168
2009-11-30 23:41:22 +00:00
Mike Stump
a7a1b7e780
Fixup key function calculations.
...
llvm-svn: 89412
2009-11-20 00:02:19 +00:00
Mike Stump
beab381d2d
This doesn't work yet.
...
llvm-svn: 89307
2009-11-19 03:53:54 +00:00
Fariborz Jahanian
e8e631c912
Prevent a code gen. crash on empty unions - pr5408.
...
llvm-svn: 86287
2009-11-06 20:47:40 +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
Mike Stump
11289f4280
Remove tabs, and whitespace cleanups.
...
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Anders Carlsson
0e91275ab4
If the alignment of the chosen field in a union is greater than the alignment of the union, we need to use a packed LLVM struct. Fixes <rdar://problem/7184250>.
...
llvm-svn: 80964
2009-09-03 22:56:02 +00:00
Anders Carlsson
09a3774cd3
Packed unions should be packed. Fixes an assert Daniel reported.
...
llvm-svn: 80808
2009-09-02 17:51:33 +00:00
Anders Carlsson
d606de72ab
More work towards zero-initializing structs that contain member pointers in constant expressions.
...
llvm-svn: 79805
2009-08-23 01:25:01 +00:00
Anders Carlsson
beac2bef4d
Remove the PaddingFields member from CGRecordLayout, it wasn't used anyway.
...
llvm-svn: 79799
2009-08-23 01:01:04 +00:00
Owen Anderson
41a750271b
Update for LLVM API change.
...
llvm-svn: 78946
2009-08-13 21:57:51 +00:00
Anders Carlsson
28a5fa29f3
Take #pragma pack into account when laying out structs. Fixes rdar://problem/7095436.
...
llvm-svn: 78490
2009-08-08 19:38:24 +00:00
Anders Carlsson
68e0b68289
Introduce a new PragmaPack attribute, and use it for #pragma pack. The PackedAttr now only represents __attribute__((packed)).
...
This is necessary because #pragma pack and __attribute__((packed)) have different semantics. No functionality change yet, but this lays the groundwork for fixing a record layout bug.
llvm-svn: 78483
2009-08-08 18:23:56 +00:00
Anders Carlsson
453878bed4
Assert that the LLVM type has the same size as the RecordDecl size.
...
llvm-svn: 78481
2009-08-08 18:01:57 +00:00
Owen Anderson
758428f4e3
Update for LLVM API change.
...
llvm-svn: 78259
2009-08-05 23:18:46 +00:00
Anders Carlsson
19702bb054
Simplify alignment handling in the record builder.
...
llvm-svn: 78069
2009-08-04 16:29:15 +00:00
Fariborz Jahanian
7be1ad814b
No longer need to keep base class offsets in the offset
...
table as it has its own place now.
llvm-svn: 77491
2009-07-29 18:50:06 +00:00
Anders Carlsson
d5d6413aa5
More CGRecordLayoutBuilder cleanup.
...
llvm-svn: 77335
2009-07-28 17:56:36 +00:00
Fariborz Jahanian
7b2b1ec6b1
Some minor changes toward support of data
...
member access in the presense of non-virtual bases.
llvm-svn: 77246
2009-07-27 20:57:45 +00:00
Anders Carlsson
72fb384a65
Enable the new struct type builder now that the constant struct builder works. (The old code will still be there until we know that everything works well.
...
llvm-svn: 77190
2009-07-27 15:31:55 +00:00
Anders Carlsson
b97a3ec4e7
Fix a tail padding bug in the record layout builder code. The bug was found by an existing test.
...
llvm-svn: 77189
2009-07-27 14:55:54 +00:00
Anders Carlsson
e1d5ca583f
Check in a half finished new constant struct builder (Obviously not used yet).
...
llvm-svn: 76969
2009-07-24 15:20:52 +00:00
Anders Carlsson
6e853bf2b7
Get rid of the size parameter to AppendField. No functionality change.
...
llvm-svn: 76931
2009-07-24 02:45:50 +00:00
Anders Carlsson
085395426c
Don't just store the field/bit field info one field, do it for all fields in the union.
...
llvm-svn: 76907
2009-07-23 22:52:34 +00:00
Anders Carlsson
e2accf4404
Fix another thinko.
...
llvm-svn: 76903
2009-07-23 21:52:03 +00:00
Anders Carlsson
516e5e7835
Correct a thinko in bitfield layout code. Fixes PR4611.
...
llvm-svn: 76898
2009-07-23 21:16:33 +00:00
Anders Carlsson
d78fc89fcb
We don't need to keep track of the packed alignment, just whether the struct is packed or not. Fixes PR4610.
...
llvm-svn: 76884
2009-07-23 17:24:40 +00:00
Anders Carlsson
8af896c10a
Move the LLVM field number for bit fields into the BitFieldInfo structure, since it's meaning is completely different than for non-bit fields.
...
llvm-svn: 76882
2009-07-23 17:01:21 +00:00
Anders Carlsson
f55922b8b8
Set field info for unions.
...
llvm-svn: 76856
2009-07-23 04:59:05 +00:00
Anders Carlsson
f814ee6003
Handle zero width bit fields in unions correctly (by ignoring them).
...
llvm-svn: 76847
2009-07-23 04:00:39 +00:00
Anders Carlsson
697f65943d
Implement union layout support.
...
llvm-svn: 76846
2009-07-23 03:43:54 +00:00
Anders Carlsson
307846fe67
Check in CGRecordLayoutBuilder which is a reimplementation of the record layout code. (Yay, no more packed structs unless absolutely necessary). We currently don't use the layouts being built but that will change when the new code is mature enough :)
...
llvm-svn: 76845
2009-07-23 03:17:50 +00:00