Commit Graph

49 Commits

Author SHA1 Message Date
Reid Kleckner f80abc060c Fix warning in ms-x86-vtordisp test case
llvm-svn: 206224
2014-04-14 23:49:17 +00:00
David Majnemer d43388cc04 MS ABI: #pragma vtordisp(0) only disables new vtordisps
Previously, it was believed that #pragma vtordisp(0) would prohibit the
generation of any and all vtordisps.

In actuality, it only disables the generation of additional vtordisps.

This fixes PR19413.

llvm-svn: 206124
2014-04-13 02:27:32 +00:00
Warren Hunt 0e70d916f2 [MS-ABI] Fixed alias-avoidance padding in the presence of vtordisps
If a vtordisp exists between two bases, then there is no need for 
additional alias avoidance padding.  Test case included.

llvm-svn: 206087
2014-04-11 23:33:35 +00:00
Warren Hunt 73f4398782 [MS-ABI] Update to vtordisp computation
A portion of the vtordisp computation that was previously unguarded by a 
test for the declaration of user defined constructors/destructors was 
erroniously adding vtordisps to things that shouldn't have them.  This 
patch correctly guards that codepath.  In addition, it updates the 
comments to make them more clear.  Test case is included.

llvm-svn: 206077
2014-04-11 22:05:28 +00:00
Warren Hunt 29a2b955fb [MS-ABI] Update virtual base padding rules to match MSVC 10+
In version 9 (VS2010) (and prior)? versions of msvc, if the last field 
in a record was a bitfield padding equal to the size of the storage 
class of that bitfield was added before each vbase and vtordisp.  This 
patch removes that feature from clang and updates the lit tests to 
reflect it. 

llvm-svn: 206004
2014-04-11 00:14:09 +00:00
Warren Hunt bb9c3c33e9 [MS-ABI] Fix to vbptr injection site calculation.
The vbptr is injected after the last non-virtual base lexographically 
rather than the last non-virtual base in layout order.  Test case 
included.  Also, some line ending fixes.

llvm-svn: 206000
2014-04-10 23:23:34 +00:00
Warren Hunt 5d9eebfec6 [MS-ABI] Fixed __declspec(align()) on bitfields under #pragma pack.
When __declspec(align()) is applied to a bitfield it affects the 
alignment rather than the required alignment of the struct.  The major 
feature that this patch adds is that the alignment of the structure 
obeys the alignment of __declspec(align()) from the bitfield over the 
value specified in pragma pack.

Test cases are included.
The patch also includes some small cleanups in recordlayoutbuilder and 
some cleanups to some lit tests, including line endings (but no 
functionality change to lit tests)

llvm-svn: 205994
2014-04-10 22:15:18 +00:00
Warren Hunt 39a907b1c2 [MS-ABI] Update to alias-avoidance padding
This patch changes how we determine if padding is needed between two 
bases in msvc compatibility mode.  Test cases included.

In addition, a very minor change to the printing of structures to ease 
lit testing.

llvm-svn: 205933
2014-04-09 21:57:24 +00:00
David Blaikie abe1a398e3 Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda at ... )')
For namespaces, this is consistent with mangling and GCC's debug info
behavior. For structs, GCC uses <anonymous struct> but we prefer
consistency between all anonymous entities but don't want to confuse
them with template arguments, etc, so we'll just go with parens in all
cases.

llvm-svn: 205398
2014-04-02 05:58:29 +00:00
Warren Hunt c89450e054 [MS-ABI] Drop Special Layout in 64-bit mode.
As of cl.exe version 18, the special layout rules for structs with 
alignment 16 or greater has been dropped.  This patch drops the behavior 
from clang.  This patch also updates the lit tests to reflect the 
change.

llvm-svn: 204674
2014-03-24 21:37:27 +00:00
Reid Kleckner ad59deb436 -fdump-record-layouts: Sort nvbases by offset before printing them
It makes our -fdump-record-layouts a little more sane.

llvm-svn: 202457
2014-02-28 01:03:09 +00:00
Reid Kleckner db673ca26a MS ABI: Just use getTypeInfoInChars to get the field size
This was changed to use manual desugaring and multiplication in r201832
and fixed for multi-dimensional arrays in r201917.  However, it breaks
down in the presence of typedefs.  Rather than attempting to handle all
the desugaring, just go back to calling the generic type info code.

This was discovered while compiling SIInstrWaits.cpp in the R600
backend.

llvm-svn: 202175
2014-02-25 18:08:48 +00:00
Warren Hunt c85942038a [MS-ABI] Fix MSRecordLayout to handel MultiDimensionalArrays
A recent change caused multi-dimensional arrays not to be handled 
correctly, this patch fixes that.  Also, it adds a lit test for 
multi-dimensional arrays.

llvm-svn: 201917
2014-02-22 00:40:37 +00:00
Warren Hunt f6ec74826e [MS-ABI] Update to zero-sized padding algorithm
Slight change to the way zero-sized sub-objects are tracked in the 
presence of virtual bases.
In addition we correctly distinguish between dsize and nvsize.
addresses http://llvm.org/bugs/show_bug.cgi?id=18826
Unit tests are included.

llvm-svn: 201832
2014-02-21 01:40:35 +00:00
David Majnemer 144d9a059b MS ABI: Fix some layout tests
Some lines intended to be used for testing x86_64 ABI compatibility were
not firing because lines were annotated with the wrong FileCheck prefix:
X64 vs 64

llvm-svn: 201454
2014-02-15 01:21:20 +00:00
David Majnemer 805d759664 MS ABI: Fix some layout tests
Some lines intended to be used for testing x86_64 ABI compatibility were
not firing because lines were annotated with the wrong FileCheck prefix:
X64 vs C64

llvm-svn: 201453
2014-02-15 01:09:56 +00:00
Reid Kleckner f50dc56baa Fix some -Wdocumentation warnings in Sema.h and try to fix test for win64
llvm-svn: 201278
2014-02-13 00:22:04 +00:00
Reid Kleckner c0dca6ded7 MS ABI: Implement #pragma vtordisp() and clang-cl /vdN
These features are new in VS 2013 and are necessary in order to layout
std::ostream correctly.  Currently we have an ABI incompatibility when
self-hosting with the 2013 stdlib in our convertible_fwd_ostream wrapper
in gtest.

This change adds another implicit attribute, MSVtorDispAttr, because
implicit attributes are currently the best way to make sure the
information stays on class templates through instantiation.

Reviewers: majnemer

Differential Revision: http://llvm-reviews.chandlerc.com/D2746

llvm-svn: 201274
2014-02-12 23:50:26 +00:00
David Majnemer 79a1c89066 MS ABI: vptr injection should obey alignment requirements
vptr injection must inject padding equivalent to the alignment of the
most aligned non-virtual subobject, not the alignment of the enclosing
record.

To fascilitate this change, don't let record layout observe the
alignment of the record until we've injected our vptrs. Also, do not
allow the alignment of vbases to affect required alignment until just
before we insert the vtordisp field.

llvm-svn: 201199
2014-02-12 00:43:02 +00:00
David Majnemer 04606bda08 MS ABI: Fix some layout tests
Some lines intended to be used for testing x86_64 ABI compatibility were
not firing because lines were annotated with the wrong FileCheck prefix:
X64 vs x64

N.B. Changes beyond just changing x64 to X64 were made, presumably
because other parts of the layout engine have changed.  I've verified
the changes to make sure that MSVC creates a compatible layout.

llvm-svn: 200670
2014-02-03 00:29:57 +00:00
Reid Kleckner bd63b33854 [ms-cxxabi] Raise aggregate memptr alignment to 8 for x86_32
With this change, we give different results for __alignof than MSVC, but
our record layout is compatible.

Some data member pointers also now have a size that is not a multiple of
their alignment.

Fixes PR18618.

Reviewers: majnemer

Differential Revision: http://llvm-reviews.chandlerc.com/D2669

llvm-svn: 200585
2014-01-31 22:28:50 +00:00
Hans Wennborg c9bd88e681 Remove the -cxx-abi command-line flag.
This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples,
Itanium otherwise. It's no longer possible to do weird combinations.

To be able to run a test with a specific ABI without constraining it to a
specific triple, new substitutions are added to lit: %itanium_abi_triple and
%ms_abi_triple can be used to get the current target triple adjusted to the
desired ABI. For example, if the test suite is running with the i686-pc-win32
target, %itanium_abi_triple will expand to i686-pc-mingw32.

Differential Revision: http://llvm-reviews.chandlerc.com/D2545

llvm-svn: 199250
2014-01-14 19:35:09 +00:00
Warren Hunt 26b944274e [ms-abi] Small Change to pack+alignment interaction.
This patch makes a small behavioral change to the interaction between 
pack and alignment.  Specifically it makes __declspec(align()) on a 
field change that field's alignment without respect to pack but the 
alignment change to the record alignment as a whole still obeys pack.

llvm-svn: 199172
2014-01-14 00:54:36 +00:00
Warren Hunt 4c73e59475 [ms-abi] Reordering __declspec(align) pragma pack handling
This patch moves the check for pragma pack until after the application 
of __declspec align to before pragma pack.  This causes observable 
changes in the use of tail padding for bases.  A test case is included.

llvm-svn: 199154
2014-01-13 22:25:55 +00:00
Warren Hunt badf9e0f84 [ms-abi] Leading VFPtrs don't suppress the leading zero sized flag
The MS-ABI tracks a bit that asserts that the first sub-object is zero 
sized.  This bit is used to add padding between objects if there's the 
potential for zero sized objects to alias.  The bit is still true even 
if the zero sized base is lead by a VFPtr.  This patch makes clang mimic 
that behavior.

llvm-svn: 199132
2014-01-13 19:55:52 +00:00
Reid Kleckner 4f017ceeda [ms-abi] Quick fix layout of an array of records
This fixes llvm::SmallVector, which fixes lots of TUs in the MS ABI self
host.

llvm-svn: 199129
2014-01-13 19:25:00 +00:00
Warren Hunt 9425891f28 [ms-abi] Change the way alignment is tracked
This patch more cleanly seperates the concepts of Preferred Alignment 
and Required Alignment.  Most notable that changes to Required Alignment 
do *not* impact preferred alignment until late in struct layout.  This 
is observable when using pragma pack and non-virtual bases and the use 
of tail padding when laying them out.

Test cases included.

llvm-svn: 198988
2014-01-11 01:16:40 +00:00
Warren Hunt 87c2b0400d [ms-abi] Adjusting Rules for Padding Between Bases
The presence of a VBPtr suppresses the presence of zero sized 
sub-objects in the non-virtual portion of the object in the context of 
determining if two base objects need alias-avoidance padding placed 
between them.

Test cases included.

llvm-svn: 198975
2014-01-10 23:32:32 +00:00
Warren Hunt f4518def33 [ms-abi] Handle __declspec(align) on bitfields "properly"
__declspec(align), when applied to bitfields affects their perferred 
alignment instead of their required alignment.  We don't know why.  
Also, #pragma pack(n) turns packing *off* if n is greater than the 
pointer size.  This is now observable because of the impact of 
declspec(align) on bitfields.

llvm-svn: 198907
2014-01-10 01:28:05 +00:00
Warren Hunt d640d7d96e [ms-abi] Refactor Microsoft Record Layout
This patch refactors microsoft record layout to be more "natural".  The 
most dominant change is that vbptrs and vfptrs are injected after the 
fact.  This simplifies the implementation and the math for the offest 
for the first base/field after the vbptr.

llvm-svn: 198818
2014-01-09 00:30:56 +00:00
Warren Hunt 63701d2533 [ms-abi] unix-line endings in lit test, no functional change
llvm-svn: 198060
2013-12-26 22:10:14 +00:00
Warren Hunt 50de3522e6 [ms-abi] Fixes improperly sized vfptrs with pragma pack
With pragma pack, the layout engine would produce vfptrs that were 
packed width rather than pointer width.  This patch addresses the issue 
and adds a test case.

llvm-svn: 198059
2013-12-26 22:09:12 +00:00
Warren Hunt f037bd1e7c [ms-abi] Update Alignment for VtorDisps
The alignment impact of the virtual bases apperas to be applied in 
order, rather than up front.  This patch adds the new behavior and 
provides a test case.

llvm-svn: 197639
2013-12-19 00:43:59 +00:00
Warren Hunt 4431fe6bec [ms-abi] Refactoring Non-virtual base layout in record layout
This refactor addresses bugzilla bug 18167 and simplifies the code at 
the same time.  Also I add a test case for the bug.  Also I make a 
non-functional change to the basic layout lit tests to make them more 
reliable (using CHECK-NEXT instead of CHECK).

llvm-svn: 197183
2013-12-12 22:33:37 +00:00
Warren Hunt 1b5184321d [ms-abi] Makes Virtual Base Alignment Look at All Virtual Bases
Prior to this patch, the alignment imposed by virtual bases only 
included direct virtual bases.  This patch fixes it to look at all 
virtual bases.

llvm-svn: 196997
2013-12-11 02:21:03 +00:00
Warren Hunt 1603e52700 [ms-abi] 64-bit fixes for r196549
In order to address latent bugs that were easier to expose in 64-bit 
mode, we move the application of __declspec(align) to before the layout 
of vbases rather than after.

llvm-svn: 196861
2013-12-10 01:44:39 +00:00
Warren Hunt 71140d68f8 [MS-ABI] adds padding before all vbases after a bitfield
MS-ABI adds padding before *every* vbase if the last field in a record 
is a bit-field. This changes clangs behavior to match. I also fix some 
windows-style line endings in the test file.

Differential Revision: http://llvm-reviews.chandlerc.com/D2277

llvm-svn: 196605
2013-12-06 20:16:49 +00:00
Warren Hunt 049f673dae [MS-ABI] Fix alias-avoidance padding between bases
Adds padding between bases or virtual bases in an attempt to avoid 
aliasing of zero-sized sub-objects.  The approach used by the ABI adds 
two more bits of state.  Detailed comments are in the code.  Test cases 
included.

Differential Revision: http://llvm-reviews.chandlerc.com/D2258

llvm-svn: 196602
2013-12-06 19:54:25 +00:00
Warren Hunt 7b252d24ad Support MS-ABI's concept of "Required Alignment" imposed by
__declspec(align())

This patch implements required alignment in a way that makes 
__declspec(align()) and #pragma pack play correctly together. In the 
MS-ABI, __declspec(align()) is a hard rule and cannot be overridden by 
#pragma pack. This cases each record to have two interesting alignments 
"preferred alignment" (which matches Itanium's concept of alignment) and 
"required alignment" which is an alignment that must never be violated, 
even in the case of #pragma pack. This patch introduces the concept of 
Required Alignment to the record builder and tracks/uses it 
appropriately. Test cases are included.

Differential Revision: http://llvm-reviews.chandlerc.com/D2283

llvm-svn: 196549
2013-12-06 00:01:17 +00:00
Warren Hunt c0df47dfed Microsoft Record Layout: zero sized base after base with vbtbl fix
Microsoft adds an extra byte of padding before laying out zero sized 
non-virtual bases if the non-virtual base before it contains a vbptr.  
This patch adds the same behavior to clang.

Differential Revision: http://llvm-reviews.chandlerc.com/D2106

llvm-svn: 195158
2013-11-19 22:11:09 +00:00
Warren Hunt d840e40113 Makes A Microsoft Layout CodeGen Test Explicit
This patch tests introduces a proper codegen test in place of the 
"codegen no longer crashes" test introduced in r193664. The test is also 
moved from layout to CodeGenCXX.

Differential Revision: http://llvm-reviews.chandlerc.com/D2174

llvm-svn: 194739
2013-11-14 22:34:59 +00:00
Warren Hunt 6b7048ddd8 Microsoft adds weird padding before virtual bases if the last field was a bitfield
This patch adds the same behavior to clang.

Differential Revision: http://llvm-reviews.chandlerc.com/D2103

llvm-svn: 194115
2013-11-06 00:54:59 +00:00
Warren Hunt 5ae586ad45 Improves compatibility with cl.exe when laying out array fields
Differential Revision: http://llvm-reviews.chandlerc.com/D2090

Clang was "improperly" over-aligning arrays with sizes are not a multiple of 
their alignment. 
This behavior was removed in microsoft 32 bit mode.

In addition, after examination of ASTContext::getTypeInfoImpl, a redundant code block in 
MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo was deleted.

llvm-svn: 193898
2013-11-01 23:59:41 +00:00
Warren Hunt af41fcce0e Activating latent test case for r193661.
llvm-svn: 193664
2013-10-30 00:08:34 +00:00
Warren Hunt 55d8e82f86 Implements 64 bit microsoft record layout and adds lit tests to cover
it.  Also removes all of the microsoft C++ ABI related code from the 
itanium layout builder.

Differential Revision: http://llvm-reviews.chandlerc.com/D2003

llvm-svn: 193290
2013-10-23 23:53:07 +00:00
Reid Kleckner bd5bd4b36a PR17576: Fix assertion on polymorphic classes with small alignment
We have to reserve at least the width of a pointer for the vfptr.  For
classes with small alignment, we weren't reserving enough space, and
were overlapping the first field with the vfptr.

llvm-svn: 192626
2013-10-14 21:14:05 +00:00
Warren Hunt e896819033 Fixing stdout/stderr interleaving in lit test.
llvm-svn: 192625
2013-10-14 20:58:36 +00:00
Warren Hunt 42be77672a Correctly check for distructors when realizing vtordisps
This patch fixes the distructor test when checking for vtordisp requirements in 
microsoft record layout.  A test case is also included.

Addresses:
http://llvm.org/bugs/show_bug.cgi?id=16406#c7

llvm-svn: 192616
2013-10-14 20:14:09 +00:00
Warren Hunt bd1b0c6916 Lit tests for Microsoft C++ record layout.
They weren't added with the rest of the microsoft record layout patch due me not 
doing svn add.

llvm-svn: 192612
2013-10-14 19:08:58 +00:00